scip-query 0.9.0 → 0.10.0

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 (129) hide show
  1. package/dist/{chunk-GD7XRHSV.js → chunk-2BMFRBV6.js} +2 -2
  2. package/dist/{chunk-3YQO3S5D.js → chunk-2WEH5QHC.js} +2 -2
  3. package/dist/{chunk-PE4EJOLN.js → chunk-4DAPXOWD.js} +2 -2
  4. package/dist/{chunk-EKP7XJ6L.js → chunk-4HTJZC6G.js} +2 -2
  5. package/dist/{chunk-RCRK4E7E.js → chunk-4JQFTUKD.js} +2 -2
  6. package/dist/{chunk-7I6KNKE3.js → chunk-4MHT7LKP.js} +2 -2
  7. package/dist/chunk-5OHZEO3U.js +3 -0
  8. package/dist/chunk-5QJIEYFB.js +34 -0
  9. package/dist/{chunk-Z2AJQ7VA.js → chunk-6DEX3XP6.js} +2 -2
  10. package/dist/{chunk-OMNT7E2T.js → chunk-6IGXZZQ4.js} +2 -2
  11. package/dist/{chunk-TA4DDU7J.js → chunk-6K2JQ2VI.js} +2 -2
  12. package/dist/{chunk-YO6DU7QZ.js → chunk-6QVCPUK6.js} +2 -2
  13. package/dist/chunk-6VL4AIEO.js +8 -0
  14. package/dist/{chunk-VHENVDS2.js → chunk-772YYL6I.js} +2 -2
  15. package/dist/{chunk-VTF5EH22.js → chunk-A2VTV2QB.js} +2 -2
  16. package/dist/{chunk-YSSTUCNS.js → chunk-ADRYSISR.js} +2 -2
  17. package/dist/{chunk-NM3BZXHA.js → chunk-AI2ECT7L.js} +2 -2
  18. package/dist/{chunk-TR5AU6A5.js → chunk-AP5GTKSG.js} +2 -2
  19. package/dist/{chunk-TCCUWKH4.js → chunk-BGRPMGTD.js} +2 -2
  20. package/dist/{chunk-7TYJD45F.js → chunk-BNW3Q24R.js} +2 -2
  21. package/dist/{chunk-K3V6XUTL.js → chunk-BUAC4Q4G.js} +2 -2
  22. package/dist/{chunk-SEZZ24IG.js → chunk-BZ6LCGE6.js} +2 -2
  23. package/dist/{chunk-ZJ737ZMD.js → chunk-CMXFASVD.js} +2 -2
  24. package/dist/{chunk-L6TOEQ2M.js → chunk-CO3AL7NZ.js} +2 -2
  25. package/dist/{chunk-ITUU3VE3.js → chunk-FVIKFWUL.js} +2 -2
  26. package/dist/{chunk-APLCSDXL.js → chunk-FVVT7GV6.js} +2 -2
  27. package/dist/chunk-HXXRN77A.js +2 -0
  28. package/dist/{chunk-NK7TQQG4.js → chunk-IC3RC3KJ.js} +2 -2
  29. package/dist/chunk-ISCKLDSS.js +22 -0
  30. package/dist/chunk-ITHQJZTG.js +2 -0
  31. package/dist/{chunk-RIXOMSOR.js → chunk-IVAIPXNO.js} +2 -2
  32. package/dist/{chunk-NO2TPMCQ.js → chunk-IW7ASGVF.js} +2 -2
  33. package/dist/{chunk-I66MQD5U.js → chunk-JODYQDE4.js} +2 -2
  34. package/dist/{chunk-HDA2V5DC.js → chunk-L2KFPRMA.js} +2 -2
  35. package/dist/{chunk-U254PV4S.js → chunk-MCW36F2D.js} +2 -2
  36. package/dist/{chunk-SDGCKEB7.js → chunk-MN75T4UB.js} +2 -2
  37. package/dist/{chunk-AGW2MVIO.js → chunk-NC4IUW25.js} +2 -2
  38. package/dist/{chunk-2DVVHNC3.js → chunk-NGI4V4AB.js} +2 -2
  39. package/dist/{chunk-SOGLYIJ4.js → chunk-O6KCZPJQ.js} +2 -2
  40. package/dist/chunk-OAI5GEIN.js +6 -0
  41. package/dist/chunk-OH5HIAID.js +4 -0
  42. package/dist/{chunk-NGLRXEWN.js → chunk-OLCKSG3Y.js} +2 -2
  43. package/dist/{chunk-JTCEWV7Q.js → chunk-OXKEUWMJ.js} +2 -2
  44. package/dist/{chunk-LBAMALDV.js → chunk-PRVDXGSK.js} +2 -2
  45. package/dist/{chunk-46ILZVMX.js → chunk-QJWN6LA5.js} +2 -2
  46. package/dist/{chunk-BCFED24F.js → chunk-QKO474FG.js} +2 -2
  47. package/dist/{chunk-TQTVM27C.js → chunk-QYKKTYBN.js} +2 -2
  48. package/dist/{chunk-UUDYI3FF.js → chunk-R6XDPWJA.js} +2 -2
  49. package/dist/{chunk-D43L5PQF.js → chunk-SCEMECW7.js} +2 -2
  50. package/dist/{chunk-2Y2WIJI4.js → chunk-SJR4SB7B.js} +2 -2
  51. package/dist/chunk-SYKCO25G.js +16 -0
  52. package/dist/{chunk-FYT2PE7C.js → chunk-T22X7WT6.js} +2 -2
  53. package/dist/{chunk-Y3RUPPIU.js → chunk-VDY4HYNK.js} +2 -2
  54. package/dist/{chunk-EAU4RDFG.js → chunk-VDZIEDJB.js} +2 -2
  55. package/dist/{chunk-6ZFKI5EP.js → chunk-VGBSY6N7.js} +2 -2
  56. package/dist/{chunk-VN6B6HFB.js → chunk-VZRILF2Z.js} +2 -2
  57. package/dist/{chunk-CVRXOP6M.js → chunk-WJIS6BNI.js} +2 -2
  58. package/dist/{chunk-SLX5XBCD.js → chunk-WN5Z3UVT.js} +2 -2
  59. package/dist/{chunk-6G76D2YM.js → chunk-XCW7DYHM.js} +2 -2
  60. package/dist/{chunk-6HP3BKIP.js → chunk-Y5H7TBVE.js} +2 -2
  61. package/dist/{chunk-I7OTKWNY.js → chunk-YWZBKYLS.js} +2 -2
  62. package/dist/{chunk-64UY7VTR.js → chunk-ZF6P2NAT.js} +3 -3
  63. package/dist/{chunk-VQGQHIAT.js → chunk-ZGIK464P.js} +2 -2
  64. package/dist/{chunk-WC43FMAB.js → chunk-ZOT3WUZW.js} +2 -2
  65. package/dist/{chunk-TFO4OMJZ.js → chunk-ZZ2W5P3D.js} +2 -2
  66. package/dist/cli.js +171 -151
  67. package/dist/index.js +1 -1
  68. package/dist/queries/affected.js +1 -1
  69. package/dist/queries/bottlenecks.js +1 -1
  70. package/dist/queries/by-kind.js +1 -1
  71. package/dist/queries/call-graph.js +1 -1
  72. package/dist/queries/change-surface.js +1 -1
  73. package/dist/queries/cleanup-plan.js +1 -1
  74. package/dist/queries/co-change.js +1 -1
  75. package/dist/queries/code.js +1 -1
  76. package/dist/queries/complexity-hotspots.js +1 -1
  77. package/dist/queries/complexity.js +1 -1
  78. package/dist/queries/convergence.js +1 -1
  79. package/dist/queries/coupling.js +1 -1
  80. package/dist/queries/cycles.js +1 -1
  81. package/dist/queries/dataflow.js +1 -1
  82. package/dist/queries/dead.js +1 -1
  83. package/dist/queries/deep-chains.js +1 -1
  84. package/dist/queries/deps.js +1 -1
  85. package/dist/queries/diff-gate.d.ts +5 -1
  86. package/dist/queries/diff-gate.js +1 -1
  87. package/dist/queries/diff-impact.js +1 -1
  88. package/dist/queries/doc-drift.js +1 -1
  89. package/dist/queries/drift.js +1 -1
  90. package/dist/queries/extract-candidates.js +1 -1
  91. package/dist/queries/fan.js +1 -1
  92. package/dist/queries/health.js +1 -1
  93. package/dist/queries/hierarchy.js +1 -1
  94. package/dist/queries/hotspots.js +1 -1
  95. package/dist/queries/imports.js +1 -1
  96. package/dist/queries/incomplete-migration.js +1 -1
  97. package/dist/queries/index.d.ts +1 -1
  98. package/dist/queries/index.js +1 -1
  99. package/dist/queries/isolated.js +1 -1
  100. package/dist/queries/members.js +1 -1
  101. package/dist/queries/methods.js +1 -1
  102. package/dist/queries/outline.js +1 -1
  103. package/dist/queries/passthrough-candidates.js +1 -1
  104. package/dist/queries/plan-context.js +1 -1
  105. package/dist/queries/recent-duplicates.js +1 -1
  106. package/dist/queries/redundant-reexports.js +1 -1
  107. package/dist/queries/refs.js +1 -1
  108. package/dist/queries/self-audit.js +1 -1
  109. package/dist/queries/similar-chains.js +1 -1
  110. package/dist/queries/similar-files.js +1 -1
  111. package/dist/queries/similar-signatures.js +1 -1
  112. package/dist/queries/similar.js +1 -1
  113. package/dist/queries/slice.js +1 -1
  114. package/dist/queries/stale-abstractions.js +1 -1
  115. package/dist/queries/surface.js +1 -1
  116. package/dist/queries/symbols.js +1 -1
  117. package/dist/queries/system.js +1 -1
  118. package/dist/queries/trace.js +1 -1
  119. package/dist/queries/unused-params.js +1 -1
  120. package/dist/queries/wrapper-candidates.js +1 -1
  121. package/package.json +1 -1
  122. package/dist/chunk-44G4P3GJ.js +0 -2
  123. package/dist/chunk-IBM6FXOQ.js +0 -3
  124. package/dist/chunk-LR7E2ATW.js +0 -8
  125. package/dist/chunk-PCMVXWDC.js +0 -34
  126. package/dist/chunk-PLFYFZX3.js +0 -2
  127. package/dist/chunk-SQ6VENQY.js +0 -6
  128. package/dist/chunk-T4AK46CM.js +0 -16
  129. package/dist/chunk-WQFOZIID.js +0 -4
