scip-query 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/README.md +31 -29
  2. package/dist/augment-vue-worker.js +2 -0
  3. package/dist/chunk-2ZGHRI2A.js +5 -0
  4. package/dist/chunk-32R4VYYA.js +2 -0
  5. package/dist/chunk-3UB2DPLP.js +2 -0
  6. package/dist/chunk-4X7C236P.js +84 -0
  7. package/dist/chunk-5LQ6CVX3.js +2 -0
  8. package/dist/chunk-5YYMKE3G.js +70 -0
  9. package/dist/chunk-7LSCW7NF.js +6 -0
  10. package/dist/chunk-7X7FLQC5.js +2 -0
  11. package/dist/chunk-A5UNS4DR.js +4 -0
  12. package/dist/chunk-BNCTPTVX.js +2 -0
  13. package/dist/{chunk-TRBNQ273.js → chunk-C5BFS23M.js} +2 -2
  14. package/dist/{chunk-DM56ECPZ.js → chunk-DRLWW74T.js} +2 -2
  15. package/dist/chunk-EB5IVUNU.js +2 -0
  16. package/dist/{chunk-TPOYTT6O.js → chunk-ERRUE5G4.js} +4 -4
  17. package/dist/chunk-F4KR22Z2.js +2 -0
  18. package/dist/chunk-FG6A6ZUP.js +2 -0
  19. package/dist/chunk-FHSD5RKF.js +19 -0
  20. package/dist/chunk-FVVEIGP3.js +5 -0
  21. package/dist/chunk-GBDZY73J.js +2 -0
  22. package/dist/{chunk-4TYGGOLO.js → chunk-H4DXD2FB.js} +1 -1
  23. package/dist/chunk-HUASU3AD.js +71 -0
  24. package/dist/chunk-IJWIYZO5.js +2 -0
  25. package/dist/chunk-K6H3XJQW.js +7 -0
  26. package/dist/{chunk-KYT47WU2.js → chunk-KAM4C6ZD.js} +1 -1
  27. package/dist/{chunk-56LPZC3S.js → chunk-KTCODJNQ.js} +3 -3
  28. package/dist/chunk-LJ2YWNQF.js +2 -0
  29. package/dist/chunk-LT2CPEQ4.js +2 -0
  30. package/dist/chunk-M5QTG55L.js +2 -0
  31. package/dist/chunk-MKFH7QJG.js +7 -0
  32. package/dist/chunk-MO32JMOD.js +12 -0
  33. package/dist/chunk-MO65UK5V.js +6 -0
  34. package/dist/chunk-MTK3JAJT.js +2 -0
  35. package/dist/{chunk-6TRXTRCW.js → chunk-MXWC53GJ.js} +4 -4
  36. package/dist/{chunk-HLILTI7S.js → chunk-OQZF2DQJ.js} +3 -3
  37. package/dist/chunk-PBFMZKXE.js +6 -0
  38. package/dist/{chunk-MMKNCPHB.js → chunk-PFMGJ4BR.js} +4 -4
  39. package/dist/{chunk-5KWWENJZ.js → chunk-PK4U6NWP.js} +2 -2
  40. package/dist/{chunk-CH47OLNL.js → chunk-Q2ALKKSE.js} +4 -4
  41. package/dist/chunk-QFCK6WV2.js +39 -0
  42. package/dist/chunk-QFZE73XF.js +84 -0
  43. package/dist/chunk-QRYEOK3M.js +2 -0
  44. package/dist/{chunk-LORWXBOO.js → chunk-RKTDEIHF.js} +1 -1
  45. package/dist/chunk-ROWAEEOD.js +2 -0
  46. package/dist/chunk-RT5PV5JQ.js +7 -0
  47. package/dist/chunk-TLRA5TR6.js +2 -0
  48. package/dist/chunk-U5MVUPOO.js +2 -0
  49. package/dist/chunk-URUVLDM7.js +29 -0
  50. package/dist/chunk-WHGCGENP.js +16 -0
  51. package/dist/chunk-WIIZF5FP.js +2 -0
  52. package/dist/chunk-WNMAH3P7.js +2 -0
  53. package/dist/chunk-XV3XUZ3X.js +11 -0
  54. package/dist/chunk-YDKWDTAW.js +2 -0
  55. package/dist/{chunk-IUNRL2AQ.js → chunk-YDNCX5PF.js} +2 -2
  56. package/dist/chunk-YU25IHJX.js +90 -0
  57. package/dist/{chunk-VZE4SOJG.js → chunk-Z5CTXSWT.js} +3 -3
  58. package/dist/chunk-ZFCQQ4B5.js +2 -0
  59. package/dist/chunk-ZHHMG4UC.js +114 -0
  60. package/dist/cli.js +487 -388
  61. package/dist/{db-DKhNQ75l.d.ts → db-BZPa7dzJ.d.ts} +19 -9
  62. package/dist/index.d.ts +221 -13
  63. package/dist/index.js +45 -31
  64. package/dist/postinstall.js +1 -1
  65. package/dist/queries/affected.d.ts +1 -1
  66. package/dist/queries/affected.js +1 -1
  67. package/dist/queries/bottlenecks.d.ts +1 -1
  68. package/dist/queries/bottlenecks.js +1 -1
  69. package/dist/queries/by-kind.d.ts +1 -1
  70. package/dist/queries/by-kind.js +1 -1
  71. package/dist/queries/call-graph.d.ts +1 -1
  72. package/dist/queries/call-graph.js +1 -1
  73. package/dist/queries/change-surface.d.ts +1 -1
  74. package/dist/queries/change-surface.js +1 -1
  75. package/dist/queries/code.d.ts +1 -1
  76. package/dist/queries/code.js +1 -1
  77. package/dist/queries/complexity-hotspots.d.ts +1 -1
  78. package/dist/queries/complexity-hotspots.js +1 -1
  79. package/dist/queries/complexity.d.ts +1 -1
  80. package/dist/queries/complexity.js +1 -1
  81. package/dist/queries/convergence.d.ts +1 -1
  82. package/dist/queries/convergence.js +1 -1
  83. package/dist/queries/coupling.d.ts +1 -1
  84. package/dist/queries/coupling.js +1 -1
  85. package/dist/queries/cycles.d.ts +1 -1
  86. package/dist/queries/cycles.js +1 -1
  87. package/dist/queries/dataflow.d.ts +1 -1
  88. package/dist/queries/dataflow.js +1 -1
  89. package/dist/queries/dead.d.ts +1 -1
  90. package/dist/queries/dead.js +1 -1
  91. package/dist/queries/deep-chains.d.ts +1 -1
  92. package/dist/queries/deep-chains.js +1 -1
  93. package/dist/queries/deps.d.ts +1 -1
  94. package/dist/queries/deps.js +1 -1
  95. package/dist/queries/diff-impact.d.ts +1 -1
  96. package/dist/queries/diff-impact.js +1 -1
  97. package/dist/queries/drift-policy.d.ts +6 -0
  98. package/dist/queries/drift-policy.js +2 -0
  99. package/dist/queries/drift.d.ts +1 -1
  100. package/dist/queries/drift.js +1 -1
  101. package/dist/queries/extract-candidates.d.ts +1 -1
  102. package/dist/queries/extract-candidates.js +1 -1
  103. package/dist/queries/fan.d.ts +1 -1
  104. package/dist/queries/fan.js +1 -1
  105. package/dist/queries/files.d.ts +1 -1
  106. package/dist/queries/files.js +1 -1
  107. package/dist/queries/health.d.ts +1 -1
  108. package/dist/queries/health.js +1 -1
  109. package/dist/queries/hierarchy.d.ts +1 -1
  110. package/dist/queries/hierarchy.js +1 -1
  111. package/dist/queries/hotspots.d.ts +1 -1
  112. package/dist/queries/hotspots.js +1 -1
  113. package/dist/queries/imports.d.ts +1 -1
  114. package/dist/queries/imports.js +1 -1
  115. package/dist/queries/index.d.ts +1 -1
  116. package/dist/queries/index.js +1 -1
  117. package/dist/queries/isolated.d.ts +1 -1
  118. package/dist/queries/isolated.js +1 -1
  119. package/dist/queries/members.d.ts +1 -1
  120. package/dist/queries/members.js +1 -1
  121. package/dist/queries/methods.d.ts +1 -1
  122. package/dist/queries/methods.js +1 -1
  123. package/dist/queries/outline.d.ts +1 -1
  124. package/dist/queries/outline.js +1 -1
  125. package/dist/queries/passthrough-candidates.d.ts +1 -1
  126. package/dist/queries/passthrough-candidates.js +1 -1
  127. package/dist/queries/redundant-reexports.d.ts +1 -1
  128. package/dist/queries/redundant-reexports.js +1 -1
  129. package/dist/queries/refs.d.ts +1 -1
  130. package/dist/queries/refs.js +1 -1
  131. package/dist/queries/similar-chains.d.ts +1 -1
  132. package/dist/queries/similar-chains.js +1 -1
  133. package/dist/queries/similar-files.d.ts +1 -1
  134. package/dist/queries/similar-files.js +1 -1
  135. package/dist/queries/similar-signatures.d.ts +1 -1
  136. package/dist/queries/similar-signatures.js +1 -1
  137. package/dist/queries/similar.d.ts +1 -1
  138. package/dist/queries/similar.js +1 -1
  139. package/dist/queries/slice.d.ts +1 -1
  140. package/dist/queries/slice.js +1 -1
  141. package/dist/queries/stale-abstractions.d.ts +1 -1
  142. package/dist/queries/stale-abstractions.js +1 -1
  143. package/dist/queries/stats.d.ts +1 -1
  144. package/dist/queries/stats.js +1 -1
  145. package/dist/queries/surface.d.ts +1 -1
  146. package/dist/queries/surface.js +1 -1
  147. package/dist/queries/symbols.d.ts +1 -1
  148. package/dist/queries/symbols.js +1 -1
  149. package/dist/queries/system.d.ts +1 -1
  150. package/dist/queries/system.js +1 -1
  151. package/dist/queries/trace.d.ts +1 -1
  152. package/dist/queries/trace.js +1 -1
  153. package/dist/queries/wrapper-candidates.d.ts +1 -1
  154. package/dist/queries/wrapper-candidates.js +1 -1
  155. package/dist/reindex-worker.js +10 -63
  156. package/package.json +4 -2
  157. package/dist/chunk-2OXZVIED.js +0 -41
  158. package/dist/chunk-5IM4IQ6N.js +0 -2
  159. package/dist/chunk-5OV6CUTY.js +0 -2
  160. package/dist/chunk-6QXYWGE5.js +0 -10
  161. package/dist/chunk-C6PQLWHR.js +0 -7
  162. package/dist/chunk-DX5YEUX4.js +0 -6
  163. package/dist/chunk-DXXROCSQ.js +0 -19
  164. package/dist/chunk-EARGTC7U.js +0 -12
  165. package/dist/chunk-EJXPKSWV.js +0 -29
  166. package/dist/chunk-EUHHVFTI.js +0 -2
  167. package/dist/chunk-F2TGKDMW.js +0 -2
  168. package/dist/chunk-GSVIC6KN.js +0 -2
  169. package/dist/chunk-H4IWC7KJ.js +0 -89
  170. package/dist/chunk-H7BWAMFI.js +0 -4
  171. package/dist/chunk-HUEIPY4M.js +0 -5
  172. package/dist/chunk-ID7TO4P6.js +0 -65
  173. package/dist/chunk-J22I2FWD.js +0 -6
  174. package/dist/chunk-KOGVTPGE.js +0 -7
  175. package/dist/chunk-LUYN4IWJ.js +0 -2
  176. package/dist/chunk-MDUIJELV.js +0 -39
  177. package/dist/chunk-MSNW2AR2.js +0 -2
  178. package/dist/chunk-N3Z2SJCR.js +0 -2
  179. package/dist/chunk-NB3GIT4Z.js +0 -7
  180. package/dist/chunk-OBPP5RRE.js +0 -2
  181. package/dist/chunk-ORBQ3HJD.js +0 -2
  182. package/dist/chunk-P6IUCZA3.js +0 -24
  183. package/dist/chunk-Q2MCCKWZ.js +0 -2
  184. package/dist/chunk-QRULHDMO.js +0 -84
  185. package/dist/chunk-RAJHIEBM.js +0 -70
  186. package/dist/chunk-RKZBRDFK.js +0 -2
  187. package/dist/chunk-RPRIZ43D.js +0 -2
  188. package/dist/chunk-RXGCTLHY.js +0 -2
  189. package/dist/chunk-S6IGA6KK.js +0 -2
  190. package/dist/chunk-TVJMEDHH.js +0 -2
  191. package/dist/chunk-UDKLKBPQ.js +0 -2
  192. package/dist/chunk-UGUBEKK5.js +0 -2
  193. package/dist/chunk-VKYLXCV6.js +0 -2
  194. package/dist/chunk-VQXXSUQF.js +0 -8
  195. package/dist/chunk-VZHI3TUX.js +0 -6
  196. package/dist/chunk-YSEQFGGH.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{h as g}from"./chunk-4X7C236P.js";import{a as m}from"./chunk-ZHHMG4UC.js";import{o as r}from"./chunk-QFZE73XF.js";function w(i,f,p){let s=m(i,f),n=m(i,p);if(!s||!n)return null;let c=new Set(g(i,s).map(e=>e.symbol)),h=new Set(g(i,n).map(e=>e.symbol)),l=[];for(let e of c)h.has(e)&&l.push(e);let o=[];for(let e of c)h.has(e)||o.push(e);let a=[];for(let e of h)c.has(e)||a.push(e);let u=new Set([...c,...h]),d=u.size>0?l.length/u.size:0,t;u.size===0?t="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":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 y=s.endLine-s.startLine+1,b=n.endLine-n.startLine+1;return{symbolA:{symbol:s.symbol,shortName:r(s.symbol),file:s.relativePath,loc:y},symbolB:{symbol:n.symbol,shortName:r(n.symbol),file:n.relativePath,loc:b},similarity:d,sharedCallees:l.map(r),uniqueToA:o.map(r),uniqueToB:a.map(r),consolidationStrategy:t}}export{w as a};
2
+ //# sourceMappingURL=chunk-U5MVUPOO.js.map
@@ -0,0 +1,29 @@
1
+ import{b as l}from"./chunk-MO65UK5V.js";import{a as n}from"./chunk-32R4VYYA.js";import{o as i,r as a}from"./chunk-QFZE73XF.js";function _(e,r){let t=l(e,r);return t.length===0?[]:m([...d(e,t),...c(e,t)]).filter(o=>!e.isIgnored(o.relative_path)).map(u)}function d(e,r){let t=r.map(()=>"?").join(", ");return e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
2
+ FROM mentions m
3
+ JOIN chunks c ON m.chunk_id = c.id
4
+ JOIN documents d1 ON c.document_id = d1.id
5
+ JOIN global_symbols gs ON m.symbol_id = gs.id
6
+ WHERE d1.relative_path NOT IN (${t})
7
+ AND (
8
+ EXISTS (
9
+ SELECT 1
10
+ FROM defn_enclosing_ranges der
11
+ JOIN documents d2 ON der.document_id = d2.id
12
+ WHERE der.symbol_id = gs.id
13
+ AND d2.relative_path IN (${t})
14
+ )
15
+ OR EXISTS (
16
+ SELECT 1
17
+ FROM mentions def_m
18
+ JOIN chunks def_c ON def_m.chunk_id = def_c.id
19
+ JOIN documents d2 ON def_c.document_id = d2.id
20
+ WHERE def_m.symbol_id = gs.id
21
+ AND def_m.role = 1
22
+ AND d2.relative_path IN (${t})
23
+ )
24
+ )
25
+ AND m.role != 1
26
+ AND ${e.localSymbolPredicate}
27
+ ${e.pathExclusionsFor("d1")}
28
+ ORDER BY d1.relative_path`,...r,...r,...r)}function c(e,r){let t=new n(e);return r.flatMap(o=>t.definitionsForFile(o).filter(s=>a(s.symbol)).map(s=>({relative_path:o,symbol:s.symbol})))}function m(e){let r=new Set;return e.filter(t=>{let o=`${t.relative_path}|${t.symbol}`;return r.has(o)?!1:(r.add(o),!0)})}function u(e){return{consumer:e.relative_path,symbol:e.symbol,shortName:i(e.symbol)}}export{_ as a};
29
+ //# sourceMappingURL=chunk-URUVLDM7.js.map
@@ -0,0 +1,16 @@
1
+ import{a as h}from"./chunk-32R4VYYA.js";import{p}from"./chunk-YU25IHJX.js";import{o as u,r as c,t as g}from"./chunk-QFZE73XF.js";import{execFileSync as f}from"child_process";function O(e,t={}){let{base:n="HEAD"}=t,s;try{s=b(e.config.projectRoot,n)}catch{return y("Unable to compute git diff.")}if(s.length===0)return y("No changed files found.");let o=I(e,s);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=new h(e),l=new Set(o),m=D(a,o),r=[],i=new Map;for(let C of m)_(e,C,o,l,r,i);let d=R(i);return{changedFiles:o,changedSymbols:r,affectedConsumers:d,summary:{totalChangedFiles:o.length,totalChangedSymbols:r.length,totalAffectedFiles:d.length}}}function y(e){return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function b(e,t){let n=f("git",["diff","--name-only",t],{encoding:"utf-8",cwd:e,timeout:1e4}),s=f("git",["diff","--name-only","--cached",t],{encoding:"utf-8",cwd:e,timeout:1e4}),o=f("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:1e4});return[...new Set([n,s,o].flatMap(a=>a.split(`
2
+ `)).map(a=>a.trim()).filter(a=>a.length>0))]}function I(e,t){let n=[];for(let s of t){let o=e.get(`SELECT relative_path FROM documents
3
+ WHERE relative_path LIKE ?
4
+ LIMIT 1`,`%${s}`);o&&!e.isIgnored(o.relative_path)&&n.push(o.relative_path)}return n}function D(e,t){return t.flatMap(n=>e.definitionsForFile(n)).filter(x).sort((n,s)=>n.relativePath.localeCompare(s.relativePath)||n.startLine-s.startLine)}function _(e,t,n,s,o,a){let l=p(e,[t]).get(t.symbolId)??new Set,m=Math.max(F(e,t.symbolId),l.size);if(!E(t,m))return;let r=u(t.symbol);o.push({symbol:t.symbol,shortName:r,file:t.relativePath,fanIn:m});for(let i of N(e,t.symbolId,n))S(e,s,a,i,r);for(let i of l)S(e,s,a,i,r)}function F(e,t){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`,t)?.fan_in??0}function N(e,t,n){return n.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 (${n.map(()=>"?").join(",")})
15
+ ${e.pathExclusionsFor("ref_d")}`,t,...n).map(o=>o.relative_path)}function S(e,t,n,s,o){if(e.isIgnored(s)||t.has(s))return;let a=n.get(s);a||(a=new Set,n.set(s,a)),a.add(o)}function R(e){return[...e.entries()].map(([t,n])=>({file:t,consumedSymbols:n.size})).sort((t,n)=>n.consumedSymbols-t.consumedSymbols)}function x(e){return!(g(e.symbol)||e.parentTypeName!==null&&!c(e.symbol))}function E(e,t){return c(e.symbol)||e.isTypeLike?!0:e.parentTypeName===null&&t>0}export{O as a};
16
+ //# sourceMappingURL=chunk-WHGCGENP.js.map
@@ -0,0 +1,2 @@
1
+ import{c as p}from"./chunk-KTCODJNQ.js";import{d as b,e as S,l as u}from"./chunk-4X7C236P.js";import{e as y}from"./chunk-2ZGHRI2A.js";import{o as L}from"./chunk-YU25IHJX.js";import{c as x}from"./chunk-ZHHMG4UC.js";import{A as I,E as R,d,p as h}from"./chunk-QFZE73XF.js";function g(n,a,t){let e=u(n).get(t);if(!e||e.length===0)return[];if(e.length===1)return[m(e[0])];let s=e.filter(r=>r.file===a);if(s.length>0)return s.map(m);let i=F(n,a),o=i.get(t);if(o)for(let r of o){let f=e.filter(l=>w(r,l.file));if(f.length>0)return f.map(m)}let c=new Set;for(let r of i.values())for(let f of r)c.add(f);for(let r of c){let f=e.filter(l=>w(r,l.file));if(f.length>0&&f.length===e.length)return f.map(m)}return[]}function C(n,a,t){let e=g(n,a,t);if(e.length>0)return e;let s=u(n).get(t);return!s||s.length===0?[]:s.map(m)}function E(n,a){let t=x(n,a);if(!t)return[];let e=h(t.symbol);if(!e)return[];let s=L(n,{...t,leaf:e,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let o=new Map;for(let c of s){let r=o.get(c.file)??[];r.push(c.line),o.set(c.file,r)}return D(n,o)}let i=new Map;for(let o of p(n)){let c=d(n,o);if(!c||c.indexOf(e)===-1||o!==t.relativePath&&!g(n,o,e).some(l=>l.symbolId===t.symbolId))continue;let r=b(n,o,e,o===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{});r.length>0&&i.set(o,r)}return D(n,i)}function A(n,a){let t=new Map;for(let i of a){if(!i.leaf)continue;let o=t.get(i.leaf)??[];o.push(i),t.set(i.leaf,o)}if(t.size===0)return new Map;let e=new Set(a.map(i=>i.symbolId)),s=new Map;for(let i of p(n)){let o=S(n,i);if(o.size!==0){for(let c of o)if(t.has(c))for(let r of g(n,i,c)){if(!e.has(r.symbolId)||i===r.relativePath)continue;let f=s.get(r.symbolId);f||(f=new Set,s.set(r.symbolId,f)),f.add(i)}}}return s}function F(n,a){let t=new Map;for(let e of y(n,a)){if(!e.sourcePath)continue;let s=e.localName??e.importedName;if(s){let i=t.get(s);i||(i=new Set,t.set(s,i)),i.add(e.sourcePath)}if(e.kind==="namespace")for(let i of e.usedMembers){let o=t.get(i);o||(o=new Set,t.set(i,o)),o.add(e.sourcePath)}}return t}function w(n,a){let t=e=>e.replace(/\\/g,"/").replace(/^\.\//,"");return t(n)===t(a)}function m(n){return{symbolId:n.symbolId,symbol:n.symbol,relativePath:n.file}}function D(n,a){let t=[],e=new Set;for(let[s,i]of a){let o=I(n,s);for(let c of i){let r=R(o,c),f=`${s}|${c}|${r?.symbol??""}`;e.has(f)||(e.add(f),t.push({file:s,line:c,enclosingSymbol:r?.symbol??null}))}}return t}export{g as a,C as b,E as c,A as d};
2
+ //# sourceMappingURL=chunk-WIIZF5FP.js.map
@@ -0,0 +1,2 @@
1
+ import{a as m}from"./chunk-32R4VYYA.js";import{o as p}from"./chunk-QFZE73XF.js";function L(s,r){let{scope:l,minLoc:o=10,limit:u=30}=r??{},{definitions:d,callerMap:y,calleeMap:b}=f(s,l);return d.map(e=>{let a=e.endLine-e.startLine+1,n=y.get(e.symbolId)?.size??0,c=b.get(e.symbolId)??[],x=c.filter(t=>t.file!==e.relativePath),i=new Set(x.map(t=>`${t.symbol}|${t.file}`)).size,M=new Set(c.map(t=>`${t.symbol}|${t.file}`)).size;return{symbol:e.symbol,shortName:p(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:a,fanIn:n,fanOut:i,calleeCount:M,score:Math.round(a/50*(n/5)*Math.max(i/5,1)*100)/100}}).filter(e=>e.loc>=o).sort((e,a)=>a.score-e.score||a.loc-e.loc).slice(0,u)}function f(s,r){let l=new m(s),o=l.productionCallableDefinitions({scope:r,requireCallableSymbol:!0,includeSuppressed:!0});return{definitions:o,callerMap:l.crossFileCallerMap(o),calleeMap:l.calleeMap(o)}}export{L as a};
2
+ //# sourceMappingURL=chunk-WNMAH3P7.js.map
@@ -0,0 +1,11 @@
1
+ import{a as c}from"./chunk-MO65UK5V.js";import{a as m}from"./chunk-32R4VYYA.js";import{p as l}from"./chunk-YU25IHJX.js";import{o as u}from"./chunk-QFZE73XF.js";function C(e,r){let n=c(e,r);if(!n)return null;let t=d(e,n);if(!t||e.isIgnored(t.relative_path))return null;let s=[],i=0;for(let o of p(e,t.relative_path)){let a=h(e,t,o);i+=a,s.push({symbol:o.symbol,shortName:u(o.symbol),startLine:o.startLine,endLine:o.endLine,externalConsumers:a,riskLevel:f(a)})}return{file:t.relative_path,symbols:s,totalExternalConsumers:i}}function d(e,r){return e.get(`SELECT id, relative_path FROM documents
2
+ WHERE relative_path = ?
3
+ ${e.pathExclusionsFor("documents")}
4
+ LIMIT 1`,r)??null}function p(e,r){return new m(e).definitionsForFile(r).sort((n,t)=>n.startLine-t.startLine||n.endLine-t.endLine)}function h(e,r,n){let t=e.all(`SELECT DISTINCT consumer_d.relative_path
5
+ FROM mentions m
6
+ JOIN chunks c ON m.chunk_id = c.id
7
+ JOIN documents consumer_d ON consumer_d.id = c.document_id
8
+ WHERE m.symbol_id = ?
9
+ AND m.role != 1
10
+ AND c.document_id != ?`,n.symbolId,r.id),s=l(e,[n]).get(n.symbolId)??new Set;return new Set([...t.map(i=>i.relative_path),...[...s].filter(i=>i!==r.relative_path)]).size}function f(e){return e>10?"high":e>0?"medium":"low"}export{C as a};
11
+ //# sourceMappingURL=chunk-XV3XUZ3X.js.map
@@ -0,0 +1,2 @@
1
+ import{g as h}from"./chunk-4X7C236P.js";function B(e,s={}){let{minSimilarity:t=.5,limit:n=15,scope:i,minChainLength:r=3,maxChainLength:l=8}=s,a=h(e,i),o=y(a,r,l);if(o.length===0)return[];let f=d(o);return f.length<2?[]:S(C(f,t,n),n)}function d(e){let s=m(e),t=[];for(let n of e){let i=n.filter(r=>!s.has(r));i.length>=2&&t.push({original:n,filtered:i})}return t}function m(e){let{nodeFreq:s,tailFreq:t}=p(e),n=e.length*.9,i=e.length*.8,r=new Set;for(let[a,o]of s)o>n&&r.add(a);for(let[a,o]of t)o>i&&r.add(a);let l=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let a of s.keys()){let o=a.split("/").pop()??"";l.includes(o)&&r.add(a)}return r}function p(e){let s=new Map,t=new Map;for(let n of e){let i=new Set;for(let r of n)i.has(r)||(s.set(r,(s.get(r)??0)+1),i.add(r));for(let r=Math.max(0,n.length-2);r<n.length;r++)t.set(n[r],(t.get(n[r])??0)+1)}return{nodeFreq:s,tailFreq:t}}function C(e,s,t){let n=[];for(let i=0;i<e.length;i++){for(let r=i+1;r<e.length;r++){let l=x(e[i],e[r],s);l&&n.push(l)}if(n.length>t*10)break}return n.sort((i,r)=>Math.abs(r.similarity-i.similarity)>.01?r.similarity-i.similarity:i.divergencePoints.length-r.divergencePoints.length),n}function x(e,s,t){if(!b(e.filtered,s.filtered))return null;let{distance:n,ops:i}=F(e.filtered,s.filtered),r=Math.max(e.filtered.length,s.filtered.length);if(r===0)return null;let l=1-n/r;if(l<t||n===0)return null;let a=i.filter(f=>f.type==="substitute").map(f=>({index:f.indexA,nodeA:e.filtered[f.indexA],nodeB:s.filtered[f.indexB]}));return a.length===0||i.filter(f=>f.type==="match").length<2?null:{chainA:e.original,chainB:s.original,similarity:l,editDistance:n,divergencePoints:a,commonPrefix:A(e.original,s.original),commonSuffix:M(e.original,s.original)}}function b(e,s){let t=new Set(e);return s.some(n=>t.has(n))}function S(e,s){let t=[];for(let n of e)if(t.some(r=>c(n.chainA,r.chainA)&&c(n.chainB,r.chainB))||t.push(n),t.length>=s)break;return t}function y(e,s,t){let n=[];for(let r of e.keys()){if(n.length>=500)break;g(e,r,[r],new Set([r]),s,t,n,500)}return n}function g(e,s,t,n,i,r,l,a){if(l.length>=a)return;if(t.length>=r){t.length>=i&&l.push([...t]);return}let o=e.get(s);if(!o||o.size===0){t.length>=i&&l.push([...t]);return}let f=!1;for(let u of o)if(!n.has(u)&&(n.add(u),t.push(u),g(e,u,t,n,i,r,l,a),t.pop(),n.delete(u),f=!0,l.length>=a))return;!f&&t.length>=i&&l.push([...t])}function F(e,s){let t=e.length,n=s.length,i=Array.from({length:t+1},()=>Array(n+1).fill(0));for(let o=0;o<=t;o++)i[o][0]=o;for(let o=0;o<=n;o++)i[0][o]=o;for(let o=1;o<=t;o++)for(let f=1;f<=n;f++)e[o-1]===s[f-1]?i[o][f]=i[o-1][f-1]:i[o][f]=1+Math.min(i[o-1][f],i[o][f-1],i[o-1][f-1]);let r=[],l=t,a=n;for(;l>0||a>0;)l>0&&a>0&&e[l-1]===s[a-1]?(r.unshift({type:"match",indexA:l-1,indexB:a-1}),l--,a--):l>0&&a>0&&i[l][a]===i[l-1][a-1]+1?(r.unshift({type:"substitute",indexA:l-1,indexB:a-1}),l--,a--):a>0&&i[l][a]===i[l][a-1]+1?(r.unshift({type:"insert",indexA:l,indexB:a-1}),a--):(r.unshift({type:"delete",indexA:l-1,indexB:a}),l--);return{distance:i[t][n],ops:r}}function A(e,s){let t=[];for(let n=0;n<Math.min(e.length,s.length)&&e[n]===s[n];n++)t.push(e[n]);return t}function M(e,s){let t=[],n=e.length-1,i=s.length-1;for(;n>=0&&i>=0&&e[n]===s[i];)t.unshift(e[n]),n--,i--;return t}function c(e,s){if(e.length>s.length)return!1;let t=s.join("\u2192"),n=e.join("\u2192");return t.includes(n)}export{B as a};
2
+ //# sourceMappingURL=chunk-YDKWDTAW.js.map
@@ -1,2 +1,2 @@
1
- import{g as y}from"./chunk-ID7TO4P6.js";function L(D,k={}){let{limit:x=10,scope:M,minDepth:j=3}=k,g=y(D,M),u=new Map,o=[],l=new Map,r=new Map,a=new Set,f=[],d=0;for(let t of g.keys()){if(l.has(t))continue;let n=[],s=(g.get(t)??new Set).values();for(l.set(t,d),r.set(t,d),d+=1,f.push(t),a.add(t),n.push({node:t,iter:s,pendingChild:null});n.length>0;){let e=n[n.length-1];if(e.pendingChild!==null){let h=e.pendingChild;e.pendingChild=null,r.set(e.node,Math.min(r.get(e.node),r.get(h)))}let c=e.iter.next();if(c.done){if(r.get(e.node)===l.get(e.node)){let h=[];for(;;){let p=f.pop();if(a.delete(p),h.push(p),u.set(p,o.length),p===e.node)break}o.push(h)}n.pop();continue}let i=c.value;if(l.has(i))a.has(i)&&r.set(e.node,Math.min(r.get(e.node),l.get(i)));else{l.set(i,d),r.set(i,d),d+=1,f.push(i),a.add(i);let h=(g.get(i)??new Set).values();e.pendingChild=i,n.push({node:i,iter:h,pendingChild:null})}}}let m=new Map,b=new Array(o.length);for(let t=0;t<o.length;t++)b[t]=o[t].length,m.set(t,new Set);for(let[t,n]of g){let s=u.get(t);for(let e of n){let c=u.get(e);c!==s&&m.get(s).add(c)}}let S=new Array(o.length),I=new Array(o.length);for(let t=0;t<o.length;t++){let n=[],s=0;for(let e of m.get(t)){let c=I[e];c>s&&(s=c,n=S[e])}S[t]=[t,...n],I[t]=b[t]+s}function v(t){return S[t]}let A=o.map(t=>[...t].sort()),C=new Set,w=[];for(let t=0;t<o.length;t++){let n=v(t),s=[];for(let c of n)s.push(...A[c]);if(s.length<j)continue;let e=s.join(" ");C.has(e)||(C.add(e),w.push({chain:s,depth:s.length}))}return w.sort((t,n)=>n.depth-t.depth),w.slice(0,x)}export{L as a};
2
- //# sourceMappingURL=chunk-IUNRL2AQ.js.map
1
+ import{g as y}from"./chunk-4X7C236P.js";function L(D,k={}){let{limit:x=10,scope:M,minDepth:j=3}=k,a=y(D,M),u=new Map,o=[],l=new Map,r=new Map,g=new Set,f=[],d=0;for(let t of a.keys()){if(l.has(t))continue;let n=[],s=(a.get(t)??new Set).values();for(l.set(t,d),r.set(t,d),d+=1,f.push(t),g.add(t),n.push({node:t,iter:s,pendingChild:null});n.length>0;){let e=n[n.length-1];if(e.pendingChild!==null){let h=e.pendingChild;e.pendingChild=null,r.set(e.node,Math.min(r.get(e.node),r.get(h)))}let c=e.iter.next();if(c.done){if(r.get(e.node)===l.get(e.node)){let h=[];for(;;){let p=f.pop();if(g.delete(p),h.push(p),u.set(p,o.length),p===e.node)break}o.push(h)}n.pop();continue}let i=c.value;if(l.has(i))g.has(i)&&r.set(e.node,Math.min(r.get(e.node),l.get(i)));else{l.set(i,d),r.set(i,d),d+=1,f.push(i),g.add(i);let h=(a.get(i)??new Set).values();e.pendingChild=i,n.push({node:i,iter:h,pendingChild:null})}}}let m=new Map,b=new Array(o.length);for(let t=0;t<o.length;t++)b[t]=o[t].length,m.set(t,new Set);for(let[t,n]of a){let s=u.get(t);for(let e of n){let c=u.get(e);c!==s&&m.get(s).add(c)}}let S=new Array(o.length),I=new Array(o.length);for(let t=0;t<o.length;t++){let n=[],s=0;for(let e of m.get(t)){let c=I[e];c>s&&(s=c,n=S[e])}S[t]=[t,...n],I[t]=b[t]+s}function v(t){return S[t]}let A=o.map(t=>[...t].sort()),C=new Set,w=[];for(let t=0;t<o.length;t++){let n=v(t),s=[];for(let c of n)s.push(...A[c]);if(s.length<j)continue;let e=s.join(" ");C.has(e)||(C.add(e),w.push({chain:s,depth:s.length}))}return w.sort((t,n)=>n.depth-t.depth),w.slice(0,x)}export{L as a};
2
+ //# sourceMappingURL=chunk-YDNCX5PF.js.map
@@ -0,0 +1,90 @@
1
+ import{A as z,b as B,p as F}from"./chunk-QFZE73XF.js";import f from"path";import{createRequire as $e}from"module";import{existsSync as T,readdirSync as Ue,readFileSync as ie}from"fs";import{existsSync as L}from"fs";import{basename as le,dirname as S,extname as m,join as d,relative as N,resolve as p}from"path";var ue=B("indexed-paths"),D=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],M=[".py",".pyi"],Y=[".java",".scala",".kt",".kts"],P=[".rs"],O=[".rb"],G=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],q=[".cs",".vb"],j=[".dart"],Q=[".php"],pe=[D,M,Y,P,O,G,q,j,Q];function h(n,e){return e.includes(m(n).toLowerCase())}function de(n){return h(n,M)}function fe(n){return h(n,Y)}function ge(n){return h(n,P)}function me(n){return h(n,O)}function Se(n){return h(n,G)}function he(n){return h(n,q)}function gt(n){return m(n).toLowerCase()===".vb"}function ye(n){return h(n,j)}function Ie(n){return h(n,Q)}function xe(n){let e=m(n).toLowerCase();for(let t of pe)if(t.includes(e))return t;return D}function Ee(n){return fe(n)||he(n)||Ie(n)}function A(n,e,t){return de(e)?be(n,e,t):ge(e)?ve(n,e,t):me(e)?ke(n,e,t):Se(e)?Re(n,e,t):Ee(e)?De(n,t.replace(/\\/g,"."),xe(e)):ye(e)?Le(n,e,t):Ne(n,e,t)}function Ne(n,e,t){if(!t.startsWith(".")&&!t.startsWith("/"))return null;let r=S(d(n.config.projectRoot,e)),i=p(r,t),o=b(n);for(let s of Me(i)){let a=I(N(n.config.projectRoot,s));if(o.has(a)||L(s))return a}return I(N(n.config.projectRoot,i))}function be(n,e,t){let r=b(n),i;if(t.startsWith(".")){let o=t.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=S(d(n.config.projectRoot,e));for(let l=1;l<s;l++)c=S(c);i=a?p(c,a.replace(/\./g,"/")):c}else i=p(n.config.projectRoot,t.replace(/\./g,"/"));for(let o of Te(i)){let s=I(N(n.config.projectRoot,o));if(r.has(s)||L(o))return s}return null}function ve(n,e,t){if(!t)return null;let r=t.replace(/\s+as\s+.+$/,"").trim();if(!r.startsWith("crate::")&&!r.startsWith("self::")&&!r.startsWith("super::"))return null;let i=S(d(n.config.projectRoot,e)),o;return r.startsWith("crate::")?o=p(n.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=p(i,r.slice(6).replace(/::/g,"/")):o=p(S(i),r.slice(7).replace(/::/g,"/")),w(n,Ce(o))}function ke(n,e,t){let r=S(d(n.config.projectRoot,e)),i=p(r,t);return w(n,_e(i))}function Re(n,e,t){let r=S(d(n.config.projectRoot,e)),i=[p(r,t),p(n.config.projectRoot,t),p(n.config.projectRoot,"include",t),p(n.config.projectRoot,"src",t)];return w(n,i)}function De(n,e,t){let r=b(n),i=e.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of t){let l=`${o}${c}`,g=[...r].find(y=>y.endsWith(l));if(g)return g}for(let c of t){let l=[...r].find(g=>le(g)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>t.includes(m(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Le(n,e,t){let r=b(n);if(t.startsWith("package:")){let s=t.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=I(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=S(d(n.config.projectRoot,e)),o=p(i,t);for(let s of Fe(o)){let a=I(N(n.config.projectRoot,s));if(r.has(a)||L(s))return a}return null}function Te(n){let e=m(n);return M.includes(e)?[n]:[`${n}.py`,`${n}.pyi`,d(n,"__init__.py"),d(n,"__init__.pyi")]}function w(n,e){let t=b(n);for(let r of e){let i=I(N(n.config.projectRoot,r));if(t.has(i)||L(r))return i}return null}function Ce(n){let e=m(n);return P.includes(e)?[n]:[`${n}.rs`,d(n,"mod.rs")]}function _e(n){let e=m(n);return O.includes(e)?[n]:[`${n}.rb`,d(n,"index.rb")]}function Fe(n){let e=m(n);return j.includes(e)?[n]:[`${n}.dart`,n]}function Me(n){let e=m(n),t=new Set;if(e){t.add(n);for(let r of D)t.add(n.slice(0,-e.length)+r)}else for(let r of D)t.add(`${n}${r}`),t.add(d(n,`index${r}`));return[...t]}function b(n){return ue.get(n,()=>new Set(n.all(`SELECT relative_path
2
+ FROM documents
3
+ WHERE 1 = 1
4
+ ${n.pathExclusionsFor("documents")}`).map(e=>I(e.relative_path)).filter(e=>!n.isIgnored(e))))}function I(n){return n.replace(/\\/g,"/")}import{existsSync as v,readFileSync as Pe,readdirSync as Oe,statSync as je}from"fs";import u from"path";var $=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function U(n,e){let r=e?u.dirname(u.join(n,e)):n,i=u.resolve(n);for(;r.startsWith(i);){for(let s of $){let a=u.join(r,s);if(v(a))return a}let o=u.dirname(r);if(o===r)break;r=o}for(let o of $){let s=u.join(n,o);if(v(s))return s}return null}function Z(n){let e=n.config.projectRoot,t=new Set(Ae(e,n.config.semantic?.typescript?.tsconfigs)),r=n.all(`SELECT relative_path
5
+ FROM documents
6
+ WHERE (
7
+ relative_path LIKE '%.ts'
8
+ OR relative_path LIKE '%.tsx'
9
+ OR relative_path LIKE '%.mts'
10
+ OR relative_path LIKE '%.cts'
11
+ OR relative_path LIKE '%.js'
12
+ OR relative_path LIKE '%.jsx'
13
+ OR relative_path LIKE '%.mjs'
14
+ OR relative_path LIKE '%.cjs'
15
+ )
16
+ ${n.pathExclusionsFor("documents")}`);for(let i of r){if(n.isIgnored(i.relative_path))continue;let o=U(e,i.relative_path);o&&t.add(u.resolve(o))}if(t.size===0){let i=U(e);i&&t.add(u.resolve(i))}return[...t].filter(i=>!ee(e,i)).sort((i,o)=>i.localeCompare(o))}function Ae(n,e=[]){let t=new Set;for(let r of e){let i=u.isAbsolute(r)?r:u.join(n,r);v(i)&&t.add(u.resolve(i))}for(let r of we(n))for(let i of $){let o=u.join(r,i);v(o)&&t.add(u.resolve(o))}if(t.size===0){let r=U(n);r&&t.add(u.resolve(r))}return[...t].filter(r=>!ee(n,r)).sort((r,i)=>r.localeCompare(i))}function we(n){let e=u.join(n,"package.json");if(!v(e))return[];let t;try{t=JSON.parse(Pe(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>We(n,i))}function We(n,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=u.join(n,e);return W(s)?[s]:[]}let t=e.indexOf("*"),r=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=u.join(n,r||".");return W(o)?Oe(o).map(s=>u.join(o,s,i)).filter(W):[]}function W(n){try{return je(n).isDirectory()}catch{return!1}}function ee(n,e){let t=u.relative(n,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}var Ke=$e(import.meta.url),k;function oe(n,e){let t=He();if(!t)return K("ts-morph is not installed");let r=Z(n);if(r.length===0)return K("no tsconfig found");try{let i=r.map(o=>({tsconfigPath:o,project:new t.Project({tsConfigFilePath:o,skipFileDependencyResolution:!1})}));return new H(n,t,i)}catch(i){return K(i instanceof Error?i.message:String(i),r[0],r)}}function He(){if(k!==void 0)return k;try{k=Ke("ts-morph")}catch{k=null}return k}function K(n,e,t){return{language:"typescript",availability:()=>({available:!1,reason:n,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var H=class{constructor(e,t,r){this.db=e;this.tsMorph=t;this.projects=r;this.workspacePackages=Ve(e.config.projectRoot)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;sourceFileCache=new Map;indexedDefinitionLeafCache=new Map;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return x(this.importUsageCache,e,()=>{let t=this.sourceFile(e);if(!t)return[];let r=[];for(let i of t.getImportDeclarations())r.push(...this.importUsageForDeclaration(e,i));return r})}referencesFor(e){return x(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),r=this.packageImportReferencesForDefinition(e);if(!t)return r;let i=Qe(t);return J([...i.flatMap(o=>qe(o,this.db.config.projectRoot)).filter(o=>o.file!==e.relativePath||o.line<e.startLine||o.line>e.endLine),...r])})}calleesFor(e){return x(this.calleesCache,e.symbolId,()=>x(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}signatureFor(e){return x(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 r=t.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(s=>{let a=s.getDeclarations()[0],c=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return re(c)}),o=r.getReturnType().getText(t);return`(${i.join(",")})=>${re(o)}`})}importUsageForDeclaration(e,t){let r=A(this.db,e,t.getModuleSpecifierValue()),i=te(t);return t.getImportClause()?.isTypeOnly()?i.map(o=>Je(e,r,o)):i.map(o=>this.valueImportUsageForEntry(e,r,o))}valueImportUsageForEntry(e,t,r){let o=(r.identifier?r.identifier.findReferences():[]).flatMap(l=>Ze(l,e,r.identifier,this.db.config.projectRoot)),s=o.some(l=>!ne(l.node)),a=o.some(l=>ne(l.node)),c=r.isTypeOnly;return{importer:e,sourcePath:t,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:c,isUsed:c||o.length>0,isTypeUsed:c||a,isValueUsed:s,references:o.map(l=>l.location)}}sourceFile(e){return this.sourceFileMatch(e)?.sourceFile??null}sourceFileMatch(e){return at(e)?x(this.sourceFileCache,e,()=>{let t=f.join(this.db.config.projectRoot,e);for(let{project:r}of this.projects){let i=r.getSourceFile(t)??r.addSourceFileAtPathIfExists(t)??null;if(i)return{project:r,sourceFile:i}}return null}):null}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let r of this.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,r);for(let[r,i]of e)e.set(r,J(i));return this.packageImportReferenceIndex=e,e}indexedTypeScriptLikeDocuments(){return this.db.all(`SELECT relative_path
17
+ FROM documents
18
+ WHERE (
19
+ relative_path LIKE '%.ts'
20
+ OR relative_path LIKE '%.tsx'
21
+ OR relative_path LIKE '%.mts'
22
+ OR relative_path LIKE '%.cts'
23
+ OR relative_path LIKE '%.js'
24
+ OR relative_path LIKE '%.jsx'
25
+ OR relative_path LIKE '%.mjs'
26
+ OR relative_path LIKE '%.cjs'
27
+ )
28
+ ${this.db.pathExclusionsFor("documents")}`).map(e=>e.relative_path)}addPackageImportReferencesForDocument(e,t,r){if(this.db.isIgnored(r))return;let i=this.sourceFileMatch(r);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,r,o)}addPackageImportReferencesForDeclaration(e,t,r,i){let o=Ye(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of te(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let l=et(a.identifier,r,this.db.config.projectRoot);l.length>0&&ot(e,c,l)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let r=new Map;for(let i of Ge(t))this.collectPackageExports(t,i,r,new Set);r.size>0&&e.set(t.name,r)}return this.packageExportIndex=e,e}collectPackageExports(e,t,r,i){if(i.has(t))return;i.add(t);let o=this.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?A(this.db,t,a):t;if(!c||!c.startsWith(`${e.sourceRootRelative}/`))continue;let l=s.getNamedExports();if(l.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let g of l){let y=g.getNameNode().getText(),X=g.getAliasNode()?.getText()??y,V=this.indexedDefinitionByLeaf(c,y);if(!V)continue;let R=r.get(X);R||(R=new Set,r.set(X,R)),R.add(V.symbolId)}}}indexedDefinitionByLeaf(e,t){return x(this.indexedDefinitionLeafCache,e,()=>rt(this.db,e)).get(t)??null}nodeForDefinition(e){let t=this.sourceFile(e.relativePath);if(!t)return null;let r=F(e.symbol)??e.leaf,i=[];return t.forEachDescendant(o=>{if(!tt(this.tsMorph,o,r))return;let s=E(t,o);s<e.startLine-1||s>e.endLine+1||i.push(o)}),i.sort((o,s)=>Math.abs(E(t,o)-e.startLine)-Math.abs(E(t,s)-e.startLine))[0]??null}definitionFromSymbol(e){let t=e.getDeclarations();for(let r of t){let i=r.getSourceFile(),o=C(this.db.config.projectRoot,i.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=E(i,r),a=nt(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.sourceFile(e);if(!t)return new Map;let r=z(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(r.length===0)return new Map;let i=new Map;t.forEachDescendant(o=>{if(!this.tsMorph.Node.isCallExpression(o)&&!this.tsMorph.Node.isNewExpression(o))return;let s=this.semanticCalleeForCallNode(t,r,o);s&&Xe(i,s.callerId,s.target)});for(let[o,s]of i)i.set(o,st(s));return i}semanticCalleeForCallNode(e,t,r){let i=it(t,E(e,r));if(!i)return null;let o=r.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:i.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function te(n){let e=[],t=n.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});let r=n.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});for(let i of n.getNamedImports()){let o=i.getNameNode(),a=i.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(n.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Je(n,e,t){return{importer:n,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function Xe(n,e,t){let r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}function Ve(n){let e=f.join(n,"package.json");if(!T(e))return[];let t;try{t=JSON.parse(ie(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>Be(n,i)).flatMap(i=>ze(n,i))}function Be(n,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=f.join(n,e);return T(f.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),r=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=f.join(n,r||".");if(!T(o))return[];try{return Ue(o).map(s=>f.join(o,s,i)).filter(s=>T(f.join(s,"package.json")))}catch{return[]}}function ze(n,e){try{let t=JSON.parse(ie(f.join(e,"package.json"),"utf8"));if(!t.name)return[];let r=f.relative(n,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:r,sourceRootRelative:`${r}/src`}]}catch{return[]}}function Ye(n,e){for(let t of n)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function Ge(n){return[`${n.sourceRootRelative}/index.ts`,`${n.sourceRootRelative}/index.tsx`,`${n.sourceRootRelative}/index.mts`,`${n.sourceRootRelative}/index.cts`]}function qe(n,e){return n.getReferences().map(t=>{let r=t.getNode();return se(r,e)})}function Qe(n){let e=n;return typeof e.findReferences=="function"?e.findReferences():[]}function Ze(n,e,t,r){return n.getReferences().map(i=>i.getNode()).filter(i=>C(r,i.getSourceFile().getFilePath())===e).filter(i=>!t||i.getStart()!==t.getStart()).map(i=>({location:se(i,r),node:i}))}function se(n,e){let t=n.getSourceFile(),r=t.getLineAndColumnAtPos(n.getStart());return{file:C(e,t.getFilePath())??t.getBaseName(),line:r.line-1,column:r.column-1}}function et(n,e,t){let r=n.getSourceFile(),i=E(r,n),o=n.getText(),s=new RegExp(`\\b${ct(o)}\\b`,"g"),a=r.getFullText().split(`
29
+ `),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let g=a[l]??"";s.lastIndex=0;let y;for(;(y=s.exec(g))!==null;)c.push({file:e,line:l,column:y.index})}return J(c.filter(l=>C(t,f.join(t,l.file))===e))}function ne(n){for(let e=n;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 tt(n,e,t){return"getNameNode"in e&&typeof e.getNameNode=="function"&&e.getNameNode()?.getText()===t||"getName"in e&&typeof e.getName=="function"&&e.getName()===t?!0:n.Node.isIdentifier(e)&&e.getText()===t}function nt(n,e,t,r){return n.all(`SELECT
30
+ gs.id AS symbolId,
31
+ gs.symbol,
32
+ d.relative_path AS relativePath,
33
+ COALESCE(der.start_line, c.start_line) AS startLine,
34
+ COALESCE(der.end_line, c.end_line) AS endLine,
35
+ COALESCE(gs.display_name, '') AS leaf,
36
+ NULL AS parentTypeName,
37
+ CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
38
+ CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
39
+ gs.kind AS kind,
40
+ gs.documentation AS documentation,
41
+ gs.enclosing_symbol AS enclosingSymbol
42
+ FROM global_symbols gs
43
+ LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
44
+ LEFT JOIN chunks c ON c.document_id = der.document_id
45
+ JOIN documents d ON d.id = der.document_id
46
+ WHERE d.relative_path = ?
47
+ AND COALESCE(gs.display_name, gs.symbol) LIKE ?
48
+ ORDER BY ABS(COALESCE(der.start_line, c.start_line) - ?)
49
+ LIMIT 5`,e,`%${r}%`,t)[0]??null}function rt(n,e){let t=n.all(`SELECT
50
+ d.id AS documentId,
51
+ gs.id AS symbolId,
52
+ gs.symbol,
53
+ d.relative_path AS relativePath,
54
+ der.start_line AS startLine,
55
+ der.end_line AS endLine,
56
+ COALESCE(gs.display_name, '') AS leaf,
57
+ NULL AS parentTypeName,
58
+ CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
59
+ CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
60
+ gs.kind AS kind,
61
+ gs.documentation AS documentation,
62
+ gs.enclosing_symbol AS enclosingSymbol
63
+ FROM global_symbols gs
64
+ JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
65
+ JOIN documents d ON d.id = der.document_id
66
+ WHERE d.relative_path = ?
67
+ UNION ALL
68
+ SELECT
69
+ d.id AS documentId,
70
+ gs.id AS symbolId,
71
+ gs.symbol,
72
+ d.relative_path AS relativePath,
73
+ MIN(c.start_line) AS startLine,
74
+ MAX(c.end_line) AS endLine,
75
+ COALESCE(gs.display_name, '') AS leaf,
76
+ NULL AS parentTypeName,
77
+ CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
78
+ CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
79
+ gs.kind AS kind,
80
+ gs.documentation AS documentation,
81
+ gs.enclosing_symbol AS enclosingSymbol
82
+ FROM global_symbols gs
83
+ JOIN mentions m ON m.symbol_id = gs.id
84
+ JOIN chunks c ON c.id = m.chunk_id
85
+ JOIN documents d ON d.id = c.document_id
86
+ WHERE d.relative_path = ?
87
+ AND m.role = 1
88
+ GROUP BY gs.id, gs.symbol, d.id, d.relative_path, gs.display_name, gs.kind, gs.documentation, gs.enclosing_symbol
89
+ ORDER BY startLine, endLine`,e,e),r=new Set,i=new Map;for(let o of t){if(r.has(o.symbolId))continue;r.add(o.symbolId);let s=o.leaf||F(o.symbol);!s||i.has(s)||i.set(s,{...o,leaf:s})}return i}function it(n,e){let t=null;for(let r of n)e<r.startLine||e>r.endLine||(!t||r.startLine>=t.startLine)&&(t=r);return t}function E(n,e){return n.getLineAndColumnAtPos(e.getStart()).line-1}function J(n){let e=new Set,t=[];for(let r of n){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),t.push(r))}return t}function ot(n,e,t){for(let r of e){let i=n.get(r)??[];i.push(...t),n.set(r,i)}}function st(n){let e=new Set,t=[];for(let r of n){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),t.push(r))}return t}function x(n,e,t){if(n.has(e))return n.get(e);let r=t();return n.set(e,r),r}function C(n,e){let t=f.relative(n||process.cwd(),e).replace(/\\/g,"/");return!t||t.startsWith("..")?null:t}function at(n){return/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/.test(n)}function re(n){return n.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}function ct(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ae=new WeakMap;function ce(n,e){let t=`${n.config.projectRoot}:typescript-workspace`,r=ae.get(n);r||(r=new Map,ae.set(n,r));let i=r.get(t);if(i)return i;let o=oe(n,e);return r.set(t,o),o}function Ct(n,e){let t=_(n,e);return t?t.importUsage(e):[]}function lt(n,e){let t=_(n,e.relativePath);return t?t.referencesFor(e):[]}function _t(n,e){let t=new Map;for(let r of e)for(let i of lt(n,r)){if(i.file===r.relativePath||n.isIgnored(i.file))continue;let o=t.get(r.symbolId);o||(o=new Set,t.set(r.symbolId,o)),o.add(i.file)}return t}function Ft(n,e){let t=new Map;for(let r of e){let i=_(n,r.relativePath);if(!i)continue;let o=i.calleesFor(r);o.length>0&&t.set(r.symbolId,o)}return t}function Mt(n,e){let t=_(n,e.relativePath);return t?t.signatureFor(e):null}function _(n,e){if(!ut(e))return null;let t=ce(n,e);return t.availability().available?t:null}function ut(n){return/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/.test(n)}export{Y as a,q as b,Q as c,gt as d,xe as e,A as f,be as g,ve as h,ke as i,Re as j,De as k,Le as l,I as m,Ct as n,lt as o,_t as p,Ft as q,Mt as r};
90
+ //# sourceMappingURL=chunk-YU25IHJX.js.map
@@ -1,4 +1,4 @@
1
- import{i as d}from"./chunk-ID7TO4P6.js";import{q as l}from"./chunk-QRULHDMO.js";import{b as r}from"./chunk-5IM4IQ6N.js";function y(o,t={}){let{limit:s=30,scope:e}=t,n=e?`AND def_d.relative_path LIKE '%${e}%'`:"",m=o.all(`SELECT
1
+ import{i as d}from"./chunk-4X7C236P.js";import{B as l,o as m}from"./chunk-QFZE73XF.js";function y(o,t={}){let{limit:s=30,scope:e}=t,n=e?`AND def_d.relative_path LIKE '%${e}%'`:"",r=o.all(`SELECT
2
2
  gs.symbol,
3
3
  COUNT(*) AS ref_count,
4
4
  COUNT(DISTINCT ref_d.id) AS file_count,
@@ -21,5 +21,5 @@ import{i as d}from"./chunk-ID7TO4P6.js";import{q as l}from"./chunk-QRULHDMO.js";
21
21
  ${n}
22
22
  GROUP BY gs.id
23
23
  ORDER BY ref_count DESC
24
- LIMIT ?`,s).filter(i=>!o.isIgnored(i.defined_in)).map(i=>({symbol:i.symbol,shortName:r(i.symbol),refCount:i.ref_count,fileCount:i.file_count,definedIn:i.defined_in}));return m.length>0?m:f(o,e,s)}function f(o,t,s){return l(o,{scope:t}).filter(e=>!o.isIgnored(e.relativePath)).map(e=>u(o,e)).filter(e=>e.refCount>0).sort((e,n)=>n.refCount-e.refCount||n.fileCount-e.fileCount).slice(0,s)}function u(o,t){let s=d(o,t,{limit:500});return{symbol:t.symbol,shortName:r(t.symbol),refCount:s.length,fileCount:new Set(s.map(e=>e.file)).size,definedIn:t.relativePath}}export{y as a};
25
- //# sourceMappingURL=chunk-VZE4SOJG.js.map
24
+ LIMIT ?`,s).filter(i=>!o.isIgnored(i.defined_in)).map(i=>({symbol:i.symbol,shortName:m(i.symbol),refCount:i.ref_count,fileCount:i.file_count,definedIn:i.defined_in}));return r.length>0?r:f(o,e,s)}function f(o,t,s){return l(o,{scope:t}).filter(e=>!o.isIgnored(e.relativePath)).map(e=>u(o,e)).filter(e=>e.refCount>0).sort((e,n)=>n.refCount-e.refCount||n.fileCount-e.fileCount).slice(0,s)}function u(o,t){let s=d(o,t,{limit:500});return{symbol:t.symbol,shortName:m(t.symbol),refCount:s.length,fileCount:new Set(s.map(e=>e.file)).size,definedIn:t.relativePath}}export{y as a};
25
+ //# sourceMappingURL=chunk-Z5CTXSWT.js.map
@@ -0,0 +1,2 @@
1
+ import{a as m}from"./chunk-32R4VYYA.js";import{a as l}from"./chunk-ZHHMG4UC.js";import{p as r,r as a}from"./chunk-QFZE73XF.js";import{basename as d}from"path";function g(t,c){let o=l(t,c);if(!o)return[];let s=r(o.symbol),i=new m(t).definitionsForFile(o.relativePath).filter(e=>a(e.symbol)),n=i.filter(e=>e.parentTypeName===s||e.symbol.includes(s));return(n.length>0?n:p(d(o.relativePath))===s?i.filter(e=>e.symbol.includes("<invalid-global-code>")):[]).map(e=>({startLine:e.startLine,endLine:e.endLine,name:r(e.symbol)}))}function p(t){return t.replace(/\.[^.]+$/,"")}export{g as a};
2
+ //# sourceMappingURL=chunk-ZFCQQ4B5.js.map
@@ -0,0 +1,114 @@
1
+ import{F as y,G as S,o as E,p as I,r as L,s as $,t as v}from"./chunk-QFZE73XF.js";function ne(e,t){let n=K(e,t.trim());if(n)return n;let s=B(e,t);if(s)return s;let a=F(e,t);return a||W(e,t)}function F(e,t){let n=C(t),s=w(n);if(!s)return null;let a=`%${s.path}%`,i=s.leaf,r=k(e,a,i,n)[0];return r?y(e,r):null}function k(e,t,n,s){let a=M([],[...J(e,t,n),...T(e,t,n)]).filter(i=>!e.isIgnored(i.relative_path)).filter(i=>_(i,s)>1);return a.sort((i,o)=>_(o,s)-_(i,s)||i.end_line-i.start_line-(o.end_line-o.start_line)||i.start_line-o.start_line||i.symbol.localeCompare(o.symbol)),a}function J(e,t,n){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name, gs.documentation
2
+ FROM global_symbols gs
3
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
4
+ JOIN documents d ON der.document_id = d.id
5
+ WHERE d.relative_path LIKE ?
6
+ AND (gs.display_name = ? OR gs.symbol LIKE ?)
7
+ ${e.pathExclusionsFor("d")}`,t,n,`%/${n}.%`)}function T(e,t,n){return e.all(`SELECT
8
+ gs.id,
9
+ gs.symbol,
10
+ c.document_id,
11
+ MIN(c.start_line) AS start_line,
12
+ MAX(c.end_line) AS end_line,
13
+ d.relative_path,
14
+ gs.display_name,
15
+ gs.documentation
16
+ FROM global_symbols gs
17
+ JOIN mentions m ON m.symbol_id = gs.id
18
+ JOIN chunks c ON m.chunk_id = c.id
19
+ JOIN documents d ON c.document_id = d.id
20
+ WHERE m.role = 1
21
+ AND d.relative_path LIKE ?
22
+ AND (gs.display_name = ? OR gs.symbol LIKE ?)
23
+ ${e.pathExclusionsFor("d")}
24
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation`,t,n,`%/${n}.%`)}function W(e,t){let n=C(t),s=j(t),a=z(e,s),i=q(a,t,n);if(i&&!e.isIgnored(i.relative_path))return y(e,i);let o=null;for(let r of a){if(e.isIgnored(r.relative_path))continue;let d=U(r,t,n,s);d<=0||(!o||d>o.score)&&(o={row:r,score:d})}return o?y(e,o.row):null}function B(e,t){let n=t.match(/^(.+):(\d+)-(\d+)$/);if(!n)return null;let[,s,a,i]=n,o=Math.max(0,parseInt(a,10)-1),r=Math.max(o,parseInt(i,10)-1),d=Y(e,s,o,r)??H(e,s,o,r);return d&&!e.isIgnored(d.relative_path)?y(e,d):null}function Y(e,t,n,s){return e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
25
+ FROM global_symbols gs
26
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
27
+ JOIN documents d ON der.document_id = d.id
28
+ WHERE d.relative_path LIKE ?
29
+ AND der.start_line <= ? AND der.end_line >= ?
30
+ ${e.pathExclusionsFor("d")}
31
+ ORDER BY (der.end_line - der.start_line) ASC
32
+ LIMIT 1`,`%${t}%`,n,s)}function H(e,t,n,s){return e.get(`SELECT gs.id, gs.symbol, c.document_id, MIN(c.start_line) AS start_line, MAX(c.end_line) AS end_line, d.relative_path
33
+ FROM global_symbols gs
34
+ JOIN mentions m ON m.symbol_id = gs.id
35
+ JOIN chunks c ON m.chunk_id = c.id
36
+ JOIN documents d ON c.document_id = d.id
37
+ WHERE m.role = 1
38
+ AND d.relative_path LIKE ?
39
+ AND c.start_line <= ? AND c.end_line >= ?
40
+ ${e.pathExclusionsFor("d")}
41
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
42
+ ORDER BY (MAX(c.end_line) - MIN(c.start_line)) ASC
43
+ LIMIT 1`,`%${t}%`,n,s)}function K(e,t){let s=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
44
+ FROM global_symbols gs
45
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
46
+ JOIN documents d ON der.document_id = d.id
47
+ WHERE gs.symbol = ?
48
+ ${e.pathExclusionsFor("d")}
49
+ ORDER BY d.relative_path, der.start_line
50
+ LIMIT 1`,t)??e.get(`SELECT
51
+ gs.id,
52
+ gs.symbol,
53
+ c.document_id,
54
+ MIN(c.start_line) AS start_line,
55
+ MAX(c.end_line) AS end_line,
56
+ d.relative_path
57
+ FROM global_symbols gs
58
+ JOIN mentions m ON m.symbol_id = gs.id
59
+ JOIN chunks c ON m.chunk_id = c.id
60
+ JOIN documents d ON c.document_id = d.id
61
+ WHERE gs.symbol = ?
62
+ AND m.role = 1
63
+ ${e.pathExclusionsFor("d")}
64
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
65
+ ORDER BY d.relative_path, start_line
66
+ LIMIT 1`,t);return!s||e.isIgnored(s.relative_path)?null:y(e,s)}function te(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=X(e,t.symbolId)[0];return n?y(e,n):null}function X(e,t){let n=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name, gs.documentation
67
+ FROM global_symbols gs
68
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
69
+ JOIN documents d ON der.document_id = d.id
70
+ WHERE gs.id = ?
71
+ ORDER BY der.start_line, der.end_line`,t),s=e.all(`SELECT
72
+ gs.id,
73
+ gs.symbol,
74
+ c.document_id,
75
+ MIN(c.start_line) AS start_line,
76
+ MAX(c.end_line) AS end_line,
77
+ d.relative_path,
78
+ gs.display_name,
79
+ gs.documentation
80
+ FROM global_symbols gs
81
+ JOIN mentions m ON m.symbol_id = gs.id
82
+ JOIN chunks c ON m.chunk_id = c.id
83
+ JOIN documents d ON c.document_id = d.id
84
+ WHERE gs.id = ?
85
+ AND m.role = 1
86
+ ${e.pathExclusionsFor("d")}
87
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
88
+ ORDER BY start_line, end_line`,t);return M(n,s)}function z(e,t){let n=t.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),s=t.flatMap(o=>{let r=`%${o}%`;return[r,r,r]}),a=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name, gs.documentation
89
+ FROM global_symbols gs
90
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
91
+ JOIN documents d ON der.document_id = d.id
92
+ WHERE ${n.join(`
93
+ AND `)}
94
+ ${e.pathExclusionsFor("d")}
95
+ LIMIT 200`,...s),i=e.all(`SELECT
96
+ gs.id,
97
+ gs.symbol,
98
+ c.document_id,
99
+ MIN(c.start_line) AS start_line,
100
+ MAX(c.end_line) AS end_line,
101
+ d.relative_path,
102
+ gs.display_name,
103
+ gs.documentation
104
+ FROM global_symbols gs
105
+ JOIN mentions m ON m.symbol_id = gs.id
106
+ JOIN chunks c ON m.chunk_id = c.id
107
+ JOIN documents d ON c.document_id = d.id
108
+ WHERE m.role = 1
109
+ AND ${n.join(`
110
+ AND `)}
111
+ ${e.pathExclusionsFor("d")}
112
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
113
+ LIMIT 200`,...s);return M(a,i)}function M(e,t){let n=new Map;for(let s of t)e.length>0&&!G(s)||n.set(s.id,s);for(let s of e)n.set(s.id,s);return[...n.values()]}function G(e){if(S(e.symbol)!==null)return!1;let n=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(n)}function U(e,t,n,s){let a=t.trim(),i=n,o=i.replace(/\(\)$/,""),r=t.toLowerCase(),d=n.toLowerCase(),g=d.replace(/\(\)$/,""),D=e.symbol,R=E(e.symbol),p=I(e.symbol),Q=e.display_name??"",f=e.symbol.toLowerCase(),c=R.toLowerCase(),m=p.toLowerCase(),O=Q.toLowerCase(),u=e.relative_path.toLowerCase(),A=/[/:.]/.test(n),N=w(n),b=N?.leaf.toLowerCase(),l=0;return(D===a||D===i)&&(l+=1150),(R===a||R===i)&&(l+=1100),Q===o&&(l+=1180),p===o&&(l+=1160),(`${p}()`===a||`${p}()`===i)&&(l+=955),(f===r||f===d)&&(l+=1e3),(c===r||c===d)&&(l+=950),(u===r||u===d)&&(l+=925),(u.endsWith(`/${d}`)||u.endsWith(`/${r}`))&&(l+=875),O===g&&(l+=850),m===g&&(l+=825),(`${m}()`===r||`${m}()`===d)&&(l+=820),(c.endsWith(`:${d}`)||c.endsWith(`:${g}`)||c.endsWith(`:${g}()`))&&(l+=800),f.includes(d)&&(l+=120),c.includes(d)&&(l+=140),u.includes(d)&&(l+=140),O.includes(d)&&(l+=110),s.every(x=>{let h=x.toLowerCase();return f.includes(h)||c.includes(h)||u.includes(h)||O.includes(h)})&&(l+=100+s.length*15),N&&u.includes(N.path.toLowerCase())&&(l+=360,b&&(m===b||`${m}()`===b||`${m}()`==`${b}()`)&&(l+=700),L(e.symbol)&&(l+=180)),$(e.symbol)&&m===g&&(l+=60),!A&&v(e.symbol)&&(l-=160),l-=Math.min(50,Math.max(0,e.end_line-e.start_line)),l}function w(e){let t=e.trim().replace(/\\/g,"/"),n=t.lastIndexOf("/");if(n<=0||n===t.length-1)return null;let s=t.slice(n+1).replace(/\(\)$/,"");return!s||s.includes(".")?null:{path:t.slice(0,n),leaf:s}}function C(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function j(e){let t=C(e),n=t.split(/[^A-Za-z0-9_]+/).map(s=>s.trim()).filter(s=>s.length>0);return n.length>0?[...new Set(n)]:[t]}function q(e,t,n){let s=t.trim(),a=e.filter(i=>{let o=E(i.symbol),r=(i.display_name??"").trim();return i.symbol===s||o===s||o===n||r===s||r===n||`${r}()`===s||_(i,n)>1||i.relative_path===s});return a.length===0?null:(a.sort((i,o)=>_(o,n)-_(i,n)||i.end_line-i.start_line-(o.end_line-o.start_line)||i.relative_path.localeCompare(o.relative_path)||i.symbol.localeCompare(o.symbol)),a[0]??null)}function _(e,t){let n=w(t);if(!n)return 0;let s=e.relative_path.toLowerCase(),a=I(e.symbol).toLowerCase(),i=n.path.toLowerCase(),o=n.leaf.toLowerCase();return s.includes(i)?a!==o?1:L(e.symbol)?S(e.symbol)===null?5:4:S(e.symbol)===null?3:2:0}export{ne as a,K as b,te as c};
114
+ //# sourceMappingURL=chunk-ZHHMG4UC.js.map