@@ -0,0 +1,16 @@
1
+ import{a as h}from"./chunk-IW7ASGVF.js";import{e as y}from"./chunk-ZF6P2NAT.js";import{c as g,f as d,h as p}from"./chunk-O6KCZPJQ.js";import{execFileSync as u}from"child_process";var I="Unable to compute git diff.";function k(e,n={}){let t=S(e,n);return t.note?F(t.note,t.changedFileLines):t.changedFiles.length===0?_(t.changedFileLines):D(t.changedFiles,[C(e,t.changedFiles,t.changedFiles)])}function S(e,n={}){let{base:t="HEAD"}=n;try{let s=x(e.config.projectRoot,t);return{changedFileLines:s,changedFiles:N(e,s),note:s.length===0?"No changed files found.":void 0}}catch{return{changedFileLines:[],changedFiles:[],note:I}}}function C(e,n,t){let s=new h(e),o=new Set(t),a=[],l=new Map,i=n.flatMap(r=>s.definitionsForFile(r)).filter(w).sort((r,f)=>r.relativePath.localeCompare(f.relativePath)||r.startLine-f.startLine),m=new Map(i.map(r=>[r.symbolId,M(e,r.symbolId)])),c=y(e,i.filter(r=>m.get(r.symbolId)===0));for(let r of i)E(e,r,t,o,a,l,c.get(r.symbolId)??new Set,m.get(r.symbolId)??0);return{changedSymbols:a,consumerEntries:[...l.entries()].map(([r,f])=>({file:r,symbols:[...f].sort()}))}}function D(e,n){let t=new Map,s=n.flatMap(a=>a.changedSymbols);for(let a of n)for(let l of a.consumerEntries){let i=t.get(l.file);i||(i=new Set,t.set(l.file,i));for(let m of l.symbols)i.add(m)}let o=L(t);return{changedFiles:[...e],changedSymbols:s,affectedConsumers:o,summary:{totalChangedFiles:e.length,totalChangedSymbols:s.length,totalAffectedFiles:o.length}}}function F(e,n=[]){return{changedFiles:n,changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:n.length,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function _(e){return{changedFiles:e,changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:e.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}}}function x(e,n){let t=u("git",["diff","--name-only",n],{encoding:"utf-8",cwd:e,timeout:1e4}),s=u("git",["diff","--name-only","--cached",n],{encoding:"utf-8",cwd:e,timeout:1e4}),o=u("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:1e4});return[...new Set([t,s,o].flatMap(a=>a.split(`
2
+ `)).map(a=>a.trim()).filter(a=>a.length>0))]}function N(e,n){let t=[];for(let s of n){let o=e.get(`SELECT relative_path FROM documents
3
+ WHERE relative_path LIKE ?
4
+ LIMIT 1`,`%${s}`);o&&!e.isIgnored(o.relative_path)&&t.push(o.relative_path)}return t}function E(e,n,t,s,o,a,l,i){let m=Math.max(i,l.size);if(!A(n,m))return;let c=g(n.symbol);o.push({symbol:n.symbol,shortName:c,file:n.relativePath,fanIn:m});for(let r of R(e,n.symbolId,t))b(e,s,a,r,c);for(let r of l)b(e,s,a,r,c)}function M(e,n){return e.get(`SELECT COUNT(DISTINCT c.document_id) AS fan_in
5
+ FROM mentions m
6
+ JOIN chunks c ON m.chunk_id = c.id
7
+ WHERE m.symbol_id = ?
8
+ AND m.role != 1`,n)?.fan_in??0}function R(e,n,t){return t.length===0?[]:e.all(`SELECT DISTINCT ref_d.relative_path
9
+ FROM mentions m
10
+ JOIN chunks c ON m.chunk_id = c.id
11
+ JOIN documents ref_d ON c.document_id = ref_d.id
12
+ WHERE m.symbol_id = ?
13
+ AND m.role != 1
14
+ AND ref_d.relative_path NOT IN (${t.map(()=>"?").join(",")})
15
+ ${e.pathExclusionsFor("ref_d")}`,n,...t).map(o=>o.relative_path)}function b(e,n,t,s,o){if(e.isIgnored(s)||n.has(s))return;let a=t.get(s);a||(a=new Set,t.set(s,a)),a.add(o)}function L(e){return[...e.entries()].map(([n,t])=>({file:n,consumedSymbols:t.size})).sort((n,t)=>t.consumedSymbols-n.consumedSymbols)}function w(e){return!(p(e.symbol)||e.parentTypeName!==null&&!d(e.symbol))}function A(e,n){return d(e.symbol)||e.isTypeLike?!0:e.parentTypeName===null&&n>0}export{I as a,k as b,S as c,C as d,D as e};
16
+ //# sourceMappingURL=chunk-SYKCO25G.js.map
@@ -1,2 +1,2 @@
1
- import{c as m}from"./chunk-UIWAZ2NT.js";import{a as d}from"./chunk-RIXOMSOR.js";function v(t,s={}){let{minSimilarity:o=.5,limit:f=20,scope:n,filePattern:p}=s,l=s.minDeps??(p?1:3),{profiles:e,distinctiveDeps:c}=h(t,{scope:n,minDeps:l}),i=[];if(p){let r=e.find(u=>u.file.includes(p));if(!r)return[];for(let u of e){if(u.file===r.file)continue;let a=g(r,u,o,c);a&&i.push(a)}}else for(let r=0;r<e.length;r++){for(let u=r+1;u<e.length;u++){let a=g(e[r],e[u],o,c);a&&i.push(a)}if(i.length>f*5)break}return i.sort((r,u)=>u.similarity-r.similarity),i.slice(0,f)}function h(t,s){let{scope:o,minDeps:f}=s,n=d(t,o),{universalDeps:p,distinctiveDeps:l}=D(n),e=[];for(let[c,i]of n)i.size>=f&&e.push({file:c,deps:new Set([...i].filter(r=>!p.has(r)))});return{profiles:e,distinctiveDeps:l}}function D(t){let s=new Set,o=new Set,f=t.size;if(f===0)return{universalDeps:s,distinctiveDeps:o};let n=new Map;for(let l of t.values())for(let e of l)n.set(e,(n.get(e)??0)+1);let p=Math.max(3,Math.ceil(f*.03));for(let[l,e]of n)e>=5&&e/f>.3?s.add(l):e<=p&&o.add(l);return{universalDeps:s,distinctiveDeps:o}}function g(t,s,o,f){let n=new Set;for(let i of t.deps)s.deps.has(i)&&n.add(i);if(n.size<3||t.deps.size<4||s.deps.size<4)return null;let p=0;for(let i of n)f.has(i)&&p++;if(p<2)return null;let l=m(t.deps,s.deps);if(l<o)return null;let e=[];for(let i of t.deps)s.deps.has(i)||e.push(i);let c=[];for(let i of s.deps)t.deps.has(i)||c.push(i);return{fileA:t.file,fileB:s.file,similarity:l,sharedDeps:[...n],uniqueToA:e,uniqueToB:c}}export{v as a};
2
- //# sourceMappingURL=chunk-FYT2PE7C.js.map
1
+ import{c as m}from"./chunk-UIWAZ2NT.js";import{a as d}from"./chunk-IVAIPXNO.js";function v(t,s={}){let{minSimilarity:o=.5,limit:f=20,scope:n,filePattern:p}=s,l=s.minDeps??(p?1:3),{profiles:e,distinctiveDeps:c}=h(t,{scope:n,minDeps:l}),i=[];if(p){let r=e.find(u=>u.file.includes(p));if(!r)return[];for(let u of e){if(u.file===r.file)continue;let a=g(r,u,o,c);a&&i.push(a)}}else for(let r=0;r<e.length;r++){for(let u=r+1;u<e.length;u++){let a=g(e[r],e[u],o,c);a&&i.push(a)}if(i.length>f*5)break}return i.sort((r,u)=>u.similarity-r.similarity),i.slice(0,f)}function h(t,s){let{scope:o,minDeps:f}=s,n=d(t,o),{universalDeps:p,distinctiveDeps:l}=D(n),e=[];for(let[c,i]of n)i.size>=f&&e.push({file:c,deps:new Set([...i].filter(r=>!p.has(r)))});return{profiles:e,distinctiveDeps:l}}function D(t){let s=new Set,o=new Set,f=t.size;if(f===0)return{universalDeps:s,distinctiveDeps:o};let n=new Map;for(let l of t.values())for(let e of l)n.set(e,(n.get(e)??0)+1);let p=Math.max(3,Math.ceil(f*.03));for(let[l,e]of n)e>=5&&e/f>.3?s.add(l):e<=p&&o.add(l);return{universalDeps:s,distinctiveDeps:o}}function g(t,s,o,f){let n=new Set;for(let i of t.deps)s.deps.has(i)&&n.add(i);if(n.size<3||t.deps.size<4||s.deps.size<4)return null;let p=0;for(let i of n)f.has(i)&&p++;if(p<2)return null;let l=m(t.deps,s.deps);if(l<o)return null;let e=[];for(let i of t.deps)s.deps.has(i)||e.push(i);let c=[];for(let i of s.deps)t.deps.has(i)||c.push(i);return{fileA:t.file,fileB:s.file,similarity:l,sharedDeps:[...n],uniqueToA:e,uniqueToB:c}}export{v as a};
2
+ //# sourceMappingURL=chunk-T22X7WT6.js.map
@@ -1,2 +1,2 @@
1
- import{a as b}from"./chunk-V76FCF5F.js";import{a as c,b as f}from"./chunk-MX6F756F.js";import{a as u}from"./chunk-NO2TPMCQ.js";import{c as a,g as l}from"./chunk-SOGLYIJ4.js";import{g as d}from"./chunk-WQFOZIID.js";function D(i,e){let{scope:n,maxLoc:t=15,limit:r=30,scanLimit:g}=e??{},m=new u(i);return b({candidates:()=>y(m,n,t),orderCandidates:f,scanLimit:g,prepare:o=>m.calleeMap(o,{semantic:e?.semantic!==!1}),evaluate:(o,s)=>p(i,o,s.get(o.symbolId)??[]),orderResults:(o,s)=>o.loc-s.loc||o.file.localeCompare(s.file),limit:r})}function p(i,e,n){let t=h(n);if(t.size!==1||!d(i,e.relativePath,e.startLine,e.endLine))return null;let[,r]=[...t.entries()][0];return{symbol:e.symbol,shortName:a(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:c(e),forwardsTo:r.symbol,forwardsToShort:a(r.symbol),forwardsToFile:r.file}}function h(i){let e=i.some(t=>l(t.symbol))?i.filter(t=>l(t.symbol)):i,n=new Map;for(let t of e)n.has(t.symbol)||n.set(t.symbol,t);return n}function y(i,e,n){return i.productionCallableDefinitions({scope:e,minLoc:3,maxLoc:n,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0})}export{D as a};
2
- //# sourceMappingURL=chunk-Y3RUPPIU.js.map
1
+ import{a as b}from"./chunk-V76FCF5F.js";import{a as c,b as f}from"./chunk-MX6F756F.js";import{a as u}from"./chunk-IW7ASGVF.js";import{c as a,g as l}from"./chunk-O6KCZPJQ.js";import{g as d}from"./chunk-OH5HIAID.js";function D(i,e){let{scope:n,maxLoc:t=15,limit:r=30,scanLimit:g}=e??{},m=new u(i);return b({candidates:()=>y(m,n,t),orderCandidates:f,scanLimit:g,prepare:o=>m.calleeMap(o,{semantic:e?.semantic!==!1}),evaluate:(o,s)=>p(i,o,s.get(o.symbolId)??[]),orderResults:(o,s)=>o.loc-s.loc||o.file.localeCompare(s.file),limit:r})}function p(i,e,n){let t=h(n);if(t.size!==1||!d(i,e.relativePath,e.startLine,e.endLine))return null;let[,r]=[...t.entries()][0];return{symbol:e.symbol,shortName:a(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:c(e),forwardsTo:r.symbol,forwardsToShort:a(r.symbol),forwardsToFile:r.file}}function h(i){let e=i.some(t=>l(t.symbol))?i.filter(t=>l(t.symbol)):i,n=new Map;for(let t of e)n.has(t.symbol)||n.set(t.symbol,t);return n}function y(i,e,n){return i.productionCallableDefinitions({scope:e,minLoc:3,maxLoc:n,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0})}export{D as a};
2
+ //# sourceMappingURL=chunk-VDY4HYNK.js.map
@@ -1,2 +1,2 @@
1
- import{b as h}from"./chunk-PCMVXWDC.js";import{e as y,g as S,h as g,i as M,m as C}from"./chunk-6ZFKI5EP.js";import{d as R}from"./chunk-64UY7VTR.js";import{s as b}from"./chunk-SOGLYIJ4.js";import{c as f,i as m,k as p}from"./chunk-WQFOZIID.js";import{a as u}from"./chunk-NN3O7TPH.js";function D(e,n,t={}){let o=new Map;if(n&&n.length===0)return o;let i=u(e,{includeIgnored:!1}),a=M(e),r=n??b(e),l=new Set(r.map(s=>s.symbolId));return k(e,o,i,a,l),I(e,o,r,l),x(e,o,i,a,l),t.semantic!==!1&&_(o,R(e,A(r))),o}function k(e,n,t,o,i){for(let a of t){if(!f(a))continue;let r=m(e,a);if(r)for(let l of r){let s=S(a,o.get(l.calleeLeaf)??[]);if(!s||s.length===0)continue;let c=g(e,a,s,l.memberAccess);c&&i.has(c.symbolId)&&c.file!==a&&d(n,c.symbolId,a)}}}function I(e,n,t,o){let i=v(t);for(let a of L(e,o))e.isIgnored(a.relative_path)||w(a,i.get(a.symbol_id))||d(n,a.symbol_id,a.relative_path)}function L(e,n){return y(e,n?[...n]:void 0)}function v(e){let n=new Map;for(let t of e)n.set(t.symbolId,{docId:t.documentId,startLine:t.startLine,endLine:t.endLine});return n}function w(e,n){return!!n&&n.docId===e.document_id&&e.chunk_start>=n.startLine&&e.chunk_end<=n.endLine}function x(e,n,t,o,i){for(let a of t){if(f(a)!=="rust")continue;let r=p(e,a,{includeRustAttributeNames:!0});if(r.length!==0)for(let{name:l}of r){let s=o.get(l);if(s)for(let c of s)i.has(c.symbolId)&&c.file!==a&&d(n,c.symbolId,a)}}}function d(e,n,t){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(t)}function A(e){return e.filter(n=>"relativePath"in n&&"symbol"in n&&"leaf"in n)}function _(e,n){for(let[t,o]of n){let i=e.get(t);i||(i=new Set,e.set(t,i));for(let a of o)i.add(a)}}function O(e,n,t={}){return h(e,n,t)}function F(e,n,t={}){return D(e,n,t)}function j(e,n){return C(e,n)}function Q(e,n,t={}){let o=F(e,n,{semantic:t.semantic});return t.sourceFallback===!1?o:V(o,j(e,n))}function V(e,n){let t=new Map;for(let[o,i]of e)t.set(o,new Set(i));for(let[o,i]of n){let a=t.get(o)??new Set;for(let r of i)a.add(r);t.set(o,a)}return t}export{O as a,F as b,j as c,Q as d};
2
- //# sourceMappingURL=chunk-EAU4RDFG.js.map
1
+ import{b as h}from"./chunk-5QJIEYFB.js";import{e as y,g as S,h as g,i as M,m as C}from"./chunk-VGBSY6N7.js";import{e as R}from"./chunk-ZF6P2NAT.js";import{s as b}from"./chunk-O6KCZPJQ.js";import{c as f,i as m,k as p}from"./chunk-OH5HIAID.js";import{a as u}from"./chunk-NN3O7TPH.js";function D(e,n,t={}){let o=new Map;if(n&&n.length===0)return o;let i=u(e,{includeIgnored:!1}),a=M(e),r=n??b(e),l=new Set(r.map(s=>s.symbolId));return k(e,o,i,a,l),I(e,o,r,l),x(e,o,i,a,l),t.semantic!==!1&&_(o,R(e,A(r))),o}function k(e,n,t,o,i){for(let a of t){if(!f(a))continue;let r=m(e,a);if(r)for(let l of r){let s=S(a,o.get(l.calleeLeaf)??[]);if(!s||s.length===0)continue;let c=g(e,a,s,l.memberAccess);c&&i.has(c.symbolId)&&c.file!==a&&d(n,c.symbolId,a)}}}function I(e,n,t,o){let i=v(t);for(let a of L(e,o))e.isIgnored(a.relative_path)||w(a,i.get(a.symbol_id))||d(n,a.symbol_id,a.relative_path)}function L(e,n){return y(e,n?[...n]:void 0)}function v(e){let n=new Map;for(let t of e)n.set(t.symbolId,{docId:t.documentId,startLine:t.startLine,endLine:t.endLine});return n}function w(e,n){return!!n&&n.docId===e.document_id&&e.chunk_start>=n.startLine&&e.chunk_end<=n.endLine}function x(e,n,t,o,i){for(let a of t){if(f(a)!=="rust")continue;let r=p(e,a,{includeRustAttributeNames:!0});if(r.length!==0)for(let{name:l}of r){let s=o.get(l);if(s)for(let c of s)i.has(c.symbolId)&&c.file!==a&&d(n,c.symbolId,a)}}}function d(e,n,t){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(t)}function A(e){return e.filter(n=>"relativePath"in n&&"symbol"in n&&"leaf"in n)}function _(e,n){for(let[t,o]of n){let i=e.get(t);i||(i=new Set,e.set(t,i));for(let a of o)i.add(a)}}function O(e,n,t={}){return h(e,n,t)}function F(e,n,t={}){return D(e,n,t)}function j(e,n){return C(e,n)}function Q(e,n,t={}){let o=F(e,n,{semantic:t.semantic});return t.sourceFallback===!1?o:V(o,j(e,n))}function V(e,n){let t=new Map;for(let[o,i]of e)t.set(o,new Set(i));for(let[o,i]of n){let a=t.get(o)??new Set;for(let r of i)a.add(r);t.set(o,a)}return t}export{O as a,F as b,j as c,Q as d};
2
+ //# sourceMappingURL=chunk-VDZIEDJB.js.map
@@ -1,4 +1,4 @@
1
- import{c as C}from"./chunk-64UY7VTR.js";import{c as _}from"./chunk-7I6KNKE3.js";import{b as S}from"./chunk-APLCSDXL.js";import{t as M}from"./chunk-WEJYUS5O.js";import{c as I}from"./chunk-PBGTMPJ7.js";import{d as f,r as y,v as h}from"./chunk-SOGLYIJ4.js";import{a as m,c as v,f as b}from"./chunk-WQFOZIID.js";import{c as g,d as D}from"./chunk-VDZL45XI.js";function R(e,r,n,t={}){if(!n)return[];let i=m(e,r);return i?i.indexOf(n)===-1?[]:(L(e,r).get(n)??[]).filter(s=>!B(s,t)):[]}function B(e,r){return typeof r.excludeStartLine=="number"&&typeof r.excludeEndLine=="number"&&e>=r.excludeStartLine&&e<=r.excludeEndLine}var G=g("file-identifiers",{clearGroups:["whole-project","source-file"]});function w(e,r){let n=b(e,r);return n?n.fileIdentifiers:G.get(e,r,()=>new Set(L(e,r).keys()))}var H=g("file-ident-lines",{clearGroups:["whole-project","source-file"]});function L(e,r){let n=b(e,r);return n?n.identifierLineMap:H.get(e,r,()=>z(e,r))}var J=g("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function ie(e,r){let n=b(e,r);return n?n.identifiersByLine:J.get(e,r,()=>{let t=L(e,r),i=0;for(let s of t.values()){let c=s[s.length-1];c!==void 0&&c>i&&(i=c)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,c]of t)for(let a of c)o[a].add(s);return o})}function z(e,r){let n=new Map,t=(c,a)=>{let l=n.get(c);if(!l){n.set(c,[a]);return}l[l.length-1]!==a&&l.push(a)},i=m(e,r);if(!i)return n;let o=M(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<o.length;c+=1){let a=o[c]??"";for(let l of a.matchAll(s))l[1]&&t(l[1],c)}return n}function k(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function d(e,r){return k(e)===k(r)}function O(e,r){let n=new Map;for(let t of S(e,r)){if(!t.sourcePath)continue;let i=t.localName??t.importedName;if(i&&F(n,i,t.sourcePath),t.kind==="namespace")for(let o of t.usedMembers)F(n,o,t.sourcePath)}return n}function F(e,r,n){let t=e.get(r);t||(t=new Set,e.set(r,t)),t.add(n)}function le(e,r){return E(e,r,n=>{let t=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
1
+ import{d as C}from"./chunk-ZF6P2NAT.js";import{c as _}from"./chunk-4MHT7LKP.js";import{b as S}from"./chunk-FVVT7GV6.js";import{t as M}from"./chunk-WEJYUS5O.js";import{c as I}from"./chunk-PBGTMPJ7.js";import{d as f,r as y,v as h}from"./chunk-O6KCZPJQ.js";import{a as m,c as v,f as b}from"./chunk-OH5HIAID.js";import{c as g,d as D}from"./chunk-VDZL45XI.js";function R(e,r,n,t={}){if(!n)return[];let i=m(e,r);return i?i.indexOf(n)===-1?[]:(L(e,r).get(n)??[]).filter(s=>!B(s,t)):[]}function B(e,r){return typeof r.excludeStartLine=="number"&&typeof r.excludeEndLine=="number"&&e>=r.excludeStartLine&&e<=r.excludeEndLine}var G=g("file-identifiers",{clearGroups:["whole-project","source-file"]});function w(e,r){let n=b(e,r);return n?n.fileIdentifiers:G.get(e,r,()=>new Set(L(e,r).keys()))}var H=g("file-ident-lines",{clearGroups:["whole-project","source-file"]});function L(e,r){let n=b(e,r);return n?n.identifierLineMap:H.get(e,r,()=>z(e,r))}var J=g("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function ie(e,r){let n=b(e,r);return n?n.identifiersByLine:J.get(e,r,()=>{let t=L(e,r),i=0;for(let s of t.values()){let c=s[s.length-1];c!==void 0&&c>i&&(i=c)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,c]of t)for(let a of c)o[a].add(s);return o})}function z(e,r){let n=new Map,t=(c,a)=>{let l=n.get(c);if(!l){n.set(c,[a]);return}l[l.length-1]!==a&&l.push(a)},i=m(e,r);if(!i)return n;let o=M(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<o.length;c+=1){let a=o[c]??"";for(let l of a.matchAll(s))l[1]&&t(l[1],c)}return n}function k(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function d(e,r){return k(e)===k(r)}function O(e,r){let n=new Map;for(let t of S(e,r)){if(!t.sourcePath)continue;let i=t.localName??t.importedName;if(i&&F(n,i,t.sourcePath),t.kind==="namespace")for(let o of t.usedMembers)F(n,o,t.sourcePath)}return n}function F(e,r,n){let t=e.get(r);t||(t=new Set,e.set(r,t)),t.add(n)}function le(e,r){return E(e,r,n=>{let t=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
2
2
  m.symbol_id,
3
3
  d.relative_path,
4
4
  COUNT(*) AS ref_count
@@ -37,4 +37,4 @@ import{c as C}from"./chunk-64UY7VTR.js";import{c as _}from"./chunk-7I6KNKE3.js";
37
37
  ) mention_doc ON mention_doc.symbol_id = gs.id
38
38
  WHERE 1 = 1
39
39
  ${e.symbolNoiseFor("gs")}`),n=new Map;for(let t of r){if(!t.relative_path||e.isIgnored(t.relative_path))continue;let i=f(t.symbol);if(!i)continue;let o=n.get(i);o||(o=[],n.set(i,o)),o.some(s=>s.symbolId===t.id)||o.push({symbol:t.symbol,symbolId:t.id,file:t.relative_path})}return n})}function N(e,r,n){let t=x(e).get(n);if(!t||t.length===0)return[];if(t.length===1)return[p(t[0])];let i=t.filter(a=>a.file===r);if(i.length>0)return i.map(p);let o=O(e,r),s=o.get(n);if(s)for(let a of s){let l=t.filter(u=>d(a,u.file));if(l.length>0)return l.map(p)}let c=new Set;for(let a of o.values())for(let l of a)c.add(l);for(let a of c){let l=t.filter(u=>d(a,u.file));if(l.length>0&&l.length===t.length)return l.map(p)}return[]}function Ce(e,r,n){let t=N(e,r,n);if(t.length>0)return t;let i=x(e).get(n);return!i||i.length===0?[]:i.map(p)}function $(e,r,n={}){let t=_(e,r);if(!t)return[];let i=f(t.symbol);if(!i)return[];if(n.semantic!==!1){let s=C(e,{...t,leaf:i,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let c=new Map;for(let a of s){let l=c.get(a.file)??[];l.push(a.line),c.set(a.file,l)}return P(e,c)}}let o=new Map;for(let s of I(e)){let c=m(e,s);if(!c||c.indexOf(i)===-1||s!==t.relativePath&&!N(e,s,i).some(u=>u.symbolId===t.symbolId))continue;let a=R(e,s,i,s===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{});a.length>0&&o.set(s,a)}return P(e,o)}function we(e,r){let n=new Map;for(let o of r){if(!o.leaf)continue;let s=n.get(o.leaf)??[];s.push(o),n.set(o.leaf,s)}if(n.size===0)return new Map;let t=new Set(r.map(o=>o.symbolId)),i=new Map;for(let o of I(e)){let s=w(e,o);if(s.size!==0){for(let c of s)if(n.has(c))for(let a of N(e,o,c)){if(!t.has(a.symbolId)||o===a.relativePath)continue;let l=i.get(a.symbolId);l||(l=new Set,i.set(a.symbolId,l)),l.add(o)}}}return i}function p(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function P(e,r){let n=[],t=new Set;for(let[i,o]of r){let s=y(e,i);for(let c of o){let a=h(s,c),l=`${i}|${c}|${a?.symbol??""}`;t.has(l)||(t.add(l),n.push({file:i,line:c,enclosingSymbol:a?.symbol??null}))}}return n}function Y(e,r){let n=q(e,r);return n?K(e,Q(e,n.match,n.identifier)):[]}function je(e,r,n={}){return Z(e,r,n).map(t=>({file:t.file,line:t.line,enclosingSymbol:t.enclosingSymbol}))}function Z(e,r,n={}){let t=$(e,r,{semantic:n.semantic}),i=t.length>0?j(t,"source-attribution"):j(Y(e,r),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function j(e,r){return e.map(n=>({...n,provenance:r}))}function Q(e,r,n){let t=new Map;for(let[i,o]of U(e,r.symbolId))t.set(i,V(e,i,o,r,n));return t}function U(e,r){let n=new Map;for(let t of A(e,[r])){if(e.isIgnored(t.relative_path))continue;let i=n.get(t.relative_path);i||(i=[],n.set(t.relative_path,i)),i.push({start_line:t.chunk_start,end_line:t.chunk_end})}return n}function V(e,r,n,t,i){let o=r===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{},s=i?R(e,r,i,o):[];return n.flatMap(c=>X(s,c))}function X(e,r){let n=e.filter(t=>t>=r.start_line&&t<=r.end_line);return n.length>0?n:[r.start_line]}function q(e,r){let n=_(e,r);return n?{match:n,identifier:f(n.symbol)||null}:null}function K(e,r){let n=[],t=new Set;for(let[i,o]of r){let s=y(e,i);for(let c of o){let a=h(s,c),l=`${i}|${c}|${a?.symbol??""}`;t.has(l)||(t.add(l),n.push({file:i,line:c,enclosingSymbol:a?.symbol??null}))}}return n}export{L as a,ie as b,le as c,fe as d,A as e,d as f,Se as g,ye as h,x as i,O as j,N as k,Ce as l,we as m,Y as n,je as o};
40
- //# sourceMappingURL=chunk-6ZFKI5EP.js.map
40
+ //# sourceMappingURL=chunk-VGBSY6N7.js.map
@@ -1,3 +1,3 @@
1
- import{o as d}from"./chunk-6ZFKI5EP.js";import{a as h}from"./chunk-7I6KNKE3.js";import{g}from"./chunk-SOGLYIJ4.js";import{a as m}from"./chunk-WQFOZIID.js";import{a as p}from"./chunk-NN3O7TPH.js";function _(t,r,n={}){let e=h(t,r);if(!e)return[];let l=!g(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=d(t,e,{semantic:n.semantic}).map(o=>({relativePath:o.file,line:o.line})),s=R(t,e),f=new Set,a=[];for(let o of[...l,...c,...s]){let u=`${o.relativePath}:${o.line}`;f.has(u)||(f.add(u),a.push(o))}return a}function R(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=b(r.symbol);if(n.length===0)return[];let e=[];for(let i of p(t,{extensions:[".rb"],includeIgnored:!1})){let l=m(t,i);if(!l)continue;let c=l.split(`
1
+ import{o as d}from"./chunk-VGBSY6N7.js";import{a as h}from"./chunk-4MHT7LKP.js";import{g}from"./chunk-O6KCZPJQ.js";import{a as m}from"./chunk-OH5HIAID.js";import{a as p}from"./chunk-NN3O7TPH.js";function _(t,r,n={}){let e=h(t,r);if(!e)return[];let l=!g(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=d(t,e,{semantic:n.semantic}).map(o=>({relativePath:o.file,line:o.line})),s=R(t,e),f=new Set,a=[];for(let o of[...l,...c,...s]){let u=`${o.relativePath}:${o.line}`;f.has(u)||(f.add(u),a.push(o))}return a}function R(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=b(r.symbol);if(n.length===0)return[];let e=[];for(let i of p(t,{extensions:[".rb"],includeIgnored:!1})){let l=m(t,i);if(!l)continue;let c=l.split(`
2
2
  `);for(let s=0;s<c.length;s++){let f=c[s]??"";n.some(a=>new RegExp(`@${a}\\b|\\b${a}:`).test(f))&&e.push({relativePath:i,line:s})}}return e}function b(t){let n=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),e=n.split("_").filter(Boolean),i=new Set;return n&&i.add(n),e.length>=1&&i.add(e[e.length-1]),e.length>=2&&i.add(e.slice(-2).join("_")),[...i]}export{_ as a};
3
- //# sourceMappingURL=chunk-VN6B6HFB.js.map
3
+ //# sourceMappingURL=chunk-VZRILF2Z.js.map
@@ -1,3 +1,3 @@
1
- import{a as b}from"./chunk-APLCSDXL.js";import{d as x}from"./chunk-SOGLYIJ4.js";import{a as d,c as g,e as y}from"./chunk-WQFOZIID.js";import{c as u}from"./chunk-VDZL45XI.js";var S=u("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]});function I(t,e,n){return t.callerFileMap(e,{semantic:n.semantic,sourceFallback:n.sourceFallback})}function P(t,e,n){let r=[],i=0,s=0,p=x(e.symbol);for(let a of n)D(t,a,e.relativePath,p)?i++:C(t,a,p)?s++:r.push(a);return{realConsumers:r,barrelConsumers:i,importOnlyConsumers:s}}function C(t,e,n){if(!n)return!1;let r=g(e);if(!r)return!1;let i=S.get(t,e,()=>v(t,e,r));return i.importedLeaves.has(n)&&!i.usedLeaves.has(n)}function v(t,e,n){let r=new Set,i=new Set,s=y(t,e);if(!s)return{importedLeaves:r,usedLeaves:i};let p=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),a=(o,f)=>{let c=f||p.has(o.type);(o.type==="identifier"||o.type==="type_identifier"||o.type==="property_identifier"||o.type==="field_identifier")&&(c?r.add(o.text):i.add(o.text));for(let l of o.children)a(l,c)};return a(s.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function D(t,e,n,r){if(!r)return!1;let i=d(t,e);if(!i)return!1;let s=b(t,e);if(s.length===0)return!1;let p=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${p}\\b`),o=i.split(`
1
+ import{a as b}from"./chunk-FVVT7GV6.js";import{d as x}from"./chunk-O6KCZPJQ.js";import{a as d,c as g,e as y}from"./chunk-OH5HIAID.js";import{c as u}from"./chunk-VDZL45XI.js";var S=u("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]});function I(t,e,n){return t.callerFileMap(e,{semantic:n.semantic,sourceFallback:n.sourceFallback})}function P(t,e,n){let r=[],i=0,s=0,p=x(e.symbol);for(let a of n)D(t,a,e.relativePath,p)?i++:C(t,a,p)?s++:r.push(a);return{realConsumers:r,barrelConsumers:i,importOnlyConsumers:s}}function C(t,e,n){if(!n)return!1;let r=g(e);if(!r)return!1;let i=S.get(t,e,()=>v(t,e,r));return i.importedLeaves.has(n)&&!i.usedLeaves.has(n)}function v(t,e,n){let r=new Set,i=new Set,s=y(t,e);if(!s)return{importedLeaves:r,usedLeaves:i};let p=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),a=(o,f)=>{let c=f||p.has(o.type);(o.type==="identifier"||o.type==="type_identifier"||o.type==="property_identifier"||o.type==="field_identifier")&&(c?r.add(o.text):i.add(o.text));for(let l of o.children)a(l,c)};return a(s.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function D(t,e,n,r){if(!r)return!1;let i=d(t,e);if(!i)return!1;let s=b(t,e);if(s.length===0)return!1;let p=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${p}\\b`),o=i.split(`
2
2
  `),f=0;for(let c=0;c<o.length;c++){if(!a.test(o[c]??""))continue;if(f++,!s.find(m=>m.startLine<=c&&c<=m.endLine))return!1}return f>0}export{I as a,P as b,C as c};
3
- //# sourceMappingURL=chunk-CVRXOP6M.js.map
3
+ //# sourceMappingURL=chunk-WJIS6BNI.js.map
@@ -1,7 +1,7 @@
1
- import{a as D,b as L}from"./chunk-CVRXOP6M.js";import{a as M}from"./chunk-V76FCF5F.js";import{a as C,b as F}from"./chunk-MX6F756F.js";import{a as I}from"./chunk-NO2TPMCQ.js";import{a as b}from"./chunk-6ZFKI5EP.js";import{c as m,d,j as p,v as g}from"./chunk-SOGLYIJ4.js";import{basename as u,extname as f}from"path";function q(t,n){let{scope:e,maxLoc:r=15,limit:o=30,scanLimit:a}=n??{},i=new I(t),s=k(i.fileDependencyGraph(e));return M({candidates:()=>x(i,e,r),orderCandidates:F,scanLimit:a,prepare:l=>({callerFileMap:D(i,l,{semantic:n?.semantic!==!1}),reverseFanIn:s}),evaluate:(l,c)=>h(t,i,l,c),orderResults:(l,c)=>c.callerFanIn-l.callerFanIn||c.loc-l.loc,limit:o})}function h(t,n,e,r){let o=S(t,n,e,r.callerFileMap);if(o.length!==1)return null;let a=o[0],i=y(t,e.symbolId,a);if(!i)return null;let s=v(n,t,a,e.symbol,i);if(s&&p(s.symbol))return null;let{fanIn:l,source:c}=P(r.callerFileMap,r.reverseFanIn,a,s);return(c==="function"?l<=3:l<=5)?null:{symbol:e.symbol,shortName:m(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:C(e),singleCaller:s?.symbol??"",singleCallerShort:s?.isFunctionLike?m(s.symbol):u(a),callerFanIn:l}}function x(t,n,e){return t.productionCallableDefinitions({scope:n,minLoc:2,maxLoc:e,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0})}function S(t,n,e,r){let o=u(e.relativePath,f(e.relativePath)),a=[...r.get(e.symbolId)??[]].filter(i=>i!==e.relativePath).filter(i=>u(i,f(i))!==o).filter(i=>{let s=n.fileKind(i);return s!=="barrel"&&s!=="entry"&&s!=="test"});return L(t,e,a).realConsumers}function y(t,n,e){return t.get(`SELECT c.start_line, c.end_line
1
+ import{a as D,b as L}from"./chunk-WJIS6BNI.js";import{a as M}from"./chunk-V76FCF5F.js";import{a as C,b as F}from"./chunk-MX6F756F.js";import{a as I}from"./chunk-IW7ASGVF.js";import{a as b}from"./chunk-VGBSY6N7.js";import{c as m,d,j as p,v as g}from"./chunk-O6KCZPJQ.js";import{basename as u,extname as f}from"path";function q(t,n){let{scope:e,maxLoc:r=15,limit:o=30,scanLimit:a}=n??{},i=new I(t),s=k(i.fileDependencyGraph(e));return M({candidates:()=>x(i,e,r),orderCandidates:F,scanLimit:a,prepare:l=>({callerFileMap:D(i,l,{semantic:n?.semantic!==!1}),reverseFanIn:s}),evaluate:(l,c)=>h(t,i,l,c),orderResults:(l,c)=>c.callerFanIn-l.callerFanIn||c.loc-l.loc,limit:o})}function h(t,n,e,r){let o=S(t,n,e,r.callerFileMap);if(o.length!==1)return null;let a=o[0],i=y(t,e.symbolId,a);if(!i)return null;let s=v(n,t,a,e.symbol,i);if(s&&p(s.symbol))return null;let{fanIn:l,source:c}=P(r.callerFileMap,r.reverseFanIn,a,s);return(c==="function"?l<=3:l<=5)?null:{symbol:e.symbol,shortName:m(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:C(e),singleCaller:s?.symbol??"",singleCallerShort:s?.isFunctionLike?m(s.symbol):u(a),callerFanIn:l}}function x(t,n,e){return t.productionCallableDefinitions({scope:n,minLoc:2,maxLoc:e,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0})}function S(t,n,e,r){let o=u(e.relativePath,f(e.relativePath)),a=[...r.get(e.symbolId)??[]].filter(i=>i!==e.relativePath).filter(i=>u(i,f(i))!==o).filter(i=>{let s=n.fileKind(i);return s!=="barrel"&&s!=="entry"&&s!=="test"});return L(t,e,a).realConsumers}function y(t,n,e){return t.get(`SELECT c.start_line, c.end_line
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents d ON c.document_id = d.id
5
5
  WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
6
6
  LIMIT 1`,n,e)}function v(t,n,e,r,o){let a=t.definitionsForFile(e),i=_(n,e,r,o.start_line,o.end_line);return g(a,i)}function P(t,n,e,r){if(r?.isFunctionLike){let o=[...t.get(r.symbolId)??[]].filter(a=>a!==r.relativePath);if(o.length>0)return{fanIn:o.length,source:"function"}}return{fanIn:N(n,e),source:"file"}}function _(t,n,e,r,o){let a=d(e);if(!a)return r;let i=b(t,n).get(a);if(!i||i.length===0)return r;for(let s of i)if(s>=r&&s<=o)return s;return r}function k(t){let n=new Map;for(let[e,r]of t){n.has(e)||n.set(e,n.get(e)??0);for(let o of r)n.set(o,(n.get(o)??0)+1)}return n}function N(t,n){let e=t.get(n)??0;if(e>0)return e;let r=u(n,f(n)),o=0;for(let[a,i]of t)a!==n&&u(a,f(a))===r&&i>o&&(o=i);return o}export{q as a};
7
- //# sourceMappingURL=chunk-SLX5XBCD.js.map
7
+ //# sourceMappingURL=chunk-WN5Z3UVT.js.map
@@ -1,2 +1,2 @@
1
- import{a as f,c as y}from"./chunk-MX6F756F.js";import{f as L}from"./chunk-64UY7VTR.js";import{x as d}from"./chunk-WEJYUS5O.js";import{c as b,o as h,p as S,s as x}from"./chunk-SOGLYIJ4.js";import{a as g}from"./chunk-WQFOZIID.js";function F(n,e={}){let{scope:s,minLoc:t=1,limit:i,scanLimit:a}=e,o=e.semantic!==!1,l=M(n,$(n,{scope:s,minLoc:t,scanLimit:a}),{semantic:o}),r=I(l);return i?r.slice(0,i):r}function $(n,e){let s=x(n,{scope:e.scope}).filter(t=>t.isFunctionLike&&!n.isIgnored(t.relativePath)).filter(t=>f(t)>=e.minLoc);return typeof e.scanLimit=="number"&&e.scanLimit>0&&s.sort((t,i)=>f(i)-f(t)||t.relativePath.localeCompare(i.relativePath)),y(s,e.scanLimit)}function M(n,e,s){let t=new Map;for(let i of e){let a=w(n,i,s);if(!a)continue;let o=t.get(a)??[];o.push(v(i)),t.set(a,o)}return t}function v(n){return{symbol:n.symbol,shortName:b(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:f(n)}}function I(n){let e=[];for(let[s,t]of n)t.length>=2&&e.push({signature:s,functions:t});return e.sort((s,t)=>{let i=t.functions.length-s.functions.length;if(i!==0)return i;let a=s.functions.reduce((l,r)=>l+r.loc,0);return t.functions.reduce((l,r)=>l+r.loc,0)-a}),e}function w(n,e,s){if(s.semantic){let a=L(n,e);if(a)return a}let t=G(e.documentation),i=t?A(t):null;return i||R(P(n,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)}function G(n){return h(S(n))}function P(n,e,s,t,i){let a=g(n,e);if(!a)return null;let o=a.split(/\r?\n/),l=E(o,s,t,i);for(let r of l){let p=Math.min(o.length-1,Math.max(r,r+4)),u="";for(let c=r;c<=p;c+=1){let m=o[c]?.trim();if(m&&(u=u?`${u} ${m}`:m,z(u)))return u}if(u&&u.includes("("))return u}return null}function z(n){let e=n.replace(/\s+/g," ").trim();return!e.includes("(")||d(e)>0?!1:/[;{]$/.test(e)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(e)||/\)\s*As\s+.+$/i.test(e)}function A(n){if(!n||!n.trim())return null;let e=n.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),s=e.indexOf("(");return s===-1||(e=e.slice(s),e=e.replace(/\s+/g,"").toLowerCase(),e.length<3)?null:e}function R(n,e){if(!n||!n.trim())return null;let s=n.replace(/\s+/g," ").trim(),t=s.indexOf("(");if(t===-1)return null;let i=s.slice(0,t),o=new RegExp(`\\b${D(e)}\\b`,"i").exec(i);o&&typeof o.index=="number"&&(i=i.slice(0,o.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 l=C(s.slice(t)).replace(/\)\s*=\s*[\s\S]*$/,")").replace(/\s+throws\s+[^={]+$/i,"").replace(/\s+where\s+.+$/i,"").replace(/\s+/g," ").trim();if(!l.startsWith("("))return null;let r=`${i?`${i} `:""}${l}`.replace(/\s+/g,"").toLowerCase();return r.length>=3?r:null}function C(n){let e=0,s=0,t=0,i=0,a=null,o=!1;for(let l=0;l<n.length;l+=1){let r=n[l];if(a){if(o){o=!1;continue}if(r==="\\"){o=!0;continue}r===a&&(a=null);continue}if(r==='"'||r==="'"||r==="`"){a=r;continue}if(r==="(")e+=1;else if(r===")")e=Math.max(0,e-1);else if(r==="[")t+=1;else if(r==="]")t=Math.max(0,t-1);else if(r==="<")i+=1;else if(r===">")i=Math.max(0,i-1);else if(r==="{"){if(e===0&&t===0&&i===0)return n.slice(0,l);s+=1}else if(r==="}")s=Math.max(0,s-1);else if(r==="="&&n[l+1]===">"&&e===0&&s===0&&t===0&&i===0)return n.slice(0,l)}return n}function E(n,e,s,t){let i=D(t),a=new RegExp(`\\b${i}\\b\\s*\\(`,"i"),o=new RegExp(`\\bdef\\s+${i}\\b`,"i"),l=[],r=new Set,p=Math.max(0,Math.min(e,n.length-1)),u=Math.max(p,Math.min(n.length-1,Math.max(s,e+4)));for(let c=p;c<=u;c+=1){let m=n[c]??"";(a.test(m)||o.test(m))&&!r.has(c)&&(r.add(c),l.push(c))}for(let c=0;c<n.length;c+=1){let m=n[c]??"";(a.test(m)||o.test(m))&&!r.has(c)&&(r.add(c),l.push(c))}return l}function D(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{F as a};
2
- //# sourceMappingURL=chunk-6G76D2YM.js.map
1
+ import{a as f,c as y}from"./chunk-MX6F756F.js";import{g as L}from"./chunk-ZF6P2NAT.js";import{x as d}from"./chunk-WEJYUS5O.js";import{c as b,o as h,p as S,s as x}from"./chunk-O6KCZPJQ.js";import{a as g}from"./chunk-OH5HIAID.js";function F(n,e={}){let{scope:s,minLoc:t=1,limit:i,scanLimit:a}=e,o=e.semantic!==!1,l=M(n,$(n,{scope:s,minLoc:t,scanLimit:a}),{semantic:o}),r=I(l);return i?r.slice(0,i):r}function $(n,e){let s=x(n,{scope:e.scope}).filter(t=>t.isFunctionLike&&!n.isIgnored(t.relativePath)).filter(t=>f(t)>=e.minLoc);return typeof e.scanLimit=="number"&&e.scanLimit>0&&s.sort((t,i)=>f(i)-f(t)||t.relativePath.localeCompare(i.relativePath)),y(s,e.scanLimit)}function M(n,e,s){let t=new Map;for(let i of e){let a=w(n,i,s);if(!a)continue;let o=t.get(a)??[];o.push(v(i)),t.set(a,o)}return t}function v(n){return{symbol:n.symbol,shortName:b(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:f(n)}}function I(n){let e=[];for(let[s,t]of n)t.length>=2&&e.push({signature:s,functions:t});return e.sort((s,t)=>{let i=t.functions.length-s.functions.length;if(i!==0)return i;let a=s.functions.reduce((l,r)=>l+r.loc,0);return t.functions.reduce((l,r)=>l+r.loc,0)-a}),e}function w(n,e,s){if(s.semantic){let a=L(n,e);if(a)return a}let t=G(e.documentation),i=t?A(t):null;return i||R(P(n,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)}function G(n){return h(S(n))}function P(n,e,s,t,i){let a=g(n,e);if(!a)return null;let o=a.split(/\r?\n/),l=E(o,s,t,i);for(let r of l){let p=Math.min(o.length-1,Math.max(r,r+4)),u="";for(let c=r;c<=p;c+=1){let m=o[c]?.trim();if(m&&(u=u?`${u} ${m}`:m,z(u)))return u}if(u&&u.includes("("))return u}return null}function z(n){let e=n.replace(/\s+/g," ").trim();return!e.includes("(")||d(e)>0?!1:/[;{]$/.test(e)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(e)||/\)\s*As\s+.+$/i.test(e)}function A(n){if(!n||!n.trim())return null;let e=n.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),s=e.indexOf("(");return s===-1||(e=e.slice(s),e=e.replace(/\s+/g,"").toLowerCase(),e.length<3)?null:e}function R(n,e){if(!n||!n.trim())return null;let s=n.replace(/\s+/g," ").trim(),t=s.indexOf("(");if(t===-1)return null;let i=s.slice(0,t),o=new RegExp(`\\b${D(e)}\\b`,"i").exec(i);o&&typeof o.index=="number"&&(i=i.slice(0,o.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 l=C(s.slice(t)).replace(/\)\s*=\s*[\s\S]*$/,")").replace(/\s+throws\s+[^={]+$/i,"").replace(/\s+where\s+.+$/i,"").replace(/\s+/g," ").trim();if(!l.startsWith("("))return null;let r=`${i?`${i} `:""}${l}`.replace(/\s+/g,"").toLowerCase();return r.length>=3?r:null}function C(n){let e=0,s=0,t=0,i=0,a=null,o=!1;for(let l=0;l<n.length;l+=1){let r=n[l];if(a){if(o){o=!1;continue}if(r==="\\"){o=!0;continue}r===a&&(a=null);continue}if(r==='"'||r==="'"||r==="`"){a=r;continue}if(r==="(")e+=1;else if(r===")")e=Math.max(0,e-1);else if(r==="[")t+=1;else if(r==="]")t=Math.max(0,t-1);else if(r==="<")i+=1;else if(r===">")i=Math.max(0,i-1);else if(r==="{"){if(e===0&&t===0&&i===0)return n.slice(0,l);s+=1}else if(r==="}")s=Math.max(0,s-1);else if(r==="="&&n[l+1]===">"&&e===0&&s===0&&t===0&&i===0)return n.slice(0,l)}return n}function E(n,e,s,t){let i=D(t),a=new RegExp(`\\b${i}\\b\\s*\\(`,"i"),o=new RegExp(`\\bdef\\s+${i}\\b`,"i"),l=[],r=new Set,p=Math.max(0,Math.min(e,n.length-1)),u=Math.max(p,Math.min(n.length-1,Math.max(s,e+4)));for(let c=p;c<=u;c+=1){let m=n[c]??"";(a.test(m)||o.test(m))&&!r.has(c)&&(r.add(c),l.push(c))}for(let c=0;c<n.length;c+=1){let m=n[c]??"";(a.test(m)||o.test(m))&&!r.has(c)&&(r.add(c),l.push(c))}return l}function D(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{F as a};
2
+ //# sourceMappingURL=chunk-XCW7DYHM.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-NO2TPMCQ.js";import{a as i}from"./chunk-7I6KNKE3.js";import{c as s,e as o,k as m}from"./chunk-SOGLYIJ4.js";function L(t,l){let r=i(t,l);return r?new a(t).definitionsForFile(r.relativePath).filter(e=>e.symbol!==r.symbol).filter(e=>m(r.symbol,e.symbol)).sort((e,n)=>e.startLine-n.startLine||e.endLine-n.endLine).map(e=>({symbol:e.symbol,shortName:s(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:o(e.symbol)??"unknown"})):[]}export{L as a};
2
- //# sourceMappingURL=chunk-6HP3BKIP.js.map
1
+ import{a}from"./chunk-IW7ASGVF.js";import{a as i}from"./chunk-4MHT7LKP.js";import{c as s,e as o,k as m}from"./chunk-O6KCZPJQ.js";function L(t,l){let r=i(t,l);return r?new a(t).definitionsForFile(r.relativePath).filter(e=>e.symbol!==r.symbol).filter(e=>m(r.symbol,e.symbol)).sort((e,n)=>e.startLine-n.startLine||e.endLine-n.endLine).map(e=>({symbol:e.symbol,shortName:s(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:o(e.symbol)??"unknown"})):[]}export{L as a};
2
+ //# sourceMappingURL=chunk-Y5H7TBVE.js.map
@@ -1,2 +1,2 @@
1
- import{a as g}from"./chunk-PCMVXWDC.js";import{a as u}from"./chunk-7I6KNKE3.js";import{c as i}from"./chunk-SOGLYIJ4.js";function w(r,b,y,f={}){let s=u(r,b),n=u(r,y);if(!s||!n)return null;let c=new Set(g(r,s,{semantic:f.semantic}).map(e=>e.symbol)),m=new Set(g(r,n,{semantic:f.semantic}).map(e=>e.symbol)),l=[];for(let e of c)m.has(e)&&l.push(e);let o=[];for(let e of c)m.has(e)||o.push(e);let a=[];for(let e of m)c.has(e)||a.push(e);let h=new Set([...c,...m]),d=h.size>0?l.length/h.size:0,t;h.size===0?t="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":l.length===0?t="These functions do not share any callees. They are not a callee-based consolidation candidate.":o.length===0&&a.length===0?t="These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.":o.length===0?t="A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.":a.length===0?t="B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.":o.length<=2&&a.length<=2?t=`Create a shared function with the ${l.length} common callees. Pass the ${o.length+a.length} divergent callees as parameters or strategy callbacks.`:t=`Extract the ${l.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${o.length} callees in A, ${a.length} in B).`;let p=s.endLine-s.startLine+1,A=n.endLine-n.startLine+1;return{symbolA:{symbol:s.symbol,shortName:i(s.symbol),file:s.relativePath,loc:p},symbolB:{symbol:n.symbol,shortName:i(n.symbol),file:n.relativePath,loc:A},similarity:d,sharedCallees:l.map(i),uniqueToA:o.map(i),uniqueToB:a.map(i),consolidationStrategy:t}}export{w as a};
2
- //# sourceMappingURL=chunk-I7OTKWNY.js.map
1
+ import{a as g}from"./chunk-5QJIEYFB.js";import{a as u}from"./chunk-4MHT7LKP.js";import{c as i}from"./chunk-O6KCZPJQ.js";function w(r,b,y,f={}){let s=u(r,b),n=u(r,y);if(!s||!n)return null;let c=new Set(g(r,s,{semantic:f.semantic}).map(e=>e.symbol)),m=new Set(g(r,n,{semantic:f.semantic}).map(e=>e.symbol)),l=[];for(let e of c)m.has(e)&&l.push(e);let o=[];for(let e of c)m.has(e)||o.push(e);let a=[];for(let e of m)c.has(e)||a.push(e);let h=new Set([...c,...m]),d=h.size>0?l.length/h.size:0,t;h.size===0?t="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":l.length===0?t="These functions do not share any callees. They are not a callee-based consolidation candidate.":o.length===0&&a.length===0?t="These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.":o.length===0?t="A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.":a.length===0?t="B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.":o.length<=2&&a.length<=2?t=`Create a shared function with the ${l.length} common callees. Pass the ${o.length+a.length} divergent callees as parameters or strategy callbacks.`:t=`Extract the ${l.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${o.length} callees in A, ${a.length} in B).`;let p=s.endLine-s.startLine+1,A=n.endLine-n.startLine+1;return{symbolA:{symbol:s.symbol,shortName:i(s.symbol),file:s.relativePath,loc:p},symbolB:{symbol:n.symbol,shortName:i(n.symbol),file:n.relativePath,loc:A},similarity:d,sharedCallees:l.map(i),uniqueToA:o.map(i),uniqueToB:a.map(i),consolidationStrategy:t}}export{w as a};
2
+ //# sourceMappingURL=chunk-YWZBKYLS.js.map
@@ -1,4 +1,4 @@
1
- import{l as T}from"./chunk-WEJYUS5O.js";import{d as N,r as k}from"./chunk-SOGLYIJ4.js";import{a as x}from"./chunk-NN3O7TPH.js";import{a as _}from"./chunk-VDZL45XI.js";function p(i,e,t){if(i.has(e))return i.get(e);let n=t();return i.set(e,n),n}import U from"path";function se(i,e){return i.getReferences().map(t=>{let n=t.getNode();return B(n,e)})}function ae(i){let e=i;return typeof e.findReferences=="function"?e.findReferences():[]}function W(i,e,t,n){let r=[];for(let o of ae(i))for(let s of se(o,n))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||r.push(s);for(let o of t)r.push(o);return E(r)}function $(i,e,t,n){let r=[],o=t?.getStart();for(let s of i.getReferences()){let a=s.getNode();y(n,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||r.push({location:B(a,n),node:a}))}return r}function B(i,e){let t=i.getSourceFile(),n=t.getLineAndColumnAtPos(i.getStart());return{file:y(e,t.getFilePath())??t.getBaseName(),line:n.line-1,column:n.column-1}}function H(i,e,t){let n=i.getSourceFile(),r=g(n,i),o=i.getText(),s=new RegExp(`\\b${ce(o)}\\b`,"g"),a=n.getFullText().split(`
1
+ import{l as T}from"./chunk-WEJYUS5O.js";import{d as N,r as k}from"./chunk-O6KCZPJQ.js";import{a as x}from"./chunk-NN3O7TPH.js";import{a as _}from"./chunk-VDZL45XI.js";function p(i,e,t){if(i.has(e))return i.get(e);let n=t();return i.set(e,n),n}import U from"path";function se(i,e){return i.getReferences().map(t=>{let n=t.getNode();return B(n,e)})}function ae(i){let e=i;return typeof e.findReferences=="function"?e.findReferences():[]}function W(i,e,t,n){let r=[];for(let o of ae(i))for(let s of se(o,n))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||r.push(s);for(let o of t)r.push(o);return E(r)}function $(i,e,t,n){let r=[],o=t?.getStart();for(let s of i.getReferences()){let a=s.getNode();y(n,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||r.push({location:B(a,n),node:a}))}return r}function B(i,e){let t=i.getSourceFile(),n=t.getLineAndColumnAtPos(i.getStart());return{file:y(e,t.getFilePath())??t.getBaseName(),line:n.line-1,column:n.column-1}}function H(i,e,t){let n=i.getSourceFile(),r=g(n,i),o=i.getText(),s=new RegExp(`\\b${ce(o)}\\b`,"g"),a=n.getFullText().split(`
2
2
  `),l=[];for(let c=0;c<a.length;c++){if(c===r)continue;let f=a[c]??"";s.lastIndex=0;let u;for(;(u=s.exec(f))!==null;)l.push({file:e,line:c,column:u.index})}return E(l.filter(c=>y(t,U.join(t,c.file))===e))}function P(i){for(let e=i;e;e=e.getParent()){let t=e.getKindName();if(t.includes("Type")||t==="InterfaceDeclaration"||t==="TypeAliasDeclaration")return!0;if(t==="CallExpression"||t==="NewExpression"||t==="ExpressionStatement")return!1}return!1}function g(i,e){return i.getLineAndColumnAtPos(e.getStart()).line-1}function E(i){let e=new Set,t=[];for(let n of i){let r=`${n.file}:${n.line}:${n.column}`;e.has(r)||(e.add(r),t.push(n))}return t}function y(i,e){let t=U.relative(i||process.cwd(),e).replace(/\\/g,"/");return!t||t.startsWith("..")?null:t}function ce(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(i,e,t,n){let r=le(e,n);return r.size===0?new Map:de(i,t,r)}function le(i,e){let t=new Map;for(let n of k(i,e)){let r=N(n.symbol)??n.leaf;if(!r)continue;let o=t.get(r);o||(o=[],t.set(r,o)),o.push(n)}return t}function de(i,e,t){let n=new Map,r=new Map;return e.forEachDescendant(o=>{for(let s of pe(i,o)){let a=t.get(s);if(!a)continue;let l=g(e,o);for(let c of a){if(l<c.startLine-1||l>c.endLine+1)continue;let f=Math.abs(l-c.startLine),u=r.get(c.symbolId);u!==void 0&&u<=f||(r.set(c.symbolId,f),n.set(c.symbolId,o))}}}),n}function pe(i,e){let t=[],n=r=>{r&&!t.includes(r)&&t.push(r)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let r=e.getNameNode();n(r?.getText())}if("getName"in e&&typeof e.getName=="function"){let r=e.getName();n(r)}return i.Node.isIdentifier(e)&&n(e.getText()),t}function V(i,e,t,n){return i.all(`SELECT
3
3
  gs.id AS symbolId,
4
4
  gs.symbol,
@@ -59,5 +59,5 @@ import{l as T}from"./chunk-WEJYUS5O.js";import{d as N,r as k}from"./chunk-SOGLYI
59
59
  WHERE d.relative_path = ?
60
60
  AND m.role = 1
61
61
  GROUP BY gs.id, gs.symbol, d.id, d.relative_path, gs.display_name, gs.kind, gs.documentation, gs.enclosing_symbol
62
- ORDER BY startLine, endLine`,e,e),n=new Set,r=new Map;for(let o of t){if(n.has(o.symbolId))continue;n.add(o.symbolId);let s=o.leaf||N(o.symbol);!s||r.has(s)||r.set(s,{...o,leaf:s})}return r}import fe from"path";var S=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function D(i){let e=i.toLowerCase();return S.some(t=>e.endsWith(t))}function z(i,e){let t=new Map,n=r=>D(r)?p(t,r,()=>{let o=fe.join(i.config.projectRoot,r);for(let{project:s}of e){let a=s.getSourceFile(o)??s.addSourceFileAtPathIfExists(o)??null;if(a)return{project:s,sourceFile:a}}return null}):null;return{sourceFile:r=>n(r)?.sourceFile??null,sourceFileMatch:n,indexedTypeScriptLikeDocuments:()=>x(i,{extensions:S})}}import m from"path";import{existsSync as M,readdirSync as ue,readFileSync as Y}from"fs";function X(i){let e=m.join(i,"package.json");if(!M(e))return[];let t;try{t=JSON.parse(Y(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(r=>me(i,r)).flatMap(r=>ge(i,r))}function me(i,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=m.join(i,e);return M(m.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),r=e.slice(t+1).replace(/^\//,""),o=m.join(i,n||".");if(!M(o))return[];try{return ue(o).map(s=>m.join(o,s,r)).filter(s=>M(m.join(s,"package.json")))}catch{return[]}}function ge(i,e){try{let t=JSON.parse(Y(m.join(e,"package.json"),"utf8"));if(!t.name)return[];let n=m.relative(i,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:n,sourceRootRelative:`${n}/src`}]}catch{return[]}}function q(i,e){for(let t of i)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function G(i){return[`${i.sourceRootRelative}/index.ts`,`${i.sourceRootRelative}/index.tsx`,`${i.sourceRootRelative}/index.mts`,`${i.sourceRootRelative}/index.cts`]}import{existsSync as h,readFileSync as ye,readdirSync as Se,statSync as he}from"fs";import d from"path";var R=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function C(i,e){let n=e?d.dirname(d.join(i,e)):i,r=d.resolve(i);for(;n.startsWith(r);){for(let s of R){let a=d.join(n,s);if(h(a))return a}let o=d.dirname(n);if(o===n)break;n=o}for(let o of R){let s=d.join(i,o);if(h(s))return s}return null}function Q(i){let e=i.config.projectRoot,t=new Set(Ie(e,i.config.semantic?.typescript?.tsconfigs)),n=x(i,{includeIgnored:!1,extensions:S});for(let r of n){let o=C(e,r);o&&t.add(d.resolve(o))}if(t.size===0){let r=C(e);r&&t.add(d.resolve(r))}return[...t].filter(r=>!Z(e,r)).sort((r,o)=>r.localeCompare(o))}function Ie(i,e=[]){let t=new Set;for(let n of e){let r=d.isAbsolute(n)?n:d.join(i,n);h(r)&&t.add(d.resolve(r))}for(let n of be(i))for(let r of R){let o=d.join(n,r);h(o)&&t.add(d.resolve(o))}if(t.size===0){let n=C(i);n&&t.add(d.resolve(n))}return[...t].filter(n=>!Z(i,n)).sort((n,r)=>n.localeCompare(r))}function be(i){let e=d.join(i,"package.json");if(!h(e))return[];let t;try{t=JSON.parse(ye(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(r=>xe(i,r))}function xe(i,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=d.join(i,e);return L(s)?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),r=e.slice(t+1).replace(/^\//,""),o=d.join(i,n||".");return L(o)?Se(o).map(s=>d.join(o,s,r)).filter(L):[]}function L(i){try{return he(i).isDirectory()}catch{return!1}}function Z(i,e){let t=d.relative(i,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}import{createRequire as Ne}from"module";var ke=Ne(import.meta.url),I;function ee(){if(I!==void 0)return I;try{I=ke("ts-morph")}catch{I=null}return I}function te(i,e){return e.map(t=>({tsconfigPath:t,project:new i.Project({tsConfigFilePath:t,skipFileDependencyResolution:!1})}))}function F(i,e,t){return{language:"typescript",availability:()=>({available:!1,reason:i,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function re(i,e){let t=ee();if(!t)return F("ts-morph is not installed");let n=Q(i);if(n.length===0)return F("no tsconfig found");try{let r=te(t,n);return new A(i,t,r)}catch(r){return F(r instanceof Error?r.message:String(r),n[0],n)}}var A=class{constructor(e,t,n){this.db=e;this.tsMorph=t;this.projects=n;this.workspacePackages=X(e.config.projectRoot),this.sourceFiles=z(e,n)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return p(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let n=[];for(let r of t.getImportDeclarations())for(let o of this.importUsageForDeclaration(e,r))n.push(o);return n})}referencesFor(e){return p(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),n=this.packageImportReferencesForDefinition(e);return t?W(t,e,n,this.db.config.projectRoot):n})}calleesFor(e){return p(this.calleesCache,e.symbolId,()=>p(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}signatureFor(e){return p(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let n=t.getType().getCallSignatures()[0];if(!n)return null;let r=n.getParameters().map(s=>{let a=s.getDeclarations()[0],l=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return ie(l)}),o=n.getReturnType().getText(t);return`(${r.join(",")})=>${ie(o)}`})}importUsageForDeclaration(e,t){let n=T(this.db,e,t.getModuleSpecifierValue()),r=ne(t);return t.getImportClause()?.isTypeOnly()?r.map(o=>Ee(e,n,o)):r.map(o=>this.valueImportUsageForEntry(e,n,o))}valueImportUsageForEntry(e,t,n){let r=n.identifier?n.identifier.findReferences():[],o=[];for(let c of r)for(let f of $(c,e,n.identifier,this.db.config.projectRoot))o.push(f);let s=o.some(c=>!P(c.node)),a=o.some(c=>P(c.node)),l=n.isTypeOnly;return{importer:e,sourcePath:t,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:l,isUsed:l||o.length>0,isTypeUsed:l||a,isValueUsed:s,references:o.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let n of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,n);for(let[n,r]of e)e.set(n,E(r));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,n){if(this.db.isIgnored(n))return;let r=this.sourceFiles.sourceFileMatch(n);if(r)for(let o of r.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,n,o)}addPackageImportReferencesForDeclaration(e,t,n,r){let o=q(this.workspacePackages,r.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of ne(r)){if(a.kind!=="named"||!a.identifier)continue;let l=s.get(a.importedName);if(!l||l.size===0)continue;let c=H(a.identifier,n,this.db.config.projectRoot);c.length>0&&Fe(e,l,c)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let n=new Map;for(let r of G(t))this.collectPackageExports(t,r,n,new Set);n.size>0&&e.set(t.name,n)}return this.packageExportIndex=e,e}collectPackageExports(e,t,n,r){if(r.has(t))return;r.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),l=a?T(this.db,t,a):t;if(!l||!l.startsWith(`${e.sourceRootRelative}/`))continue;let c=s.getNamedExports();if(c.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,l,n,r);continue}for(let f of c){let u=f.getNameNode().getText(),w=f.getAliasNode()?.getText()??u,O=this.indexedDefinitionByLeaf(l,u);if(!O)continue;let b=n.get(w);b||(b=new Set,n.set(w,b)),b.add(O.symbolId)}}}indexedDefinitionByLeaf(e,t){return p(this.indexedDefinitionLeafCache,e,()=>K(this.db,e)).get(t)??null}nodeForDefinition(e){return p(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return p(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?J(this.tsMorph,this.db,t,e):new Map})}definitionFromSymbol(e){let t=e.getDeclarations();for(let n of t){let r=n.getSourceFile(),o=y(this.db.config.projectRoot,r.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=g(r,n),a=V(this.db,o,s,e.getName());if(a)return{symbol:a.symbol,file:a.relativePath,line:a.startLine}}return null}calleeMapForFile(e){let t=this.sourceFiles.sourceFile(e);if(!t)return new Map;let n=k(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(n.length===0)return new Map;let r=new Map;t.forEachDescendant(o=>{if(!this.tsMorph.Node.isCallExpression(o)&&!this.tsMorph.Node.isNewExpression(o))return;let s=this.semanticCalleeForCallNode(t,n,o);s&&De(r,s.callerId,s.target)});for(let[o,s]of r)r.set(o,ve(s));return r}semanticCalleeForCallNode(e,t,n){let r=Me(t,g(e,n));if(!r)return null;let o=n.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:r.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function ne(i){let e=[],t=i.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:i.getImportClause()?.isTypeOnly()??!1});let n=i.getNamespaceImport();n&&e.push({identifier:n,importedName:"*",localName:n.getText(),kind:"namespace",isTypeOnly:i.getImportClause()?.isTypeOnly()??!1});for(let r of i.getNamedImports()){let o=r.getNameNode(),a=r.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:r.isTypeOnly()||(i.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Ee(i,e,t){return{importer:i,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function De(i,e,t){let n=i.get(e);n||(n=[],i.set(e,n)),n.push(t)}function Me(i,e){let t=null;for(let n of i)e<n.startLine||e>n.endLine||(!t||n.startLine>=t.startLine)&&(t=n);return t}function Fe(i,e,t){for(let n of e){let r=i.get(n)??[];r.push(...t),i.set(n,r)}}function ve(i){let e=new Set,t=[];for(let n of i){let r=`${n.symbol}|${n.file}|${n.line}`;e.has(r)||(e.add(r),t.push(n))}return t}function ie(i){return i.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}var j=new WeakMap;_({name:"semantic-provider",groups:["semantic-provider"],clearAll:i=>j.delete(i)});function oe(i,e){let t=`${i.config.projectRoot}:typescript-workspace`,n=j.get(i);n||(n=new Map,j.set(i,n));let r=n.get(t);if(r)return r;let o=re(i,e);return n.set(t,o),o}function St(i,e){let t=v(i,e);return t?t.importUsage(e):[]}function Te(i,e){let t=v(i,e.relativePath);return t?t.referencesFor(e):[]}function ht(i,e){let t=new Map;for(let n of e)for(let r of Te(i,n)){if(r.file===n.relativePath||i.isIgnored(r.file))continue;let o=t.get(n.symbolId);o||(o=new Set,t.set(n.symbolId,o)),o.add(r.file)}return t}function It(i,e){let t=new Map;for(let n of e){let r=v(i,n.relativePath);if(!r)continue;let o=r.calleesFor(n);o.length>0&&t.set(n.symbolId,o)}return t}function bt(i,e){let t=v(i,e.relativePath);return t?t.signatureFor(e):null}function v(i,e){if(!D(e))return null;let t=oe(i,e);return t.availability().available?t:null}export{oe as a,St as b,Te as c,ht as d,It as e,bt as f};
63
- //# sourceMappingURL=chunk-64UY7VTR.js.map
62
+ ORDER BY startLine, endLine`,e,e),n=new Set,r=new Map;for(let o of t){if(n.has(o.symbolId))continue;n.add(o.symbolId);let s=o.leaf||N(o.symbol);!s||r.has(s)||r.set(s,{...o,leaf:s})}return r}import fe from"path";var S=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function D(i){let e=i.toLowerCase();return S.some(t=>e.endsWith(t))}function z(i,e){let t=new Map,n=r=>D(r)?p(t,r,()=>{let o=fe.join(i.config.projectRoot,r);for(let{project:s}of e){let a=s.getSourceFile(o)??s.addSourceFileAtPathIfExists(o)??null;if(a)return{project:s,sourceFile:a}}return null}):null;return{sourceFile:r=>n(r)?.sourceFile??null,sourceFileMatch:n,indexedTypeScriptLikeDocuments:()=>x(i,{extensions:S})}}import m from"path";import{existsSync as M,readdirSync as ue,readFileSync as Y}from"fs";function X(i){let e=m.join(i,"package.json");if(!M(e))return[];let t;try{t=JSON.parse(Y(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(r=>me(i,r)).flatMap(r=>ge(i,r))}function me(i,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=m.join(i,e);return M(m.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),r=e.slice(t+1).replace(/^\//,""),o=m.join(i,n||".");if(!M(o))return[];try{return ue(o).map(s=>m.join(o,s,r)).filter(s=>M(m.join(s,"package.json")))}catch{return[]}}function ge(i,e){try{let t=JSON.parse(Y(m.join(e,"package.json"),"utf8"));if(!t.name)return[];let n=m.relative(i,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:n,sourceRootRelative:`${n}/src`}]}catch{return[]}}function q(i,e){for(let t of i)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function G(i){return[`${i.sourceRootRelative}/index.ts`,`${i.sourceRootRelative}/index.tsx`,`${i.sourceRootRelative}/index.mts`,`${i.sourceRootRelative}/index.cts`]}import{existsSync as h,readFileSync as ye,readdirSync as Se,statSync as he}from"fs";import d from"path";var R=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function C(i,e){let n=e?d.dirname(d.join(i,e)):i,r=d.resolve(i);for(;n.startsWith(r);){for(let s of R){let a=d.join(n,s);if(h(a))return a}let o=d.dirname(n);if(o===n)break;n=o}for(let o of R){let s=d.join(i,o);if(h(s))return s}return null}function Q(i){let e=i.config.projectRoot,t=new Set(Ie(e,i.config.semantic?.typescript?.tsconfigs)),n=x(i,{includeIgnored:!1,extensions:S});for(let r of n){let o=C(e,r);o&&t.add(d.resolve(o))}if(t.size===0){let r=C(e);r&&t.add(d.resolve(r))}return[...t].filter(r=>!Z(e,r)).sort((r,o)=>r.localeCompare(o))}function Ie(i,e=[]){let t=new Set;for(let n of e){let r=d.isAbsolute(n)?n:d.join(i,n);h(r)&&t.add(d.resolve(r))}for(let n of be(i))for(let r of R){let o=d.join(n,r);h(o)&&t.add(d.resolve(o))}if(t.size===0){let n=C(i);n&&t.add(d.resolve(n))}return[...t].filter(n=>!Z(i,n)).sort((n,r)=>n.localeCompare(r))}function be(i){let e=d.join(i,"package.json");if(!h(e))return[];let t;try{t=JSON.parse(ye(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(r=>xe(i,r))}function xe(i,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=d.join(i,e);return L(s)?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),r=e.slice(t+1).replace(/^\//,""),o=d.join(i,n||".");return L(o)?Se(o).map(s=>d.join(o,s,r)).filter(L):[]}function L(i){try{return he(i).isDirectory()}catch{return!1}}function Z(i,e){let t=d.relative(i,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}import{createRequire as Ne}from"module";var ke=Ne(import.meta.url),I;function ee(){if(I!==void 0)return I;try{I=ke("ts-morph")}catch{I=null}return I}function te(i,e){return e.map(t=>({tsconfigPath:t,project:new i.Project({tsConfigFilePath:t,skipFileDependencyResolution:!1})}))}function F(i,e,t){return{language:"typescript",availability:()=>({available:!1,reason:i,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function re(i,e){let t=ee();if(!t)return F("ts-morph is not installed");let n=Q(i);if(n.length===0)return F("no tsconfig found");try{let r=te(t,n);return new A(i,t,r)}catch(r){return F(r instanceof Error?r.message:String(r),n[0],n)}}var A=class{constructor(e,t,n){this.db=e;this.tsMorph=t;this.projects=n;this.workspacePackages=X(e.config.projectRoot),this.sourceFiles=z(e,n)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return p(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let n=[];for(let r of t.getImportDeclarations())for(let o of this.importUsageForDeclaration(e,r))n.push(o);return n})}referencesFor(e){return p(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),n=this.packageImportReferencesForDefinition(e);return t?W(t,e,n,this.db.config.projectRoot):n})}calleesFor(e){return p(this.calleesCache,e.symbolId,()=>p(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}signatureFor(e){return p(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let n=t.getType().getCallSignatures()[0];if(!n)return null;let r=n.getParameters().map(s=>{let a=s.getDeclarations()[0],l=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return ie(l)}),o=n.getReturnType().getText(t);return`(${r.join(",")})=>${ie(o)}`})}importUsageForDeclaration(e,t){let n=T(this.db,e,t.getModuleSpecifierValue()),r=ne(t);return t.getImportClause()?.isTypeOnly()?r.map(o=>Ee(e,n,o)):r.map(o=>this.valueImportUsageForEntry(e,n,o))}valueImportUsageForEntry(e,t,n){let r=n.identifier?n.identifier.findReferences():[],o=[];for(let c of r)for(let f of $(c,e,n.identifier,this.db.config.projectRoot))o.push(f);let s=o.some(c=>!P(c.node)),a=o.some(c=>P(c.node)),l=n.isTypeOnly;return{importer:e,sourcePath:t,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:l,isUsed:l||o.length>0,isTypeUsed:l||a,isValueUsed:s,references:o.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let n of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,n);for(let[n,r]of e)e.set(n,E(r));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,n){if(this.db.isIgnored(n))return;let r=this.sourceFiles.sourceFileMatch(n);if(r)for(let o of r.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,n,o)}addPackageImportReferencesForDeclaration(e,t,n,r){let o=q(this.workspacePackages,r.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of ne(r)){if(a.kind!=="named"||!a.identifier)continue;let l=s.get(a.importedName);if(!l||l.size===0)continue;let c=H(a.identifier,n,this.db.config.projectRoot);c.length>0&&Fe(e,l,c)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let n=new Map;for(let r of G(t))this.collectPackageExports(t,r,n,new Set);n.size>0&&e.set(t.name,n)}return this.packageExportIndex=e,e}collectPackageExports(e,t,n,r){if(r.has(t))return;r.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),l=a?T(this.db,t,a):t;if(!l||!l.startsWith(`${e.sourceRootRelative}/`))continue;let c=s.getNamedExports();if(c.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,l,n,r);continue}for(let f of c){let u=f.getNameNode().getText(),w=f.getAliasNode()?.getText()??u,O=this.indexedDefinitionByLeaf(l,u);if(!O)continue;let b=n.get(w);b||(b=new Set,n.set(w,b)),b.add(O.symbolId)}}}indexedDefinitionByLeaf(e,t){return p(this.indexedDefinitionLeafCache,e,()=>K(this.db,e)).get(t)??null}nodeForDefinition(e){return p(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return p(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?J(this.tsMorph,this.db,t,e):new Map})}definitionFromSymbol(e){let t=e.getDeclarations();for(let n of t){let r=n.getSourceFile(),o=y(this.db.config.projectRoot,r.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=g(r,n),a=V(this.db,o,s,e.getName());if(a)return{symbol:a.symbol,file:a.relativePath,line:a.startLine}}return null}calleeMapForFile(e){let t=this.sourceFiles.sourceFile(e);if(!t)return new Map;let n=k(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(n.length===0)return new Map;let r=new Map;t.forEachDescendant(o=>{if(!this.tsMorph.Node.isCallExpression(o)&&!this.tsMorph.Node.isNewExpression(o))return;let s=this.semanticCalleeForCallNode(t,n,o);s&&De(r,s.callerId,s.target)});for(let[o,s]of r)r.set(o,ve(s));return r}semanticCalleeForCallNode(e,t,n){let r=Me(t,g(e,n));if(!r)return null;let o=n.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:r.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function ne(i){let e=[],t=i.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:i.getImportClause()?.isTypeOnly()??!1});let n=i.getNamespaceImport();n&&e.push({identifier:n,importedName:"*",localName:n.getText(),kind:"namespace",isTypeOnly:i.getImportClause()?.isTypeOnly()??!1});for(let r of i.getNamedImports()){let o=r.getNameNode(),a=r.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:r.isTypeOnly()||(i.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Ee(i,e,t){return{importer:i,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function De(i,e,t){let n=i.get(e);n||(n=[],i.set(e,n)),n.push(t)}function Me(i,e){let t=null;for(let n of i)e<n.startLine||e>n.endLine||(!t||n.startLine>=t.startLine)&&(t=n);return t}function Fe(i,e,t){for(let n of e){let r=i.get(n)??[];r.push(...t),i.set(n,r)}}function ve(i){let e=new Set,t=[];for(let n of i){let r=`${n.symbol}|${n.file}|${n.line}`;e.has(r)||(e.add(r),t.push(n))}return t}function ie(i){return i.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}var j=new WeakMap;_({name:"semantic-provider",groups:["semantic-provider"],clearAll:i=>j.delete(i)});function oe(i,e){let t=`${i.config.projectRoot}:typescript-workspace`,n=j.get(i);n||(n=new Map,j.set(i,n));let r=n.get(t);if(r)return r;let o=re(i,e);return n.set(t,o),o}function St(i,e){let t=v(i,e);return t?t.importUsage(e):[]}function Te(i,e){let t=v(i,e.relativePath);return t?t.referencesFor(e):[]}function ht(i,e){let t=new Map;for(let n of e)for(let r of Te(i,n)){if(r.file===n.relativePath||i.isIgnored(r.file))continue;let o=t.get(n.symbolId);o||(o=new Set,t.set(n.symbolId,o)),o.add(r.file)}return t}function It(i,e){let t=new Map;for(let n of e){let r=v(i,n.relativePath);if(!r)continue;let o=r.calleesFor(n);o.length>0&&t.set(n.symbolId,o)}return t}function bt(i,e){let t=v(i,e.relativePath);return t?t.signatureFor(e):null}function v(i,e){if(!D(e))return null;let t=oe(i,e);return t.availability().available?t:null}export{D as a,oe as b,St as c,Te as d,ht as e,It as f,bt as g};
63
+ //# sourceMappingURL=chunk-ZF6P2NAT.js.map
@@ -1,2 +1,2 @@
1
- import{a as B}from"./chunk-TCCUWKH4.js";import{a as T}from"./chunk-GD7XRHSV.js";import{a as I}from"./chunk-NK7TQQG4.js";import{a as p}from"./chunk-LBAMALDV.js";import{a as H}from"./chunk-JTCEWV7Q.js";import{a as v}from"./chunk-BCFED24F.js";import{a as F,b as G}from"./chunk-AGW2MVIO.js";import{b as A}from"./chunk-I66MQD5U.js";import{b as P}from"./chunk-R3G6ERW7.js";import{a as k}from"./chunk-YSSTUCNS.js";import{a as b}from"./chunk-UUDYI3FF.js";import{a as D}from"./chunk-D43L5PQF.js";import{a as w}from"./chunk-ITUU3VE3.js";function X(t,e,n={}){let o=n.impactDepth??3,r=n.sliceDepth??3,l=n.semantic,s=!z(e),a=s?I(t,e,{semantic:l}):{definitions:[],referencedBy:[]},m=s?D(t,e,{semantic:l}):null,f=s?k(t,e,{semantic:l}):null,h=s?v(t,e,{semantic:l}):null,y=s?p(t,e,{direction:"backward",maxDepth:r,semantic:l}):null,R=s?p(t,e,{direction:"forward",maxDepth:r,semantic:l}):null,d=s?b(t,e,{maxDepth:o,scope:n.scope}):[],i=w(t,e,{semantic:l}),g=F(t,e),x=G(t,e),u=T(t,e),C=B(t,e),c={symbol:a.definitions.length>0||a.referencedBy.length>0||m!==null||f!==null||h!==null||y!==null||R!==null||d.length>0,file:i!==null||g.length>0||x.length>0,module:u.files.length>0||u.symbols.length>0||C.length>0},S=[];!c.symbol&&!c.file&&!c.module&&S.push("No symbol, file, or module matched target.");let O=i?.file??a.definitions[0]?.relativePath??null;return{target:e,matched:c,history:j(t,O),trace:a,callGraph:m,complexity:f,dataflow:h,backwardSlice:y,forwardSlice:R,affected:d,changeSurface:i,deps:g,rdeps:x,system:u,surface:C,warnings:S}}function j(t,e){let n={available:!1,file:e,churn:null,coChangePartners:[],suppressionsInFile:0};if(!e)return n;let o=P(t);if(!o)return n;let r=A(t,e,{limit:5});return{available:!0,file:e,churn:o.get(e)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:r.findings.map(l=>({file:l.fileA===e?l.fileB:l.fileA,together:l.together,confidence:l.confidence})),suppressionsInFile:H(t).byFile.get(e)??0}}function z(t){return t.includes("/")||t.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(t)}export{X as a};
2
- //# sourceMappingURL=chunk-VQGQHIAT.js.map
1
+ import{a as B}from"./chunk-BGRPMGTD.js";import{a as T}from"./chunk-2BMFRBV6.js";import{a as I}from"./chunk-IC3RC3KJ.js";import{a as p}from"./chunk-PRVDXGSK.js";import{a as H}from"./chunk-OXKEUWMJ.js";import{a as v}from"./chunk-QKO474FG.js";import{a as F,b as G}from"./chunk-NC4IUW25.js";import{b as A}from"./chunk-JODYQDE4.js";import{b as P}from"./chunk-R3G6ERW7.js";import{a as k}from"./chunk-ADRYSISR.js";import{a as b}from"./chunk-R6XDPWJA.js";import{a as D}from"./chunk-SCEMECW7.js";import{a as w}from"./chunk-FVIKFWUL.js";function X(t,e,n={}){let o=n.impactDepth??3,r=n.sliceDepth??3,l=n.semantic,s=!z(e),a=s?I(t,e,{semantic:l}):{definitions:[],referencedBy:[]},m=s?D(t,e,{semantic:l}):null,f=s?k(t,e,{semantic:l}):null,h=s?v(t,e,{semantic:l}):null,y=s?p(t,e,{direction:"backward",maxDepth:r,semantic:l}):null,R=s?p(t,e,{direction:"forward",maxDepth:r,semantic:l}):null,d=s?b(t,e,{maxDepth:o,scope:n.scope}):[],i=w(t,e,{semantic:l}),g=F(t,e),x=G(t,e),u=T(t,e),C=B(t,e),c={symbol:a.definitions.length>0||a.referencedBy.length>0||m!==null||f!==null||h!==null||y!==null||R!==null||d.length>0,file:i!==null||g.length>0||x.length>0,module:u.files.length>0||u.symbols.length>0||C.length>0},S=[];!c.symbol&&!c.file&&!c.module&&S.push("No symbol, file, or module matched target.");let O=i?.file??a.definitions[0]?.relativePath??null;return{target:e,matched:c,history:j(t,O),trace:a,callGraph:m,complexity:f,dataflow:h,backwardSlice:y,forwardSlice:R,affected:d,changeSurface:i,deps:g,rdeps:x,system:u,surface:C,warnings:S}}function j(t,e){let n={available:!1,file:e,churn:null,coChangePartners:[],suppressionsInFile:0};if(!e)return n;let o=P(t);if(!o)return n;let r=A(t,e,{limit:5});return{available:!0,file:e,churn:o.get(e)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:r.findings.map(l=>({file:l.fileA===e?l.fileB:l.fileA,together:l.together,confidence:l.confidence})),suppressionsInFile:H(t).byFile.get(e)??0}}function z(t){return t.includes("/")||t.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(t)}export{X as a};
2
+ //# sourceMappingURL=chunk-ZGIK464P.js.map
@@ -1,2 +1,2 @@
1
- import{a as u}from"./chunk-7I6KNKE3.js";import{a as c}from"./chunk-NN3O7TPH.js";import{existsSync as m}from"fs";import{basename as p,isAbsolute as g,join as d}from"path";function S(t,r){let e=f(t,r,{allowMultiple:!1})[0]?.relativePath;return e||x(t,r)}function j(t,r){return f(t,r,{allowMultiple:!0}).map(e=>e.relativePath)}function x(t,r){if(!r)return null;let e=r.replace(/\\/g,"/").replace(/^\.\//,""),s=g(e)&&e.startsWith(t.config.projectRoot)?e.slice(t.config.projectRoot.length).replace(/^\/+/,""):e,i=d(t.config.projectRoot,s);return m(i)?s:null}function f(t,r,e){let s=h(r);if(!s)return[];let i=c(t,{includeIgnored:!1}).map(o=>({relativePath:o,score:v(o,s)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.relativePath.localeCompare(l.relativePath));if(i.length===0){let o=u(t,r);return!o||t.isIgnored(o.relativePath)?[]:[{relativePath:o.relativePath,score:700}]}let n=i.filter(o=>o.score>=1100);if(n.length>0)return e.allowMultiple?n:[n[0]];let a=i.filter(o=>o.score>=800);return a.length>0?e.allowMultiple?a:[a[0]]:e.allowMultiple?i:[i[0]]}function v(t,r){let e=h(t),s=p(e),i=p(r),n=0;return e===r&&(n+=1200),e.endsWith(`/${r}`)&&(n+=1100),s===i&&(n+=900),e.startsWith(`${r}/`)&&(n+=850),e.includes(r)&&(n+=250),n}function h(t){return t.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}export{S as a,j as b};
2
- //# sourceMappingURL=chunk-WC43FMAB.js.map
1
+ import{a as u}from"./chunk-4MHT7LKP.js";import{a as c}from"./chunk-NN3O7TPH.js";import{existsSync as m}from"fs";import{basename as p,isAbsolute as g,join as d}from"path";function S(t,r){let e=f(t,r,{allowMultiple:!1})[0]?.relativePath;return e||x(t,r)}function j(t,r){return f(t,r,{allowMultiple:!0}).map(e=>e.relativePath)}function x(t,r){if(!r)return null;let e=r.replace(/\\/g,"/").replace(/^\.\//,""),s=g(e)&&e.startsWith(t.config.projectRoot)?e.slice(t.config.projectRoot.length).replace(/^\/+/,""):e,i=d(t.config.projectRoot,s);return m(i)?s:null}function f(t,r,e){let s=h(r);if(!s)return[];let i=c(t,{includeIgnored:!1}).map(o=>({relativePath:o,score:v(o,s)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.relativePath.localeCompare(l.relativePath));if(i.length===0){let o=u(t,r);return!o||t.isIgnored(o.relativePath)?[]:[{relativePath:o.relativePath,score:700}]}let n=i.filter(o=>o.score>=1100);if(n.length>0)return e.allowMultiple?n:[n[0]];let a=i.filter(o=>o.score>=800);return a.length>0?e.allowMultiple?a:[a[0]]:e.allowMultiple?i:[i[0]]}function v(t,r){let e=h(t),s=p(e),i=p(r),n=0;return e===r&&(n+=1200),e.endsWith(`/${r}`)&&(n+=1100),s===i&&(n+=900),e.startsWith(`${r}/`)&&(n+=850),e.includes(r)&&(n+=250),n}function h(t){return t.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}export{S as a,j as b};
2
+ //# sourceMappingURL=chunk-ZOT3WUZW.js.map
@@ -1,4 +1,4 @@
1
- import{a as g}from"./chunk-WC43FMAB.js";import{b as u}from"./chunk-64UY7VTR.js";import{a as p}from"./chunk-7I6KNKE3.js";import{b as a}from"./chunk-APLCSDXL.js";import{c as l,d as c,h as f}from"./chunk-SOGLYIJ4.js";import{a as d}from"./chunk-NN3O7TPH.js";function J(e,s,t={}){return I(e,s,t)?.map(r=>({symbol:r.symbol,shortName:r.shortName,fromFile:r.fromFile}))??[]}function P(e,s){let t=N(e,s);return t.length>0?t:E(e,s)}function v(e,s,t={}){return I(e,s,t)?.filter(r=>!r.used).map(r=>({symbol:r.symbol,shortName:r.shortName,importedIn:r.importer}))??[]}function N(e,s){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
1
+ import{a as g}from"./chunk-ZOT3WUZW.js";import{c as u}from"./chunk-ZF6P2NAT.js";import{a as p}from"./chunk-4MHT7LKP.js";import{b as a}from"./chunk-FVVT7GV6.js";import{c as l,d as c,h as f}from"./chunk-O6KCZPJQ.js";import{a as d}from"./chunk-NN3O7TPH.js";function J(e,s,t={}){return I(e,s,t)?.map(r=>({symbol:r.symbol,shortName:r.shortName,fromFile:r.fromFile}))??[]}function P(e,s){let t=N(e,s);return t.length>0?t:E(e,s)}function v(e,s,t={}){return I(e,s,t)?.filter(r=>!r.used).map(r=>({symbol:r.symbol,shortName:r.shortName,importedIn:r.importer}))??[]}function N(e,s){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents d ON c.document_id = d.id
@@ -32,4 +32,4 @@ import{a as g}from"./chunk-WC43FMAB.js";import{b as u}from"./chunk-64UY7VTR.js";
32
32
  WHERE imp_d.relative_path = ?
33
33
  AND m.role = 2
34
34
  ORDER BY def_d.relative_path, gs.symbol`,s).filter(m=>!e.isIgnored(m.importer));if(o.length>0){let m=t.semantic===!1?[]:u(e,s);return o.map(i=>({symbol:i.symbol,shortName:l(i.symbol),fromFile:i.from_file??"(external)",importer:i.importer,used:i.used!==0||m.some(n=>n.isUsed&&n.sourcePath===i.from_file)}))}return null}function F(e,s){let t=u(e,s);return t.length>0?t.map(r=>{let o=h(r.importedName,r.localName,r.kind);return{symbol:o,shortName:o,fromFile:r.sourcePath??"(external)",importer:s,used:r.kind==="side-effect"?!0:r.isUsed}}):null}function O(e,s){return a(e,s).map(t=>{let r=h(t.importedName,t.localName,t.kind),o=t.kind==="side-effect"?!0:t.used;return{symbol:r,shortName:r,fromFile:t.sourcePath??"(external)",importer:s,used:o}})}function h(e,s,t){return t==="namespace"&&e==="*"&&s?`* as ${s}`:t==="default"&&s?`default as ${s}`:t==="side-effect"?"(side effect import)":s&&s!==e?`${e} as ${s}`:e}function b(e){return e.replace(/\\/g,"/")}function R(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{J as a,P as b,v as c};
35
- //# sourceMappingURL=chunk-TFO4OMJZ.js.map
35
+ //# sourceMappingURL=chunk-ZZ2W5P3D.js.map