scip-query 0.4.3 → 0.6.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 (199) hide show
  1. package/dist/chunk-2DSS2NGF.js +10 -0
  2. package/dist/chunk-2RLP74AO.js +2 -0
  3. package/dist/chunk-4QJ7LVW5.js +2 -0
  4. package/dist/chunk-4TYGGOLO.js +5 -0
  5. package/dist/chunk-5IADAU5B.js +7 -0
  6. package/dist/chunk-7754WFFV.js +18 -0
  7. package/dist/chunk-7VOF4ZG6.js +2 -0
  8. package/dist/chunk-7Z4COVMC.js +2 -0
  9. package/dist/chunk-AJ5PWKD4.js +2 -0
  10. package/dist/chunk-BDBRZPX3.js +7 -0
  11. package/dist/chunk-BE6EQIWY.js +2 -0
  12. package/dist/chunk-BQ3INTYT.js +8 -0
  13. package/dist/chunk-D7KLLMPB.js +2 -0
  14. package/dist/chunk-D7YBWSON.js +29 -0
  15. package/dist/chunk-DE5ZBHMK.js +39 -0
  16. package/dist/chunk-DHYIJHXZ.js +33 -0
  17. package/dist/chunk-EEF3YEHW.js +2 -0
  18. package/dist/chunk-F2LLHRRZ.js +2 -0
  19. package/dist/chunk-FCC3XJTI.js +2 -0
  20. package/dist/chunk-GNXRLK5G.js +2 -0
  21. package/dist/chunk-GXVB36TG.js +62 -0
  22. package/dist/chunk-HMKJTAZD.js +2 -0
  23. package/dist/chunk-IBGBI3VU.js +2 -0
  24. package/dist/chunk-IYFZS4PV.js +84 -0
  25. package/dist/chunk-JH3A7HTU.js +2 -0
  26. package/dist/chunk-JS2RNIC7.js +2 -0
  27. package/dist/chunk-K5FQFCSN.js +41 -0
  28. package/dist/chunk-K6GBKEQE.js +6 -0
  29. package/dist/chunk-KO7YJRWP.js +12 -0
  30. package/dist/chunk-KYT47WU2.js +4 -0
  31. package/dist/chunk-LORWXBOO.js +2 -0
  32. package/dist/chunk-LX4H4LLG.js +89 -0
  33. package/dist/chunk-N3Z2SJCR.js +2 -0
  34. package/dist/chunk-NTDA4A2D.js +25 -0
  35. package/dist/chunk-NXMYYHDO.js +24 -0
  36. package/dist/chunk-PZ6ESKRH.js +7 -0
  37. package/dist/chunk-QXE6EDY2.js +6 -0
  38. package/dist/chunk-RJ7SPBJ5.js +5 -0
  39. package/dist/chunk-RWE6FHG3.js +3 -0
  40. package/dist/chunk-SDX6MDBL.js +2 -0
  41. package/dist/chunk-SG35Y7J2.js +2 -0
  42. package/dist/chunk-STOGKRJH.js +4 -0
  43. package/dist/chunk-TINPMWJK.js +2 -0
  44. package/dist/chunk-UJB62HV3.js +2 -0
  45. package/dist/chunk-VEUMRDHW.js +2 -0
  46. package/dist/chunk-WCDXJGYT.js +65 -0
  47. package/dist/chunk-WTSTDJZ7.js +6 -0
  48. package/dist/chunk-XAZTIDST.js +2 -0
  49. package/dist/chunk-XVDASCN7.js +35 -0
  50. package/dist/chunk-Y7H6D2EV.js +2 -0
  51. package/dist/chunk-Y7LOQSWY.js +2 -0
  52. package/dist/chunk-YIPCV7M7.js +70 -0
  53. package/dist/chunk-ZSRXMNMK.js +5 -0
  54. package/dist/chunk-ZXKURFVB.js +56 -0
  55. package/dist/cli.js +509 -8938
  56. package/dist/{db-6F9R9e_t.d.ts → db-BSTtBG_H.d.ts} +146 -1
  57. package/dist/index.d.ts +11 -2
  58. package/dist/index.js +13 -1616
  59. package/dist/postinstall.js +4 -100
  60. package/dist/queries/affected.d.ts +1 -1
  61. package/dist/queries/affected.js +1 -8
  62. package/dist/queries/bottlenecks.d.ts +1 -1
  63. package/dist/queries/bottlenecks.js +1 -8
  64. package/dist/queries/by-kind.d.ts +1 -4
  65. package/dist/queries/by-kind.js +1 -10
  66. package/dist/queries/call-graph.d.ts +1 -1
  67. package/dist/queries/call-graph.js +1 -8
  68. package/dist/queries/change-surface.d.ts +4 -1
  69. package/dist/queries/change-surface.js +1 -8
  70. package/dist/queries/code.d.ts +1 -1
  71. package/dist/queries/code.js +1 -8
  72. package/dist/queries/complexity-hotspots.d.ts +5 -3
  73. package/dist/queries/complexity-hotspots.js +1 -8
  74. package/dist/queries/complexity.d.ts +1 -1
  75. package/dist/queries/complexity.js +1 -8
  76. package/dist/queries/convergence.d.ts +1 -1
  77. package/dist/queries/convergence.js +1 -8
  78. package/dist/queries/coupling.d.ts +1 -1
  79. package/dist/queries/coupling.js +1 -10
  80. package/dist/queries/cycles.d.ts +1 -1
  81. package/dist/queries/cycles.js +1 -8
  82. package/dist/queries/dataflow.d.ts +1 -1
  83. package/dist/queries/dataflow.js +1 -8
  84. package/dist/queries/dead.d.ts +1 -1
  85. package/dist/queries/dead.js +1 -9
  86. package/dist/queries/deep-chains.d.ts +9 -1
  87. package/dist/queries/deep-chains.js +1 -8
  88. package/dist/queries/deps.d.ts +1 -1
  89. package/dist/queries/deps.js +1 -10
  90. package/dist/queries/diff-impact.d.ts +1 -1
  91. package/dist/queries/diff-impact.js +1 -7
  92. package/dist/queries/drift.d.ts +1 -1
  93. package/dist/queries/drift.js +1 -8
  94. package/dist/queries/extract-candidates.d.ts +1 -1
  95. package/dist/queries/extract-candidates.js +1 -8
  96. package/dist/queries/fan.d.ts +1 -1
  97. package/dist/queries/fan.js +1 -14
  98. package/dist/queries/files.d.ts +1 -1
  99. package/dist/queries/files.js +1 -6
  100. package/dist/queries/health.d.ts +1 -1
  101. package/dist/queries/health.js +1 -20
  102. package/dist/queries/hierarchy.d.ts +1 -1
  103. package/dist/queries/hierarchy.js +1 -8
  104. package/dist/queries/hotspots.d.ts +1 -1
  105. package/dist/queries/hotspots.js +1 -8
  106. package/dist/queries/imports.d.ts +1 -1
  107. package/dist/queries/imports.js +1 -12
  108. package/dist/queries/index.d.ts +1 -1
  109. package/dist/queries/index.js +1 -197
  110. package/dist/queries/isolated.d.ts +1 -1
  111. package/dist/queries/isolated.js +1 -9
  112. package/dist/queries/members.d.ts +4 -1
  113. package/dist/queries/members.js +1 -8
  114. package/dist/queries/methods.d.ts +1 -1
  115. package/dist/queries/methods.js +1 -8
  116. package/dist/queries/outline.d.ts +4 -1
  117. package/dist/queries/outline.js +1 -8
  118. package/dist/queries/passthrough-candidates.d.ts +1 -1
  119. package/dist/queries/passthrough-candidates.js +1 -8
  120. package/dist/queries/redundant-reexports.d.ts +1 -1
  121. package/dist/queries/redundant-reexports.js +1 -9
  122. package/dist/queries/refs.d.ts +1 -1
  123. package/dist/queries/refs.js +1 -8
  124. package/dist/queries/similar-chains.d.ts +1 -1
  125. package/dist/queries/similar-chains.js +1 -8
  126. package/dist/queries/similar-files.d.ts +1 -1
  127. package/dist/queries/similar-files.js +1 -8
  128. package/dist/queries/similar-signatures.d.ts +1 -1
  129. package/dist/queries/similar-signatures.js +1 -8
  130. package/dist/queries/similar.d.ts +1 -1
  131. package/dist/queries/similar.js +1 -10
  132. package/dist/queries/slice.d.ts +1 -1
  133. package/dist/queries/slice.js +1 -8
  134. package/dist/queries/stale-abstractions.d.ts +15 -5
  135. package/dist/queries/stale-abstractions.js +1 -8
  136. package/dist/queries/stats.d.ts +1 -1
  137. package/dist/queries/stats.js +1 -6
  138. package/dist/queries/surface.d.ts +1 -1
  139. package/dist/queries/surface.js +1 -8
  140. package/dist/queries/symbols.d.ts +1 -1
  141. package/dist/queries/symbols.js +1 -9
  142. package/dist/queries/system.d.ts +6 -2
  143. package/dist/queries/system.js +1 -9
  144. package/dist/queries/trace.d.ts +1 -1
  145. package/dist/queries/trace.js +1 -9
  146. package/dist/queries/wrapper-candidates.d.ts +1 -1
  147. package/dist/queries/wrapper-candidates.js +1 -8
  148. package/dist/reindex-worker.js +7 -672
  149. package/package.json +20 -2
  150. package/dist/chunk-334PCFO3.js +0 -221
  151. package/dist/chunk-46ZTW4AI.js +0 -61
  152. package/dist/chunk-4TYLS5XX.js +0 -10
  153. package/dist/chunk-4YN3PE57.js +0 -124
  154. package/dist/chunk-5YB6UXQ3.js +0 -101
  155. package/dist/chunk-6PVHJ332.js +0 -44
  156. package/dist/chunk-74RFWB5T.js +0 -24
  157. package/dist/chunk-7KGTWDAX.js +0 -87
  158. package/dist/chunk-7OGXSMLY.js +0 -105
  159. package/dist/chunk-AEBM56CO.js +0 -69
  160. package/dist/chunk-B747RITP.js +0 -38
  161. package/dist/chunk-B7LDMCUS.js +0 -110
  162. package/dist/chunk-C2VSV54P.js +0 -110
  163. package/dist/chunk-DIYEUFVP.js +0 -81
  164. package/dist/chunk-E74RY6AQ.js +0 -93
  165. package/dist/chunk-FIMTTUGE.js +0 -165
  166. package/dist/chunk-FMAYH7GS.js +0 -2542
  167. package/dist/chunk-FO2CBB7U.js +0 -23
  168. package/dist/chunk-HESWGDIV.js +0 -162
  169. package/dist/chunk-HL2LXSBW.js +0 -34
  170. package/dist/chunk-HW76DVE4.js +0 -216
  171. package/dist/chunk-IC5NTO47.js +0 -53
  172. package/dist/chunk-J34HAAEQ.js +0 -59
  173. package/dist/chunk-JSXGC2EH.js +0 -151
  174. package/dist/chunk-LQXBFCP2.js +0 -87
  175. package/dist/chunk-NML6M5AS.js +0 -37
  176. package/dist/chunk-NNFP4ZRF.js +0 -72
  177. package/dist/chunk-NWXTQGUE.js +0 -49
  178. package/dist/chunk-NYZ6INK3.js +0 -95
  179. package/dist/chunk-OMVF3BHY.js +0 -84
  180. package/dist/chunk-P3VCDYMJ.js +0 -269
  181. package/dist/chunk-PGQXIAJF.js +0 -79
  182. package/dist/chunk-PKDFXASW.js +0 -76
  183. package/dist/chunk-PSK5BPFE.js +0 -82
  184. package/dist/chunk-QZ4FRB65.js +0 -341
  185. package/dist/chunk-R2QBMQQN.js +0 -185
  186. package/dist/chunk-T3ALCNCP.js +0 -113
  187. package/dist/chunk-T6UVM534.js +0 -213
  188. package/dist/chunk-U74VYTLX.js +0 -46
  189. package/dist/chunk-UIRCHPOU.js +0 -34
  190. package/dist/chunk-UNS6ZQVX.js +0 -71
  191. package/dist/chunk-VJMTX3OR.js +0 -115
  192. package/dist/chunk-XJSPWHNT.js +0 -64
  193. package/dist/chunk-XMZAC2VU.js +0 -84
  194. package/dist/chunk-Y7FKURZG.js +0 -130
  195. package/dist/chunk-YMSJCSRG.js +0 -213
  196. package/dist/chunk-YQIWS5V6.js +0 -172
  197. package/dist/chunk-ZPEI7DRJ.js +0 -66
  198. package/dist/queries/clean-signature.d.ts +0 -9
  199. package/dist/queries/clean-signature.js +0 -7
@@ -0,0 +1,6 @@
1
+ import{a as w,b as h,d as A,e as j}from"./chunk-LORWXBOO.js";import{e as $,h as B}from"./chunk-WCDXJGYT.js";import{a as z}from"./chunk-LX4H4LLG.js";import{d as v,e as M,l as x,q as D,r as L}from"./chunk-IYFZS4PV.js";import{b,c as q,f as F}from"./chunk-TINPMWJK.js";function se(t,e,r={}){let{minSimilarity:s=.4,limit:l=20}=r,o=W(t,e);if(!o)return[];if(!F(o.symbol))return[];let n=_(t,o,s);return n.length>0?n.slice(0,l):K(t,e,{minSimilarity:s,limit:l})}function _(t,e,r){let s=T(t,{minCallees:3,excludeSymbol:e.symbol}),l=A([e,...s].map(n=>n.callees)),o=[];for(let n of s){if(n.callees.size<3)continue;let i=N(e,n,l,{minSimilarity:r,requireSignificantShared:1,requireSharedCount:0});i&&o.push(i)}return o.sort((n,i)=>i.similarity-n.similarity),o}function N(t,e,r,s){let{similarity:l,significantShared:o}=j(t.callees,e.callees,r);if(l<s.minSimilarity)return null;let n=w(t.callees,e.callees).size;if(o.length<s.requireSignificantShared&&n<s.requireSharedCount)return null;let i=o.length>0?o:[...w(t.callees,e.callees)];return{symbolA:t.symbol,shortNameA:b(t.symbol),fileA:t.file,symbolB:e.symbol,shortNameB:b(e.symbol),fileB:e.file,similarity:l,sharedCallees:i.map(b),uniqueToA:[...h(t.callees,e.callees)].map(b),uniqueToB:[...h(e.callees,t.callees)].map(b)}}function le(t,e={}){let{minSimilarity:r=.5,limit:s=20,scope:l,minCallees:o=4,crossFileOnly:n=!1}=e,i=T(t,{minCallees:o,scope:l}),c=A(i.map(a=>a.callees)),u=new Map;for(let a of i)for(let m of a.callees)u.set(m,(u.get(m)??0)+1);let f=Math.max(8,Math.ceil(Math.sqrt(i.length))),S=new Map;for(let a=0;a<i.length;a+=1)for(let m of i[a].callees){if((u.get(m)??0)>f)continue;let g=S.get(m);g||(g=[],S.set(m,g)),g.push(a)}let C=[],R=new Set;e:for(let a=0;a<i.length;a+=1){let m=i[a],g=new Set;for(let k of m.callees){let y=S.get(k);if(y)for(let p of y)p>a&&g.add(p)}for(let k of g){let y=`${a}|${k}`;if(R.has(y))continue;R.add(y);let p=i[k];if(n&&m.file===p.file)continue;if(m.paramCount>=0&&p.paramCount>=0){let O=Math.abs(m.paramCount-p.paramCount),Z=Math.max(2,Math.ceil(Math.max(m.paramCount,p.paramCount)*.5));if(O>Z)continue}let P=N(m,p,c,{minSimilarity:r,requireSignificantShared:2,requireSharedCount:4});if(P&&(C.push(P),C.length>s*5))break e}}return C.sort((a,m)=>m.similarity-a.similarity),C.slice(0,s)}function W(t,e){let r=z(t,e);if(!r)return null;let s=$(t,r);return{symbol:r.symbol,file:r.relativePath,callees:new Set(s.map(l=>l.symbol)),paramCount:x(t,r.relativePath,r.startLine,r.endLine)?.paramCount??-1}}function T(t,e){let{minCallees:r,scope:s,excludeSymbol:l}=e,o=L(t,s).filter(i=>!t.isIgnored(i.relativePath)).filter(i=>i.isFunctionLike).filter(i=>l===void 0||i.symbol!==l).filter(i=>i.endLine-i.startLine+1>=5).filter(i=>!M(t,i.relativePath,i.startLine)),n=B(t,o);return o.map(i=>({symbol:i.symbol,file:i.relativePath,callees:new Set((n.get(i.symbolId)??[]).map(c=>c.symbol)),paramCount:x(t,i.relativePath,i.startLine,i.endLine)?.paramCount??-1})).filter(i=>i.callees.size>=r)}function K(t,e,r){let s=U(t,e);if(!s||s.tokens.size<3)return[];let l=r.minSimilarity>=.5?r.minSimilarity:.3,o=[];for(let n of H(t)){if(n.symbol===s.symbol||n.tokens.size<3)continue;let i=w(s.tokens,n.tokens);if(i.size<2)continue;let c=new Set([...s.tokens,...n.tokens]),u=c.size>0?i.size/c.size:0;u<l||o.push({symbolA:s.symbol,shortNameA:b(s.symbol),fileA:s.file,symbolB:n.symbol,shortNameB:b(n.symbol),fileB:n.file,similarity:u,sharedCallees:[...i].sort(),uniqueToA:[...h(s.tokens,n.tokens)].sort(),uniqueToB:[...h(n.tokens,s.tokens)].sort()})}return o.sort((n,i)=>i.similarity-n.similarity||n.shortNameB.localeCompare(i.shortNameB)),o.slice(0,r.limit)}function U(t,e){let r=z(t,e);if(!r||!F(r.symbol))return null;let s=G(t,r);return s?{symbol:r.symbol,file:r.relativePath,tokens:s}:null}function G(t,e){let r=q(e.symbol),s=E(t,e.relativePath,e.startLine,e.endLine,r),l=I(s,r);return l.size>0?l:null}function H(t){return D(t).filter(e=>e.isFunctionLike).map(e=>({symbol:e.symbol,file:e.relativePath,tokens:I(E(t,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)})).filter(e=>e.tokens.size>0)}function E(t,e,r,s,l){let o=v(t,e);if(!o)return"";let n=o.split(`
2
+ `);if(s>=r&&s-r<=12)return n.slice(r,s+1).join(`
3
+ `);let i=[new RegExp(`\\bdef\\s+${d(l)}\\b`),new RegExp(`\\bfun\\s+${d(l)}\\b`),new RegExp(`\\bfn\\s+${d(l)}\\b`),new RegExp(`\\bfunction\\s+${d(l)}\\b`),new RegExp(`\\b${d(l)}\\s*\\(`)],c=n.findIndex(u=>i.some(f=>f.test(u)));if(c>=0){let u=c;for(let f=c+1;f<n.length&&f<=c+8;f++){let S=n[f]??"";if(f>c&&Q(S)||(u=f,S.trim()===""&&f>c+1))break}return n.slice(c,u+1).join(`
4
+ `)}return n.slice(r,Math.min(n.length,r+8)).join(`
5
+ `)}function I(t,e){if(!t)return new Set;let r=new Set(["public","private","protected","final","static","class","def","fun","fn","function","return","string","bool","boolean","void","unit","self","this","new","const","let","var","end","pub"]),s=J(e),o=t.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(n=>n.trim()).filter(n=>n.length>1).filter(n=>!r.has(n)).filter(n=>!s.has(n));return new Set(o)}function J(t){return new Set(t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(e=>e.toLowerCase()).filter(e=>e.length>1))}function Q(t){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(t)}function d(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{se as a,le as b};
6
+ //# sourceMappingURL=chunk-K6GBKEQE.js.map
@@ -0,0 +1,12 @@
1
+ import{c as M,d as O,e as T,f as j}from"./chunk-GNXRLK5G.js";import{a as L}from"./chunk-VEUMRDHW.js";import{a as I}from"./chunk-ZSRXMNMK.js";import{c as F}from"./chunk-WCDXJGYT.js";import{f as b,g as P,h as x,k,m as A,q as D}from"./chunk-IYFZS4PV.js";import{b as C,f as N,g as R}from"./chunk-TINPMWJK.js";var S=new WeakMap;function $(n,u){let r=b(u);return r==="rust"?G(n,u):r==="typescript"||r==="tsx"||r==="javascript"?J(n,u):[]}var U=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function J(n,u){let r=x(n,u);if(!r)return[];let d=S.get(r);if(d)return d;let o=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(u)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(u),c=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(u),f=!1,s=r.rootNode;for(let i of s.namedChildren){if(i.type!=="expression_statement")continue;let e=i.namedChild(0);if(!e||e.type!=="call_expression")continue;let a=e.namedChild(0);if(!a)continue;let l=a.type==="member_expression"?a.namedChild(a.namedChildCount-1)?.text:a.text;if(l&&U.has(l)){f=!0;break}}let m=[];f&&m.push({startLine:0,endLine:s.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(o||c)&&m.push({startLine:0,endLine:s.endPosition.row,reason:o?"Next.js / Remix route file":"Vite/Vue route component"});for(let i of s.namedChildren){let e=null,a=null;if(i.type==="function_declaration")e=i.namedChild(0)?.text??null,a=i;else if(i.type==="export_statement"){let l=i.namedChild(0);l?.type==="function_declaration"&&(e=l.namedChild(0)?.text??null,a=l)}else if(i.type==="lexical_declaration"){let l=i.namedChild(0);if(l?.type==="variable_declarator"){let h=l.namedChild(0)?.text,y=l.namedChild(1);h&&(y?.type==="arrow_function"||y?.type==="function_expression")&&(e=h,a=l)}}e&&/^use[A-Z]/.test(e)&&a&&m.push({startLine:a.startPosition.row,endLine:a.endPosition.row,reason:"React custom hook (use*)"})}return m.push(...W(r,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),S.set(r,m),m}var q=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function z(n){return q.test(n)}function W(n,u,r){let d=[],o=c=>{if(u.has(c.type)&&c.parent){let s=c.parent.children,m=-1;for(let i=0;i<s.length;i+=1)if(s[i].startIndex===c.startIndex&&s[i].type===c.type){m=i;break}if(m>0)for(let i=m-1;i>=0;i-=1){let e=s[i];if(r.has(e.type)){if(z(e.text)){d.push({startLine:c.startPosition.row,endLine:c.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(e.type==="attribute_item"||e.type==="inner_attribute_item"))break}}for(let f of c.namedChildren)o(f)};return o(n.rootNode),d}function G(n,u){let r=x(n,u);if(!r)return[];let d=S.get(r);if(d)return d;let o=[],c=e=>{let a=e.parent;if(!a)return[];let l=a.children,h=-1;for(let p=0;p<l.length;p+=1)if(l[p].startIndex===e.startIndex&&l[p].type===e.type){h=p;break}if(h<=0)return[];let y=[];for(let p=h-1;p>=0;p-=1){let g=l[p];if(g.type==="attribute_item"||g.type==="inner_attribute_item")y.push(g.text);else{if(g.type==="line_comment"||g.type==="block_comment")continue;break}}return y},f=e=>/#\[\s*tauri::command\b/.test(e)?"#[tauri::command]":/#\[\s*command\b/.test(e)?"#[command]":/#\[\s*test\b/.test(e)?"#[test]":/#\[\s*bench\b/.test(e)?"#[bench]":/#\[\s*tokio::test\b/.test(e)?"#[tokio::test]":/#\[\s*async_std::test\b/.test(e)?"#[async_std::test]":/#\[\s*wasm_bindgen\b/.test(e)?"#[wasm_bindgen]":/#\[\s*no_mangle\b/.test(e)?"#[no_mangle]":/#\[\s*napi\b/.test(e)?"#[napi]":/#\[\s*pyfunction\b/.test(e)?"#[pyfunction]":/#\[\s*pymethod\b/.test(e)?"#[pymethod]":/#\[\s*pyo3\b/.test(e)?"#[pyo3]":/#\[\s*cfg\s*\(\s*test\s*\)/.test(e)?"#[cfg(test)]":/#\[\s*doc\s*\(\s*hidden\s*\)/.test(e)?"#[doc(hidden)]":null,s=e=>/#\[\s*derive\s*\(/.test(e)?/\bSerialize\b/.test(e)||/\bDeserialize\b/.test(e)||/\bFromRow\b/.test(e)||/\bDeriveEntityModel\b/.test(e)||/\bIntoSchema\b/.test(e)||/\bToSchema\b/.test(e)||/\bDeriveValueType\b/.test(e)||/\bsqlx::FromRow\b/.test(e):!1,m=e=>/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e),i=(e,a,l)=>{let h=a,y=l;if(e.type==="impl_item"&&e.namedChildren.filter(g=>g.type==="type_identifier").length>=2&&(y=!0),e.type==="function_item"||e.type==="function_signature_item"){let p=c(e),g=null;l?g="trait impl method (dynamic dispatch)":a&&(g="inside #[cfg(test)] mod");for(let t of p){let _=f(t);if(_){g=_;break}if(m(t)){g="#[allow(dead_code)]";break}}g&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:g})}else if(e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"){let p=c(e),g=p.some(s),t=p.some(m),_=e.namedChildren.find(E=>E.type==="type_identifier")?.text;g&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:_}),t&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:_}),a&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:_})}else e.type==="mod_item"&&c(e).some(g=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(g))&&(h=!0);for(let p of e.namedChildren)i(p,h,y)};return i(r.rootNode,!1,!1),o.push(...W(r,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),S.set(r,o),o}var K=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function H(n,u){return k(n,u,X,()=>new Set,(r,d,o)=>{if(!(d!=="typescript"&&d!=="tsx"&&d!=="javascript"))for(let c of r.rootNode.descendantsOfType("call_expression")){let f=c.namedChild(0);if(!f)continue;let s=A(f);if(!s||!K.has(s))continue;let m=c.namedChildren.find(a=>a.type==="arguments");if(!m)continue;let i=m.namedChild(0);if(!i||i.type!=="string")continue;let e=i.namedChildren.find(a=>a.type==="string_fragment");e&&o.add(e.text)}})??new Set}var X=new WeakMap;function fe(n,u={}){let{scope:r,minLoc:d=1,includeTests:o=!1,skipBarrels:c=!1,includeMembers:f=!1}=u,s=c?new Set(M(n)):new Set,m=n.all(`SELECT
2
+ m.symbol_id,
3
+ d.relative_path,
4
+ COUNT(*) AS ref_count
5
+ FROM mentions m
6
+ JOIN chunks c ON m.chunk_id = c.id
7
+ JOIN documents d ON c.document_id = d.id
8
+ WHERE m.role != 1
9
+ ${n.pathExclusionsFor("d")}
10
+ GROUP BY m.symbol_id, d.relative_path`),i=new Map;for(let t of m){if(n.isIgnored(t.relative_path)||s.has(t.relative_path))continue;let _=i.get(t.symbol_id);_||(_=new Map,i.set(t.symbol_id,_)),_.set(t.relative_path,t.ref_count)}Y(n,i,s);let e=Z(n),l=D(n,{scope:r}).filter(t=>!n.isIgnored(t.relativePath)).filter(t=>!R(t.symbol)).filter(t=>w(t.symbol)).filter(t=>t.isFunctionLike||!t.enclosingSymbol||!w(t.enclosingSymbol)).filter(t=>o||Q(t.relativePath)).filter(t=>o||!e(t.relativePath,t.startLine,t.parentTypeName)).filter(t=>f||w(t.symbol)).filter(t=>t.endLine-t.startLine+1>=d).map(t=>{let _=i.get(t.symbolId)??new Map,E=_.get(t.relativePath)??0,v=0;for(let[B,V]of _)B!==t.relativePath&&(v+=V);return{relative_path:t.relativePath,start_line:t.startLine,end_line:t.endLine,loc:t.endLine-t.startLine+1,symbol:t.symbol,same_file_refs:E,cross_file_refs:v}}).filter(t=>t.cross_file_refs===0).sort((t,_)=>_.loc-t.loc||t.relative_path.localeCompare(_.relative_path)||t.start_line-_.start_line),h=0,y=0,p=0,g=l.filter(t=>!n.isIgnored(t.relative_path)).filter(t=>!O(n,t.relative_path)).map(t=>{let _=t.same_file_refs===0?"dead-code":"file-internal";return _==="dead-code"?h++:y++,p+=t.loc,{relativePath:t.relative_path,startLine:t.start_line,endLine:t.end_line,loc:t.loc,symbol:t.symbol,shortName:C(t.symbol),sameFileRefs:t.same_file_refs,kind:_}});return{symbols:g,totalCount:g.length,deadCodeCount:h,fileInternalCount:y,totalLoc:p}}function Y(n,u,r){let d=n.all(`SELECT relative_path FROM documents
11
+ WHERE 1 = 1 ${n.pathExclusionsFor("documents")}`),o=new Set(d.map(s=>s.relative_path)),c=new Set(I(n));for(let s of o)c.add(s);let f=(s,m,i)=>{if(i<=0)return;let e=u.get(s);e||(e=new Map,u.set(s,e)),e.set(m,(e.get(m)??0)+i)};for(let s of c){if(!b(s)&&!P(s)||n.isIgnored(s)||r.has(s))continue;let m=F(n,s);for(let[e,a]of m){let l=L(n,s,e);if(l.length!==0)for(let h of l){let y=h.relativePath===s?Math.max(0,a.length-1):a.length;f(h.symbolId,s,y)}}let i=H(n,s);for(let e of i){let a=L(n,s,e);for(let l of a)l.relativePath!==s&&f(l.symbolId,s,1)}}}function Z(n){let u=new Map,r=d=>{let o=u.get(d);if(o)return o;let c=$(n,d);return o={ranges:c.map(f=>({startLine:f.startLine,endLine:f.endLine})),containers:new Set(c.map(f=>f.containerName).filter(f=>!!f))},u.set(d,o),o};return(d,o,c)=>{let f=r(d);for(let s of f.ranges)if(o>=s.startLine&&o<=s.endLine)return!0;return!!(c&&f.containers.has(c))}}function Q(n){return[...new Set([...T,...j])].every(r=>!ee(n,r))}function ee(n,u){return new RegExp(`^${u.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(n)}function w(n){return N(n)||n.endsWith("().")||n.endsWith(".")}export{fe as a};
12
+ //# sourceMappingURL=chunk-KO7YJRWP.js.map
@@ -0,0 +1,4 @@
1
+ function i(e){return/[*?]/.test(e)?e.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_"):`%${e}%`}function l(e,r){let a=i(r);return e.all(`SELECT relative_path FROM documents
2
+ WHERE relative_path LIKE ?
3
+ ORDER BY relative_path`,a).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path}))}export{l as a};
4
+ //# sourceMappingURL=chunk-KYT47WU2.js.map
@@ -0,0 +1,2 @@
1
+ function m(n,e){let t=new Set;for(let r of n)e.has(r)&&t.add(r);return t}function M(n,e){let t=new Set;for(let r of n)e.has(r)||t.add(r);return t}function w(n,e){if(n.size===0&&e.size===0)return 0;let t=0;for(let o of n)e.has(o)&&(t+=1);let r=n.size+e.size-t;return r===0?0:t/r}function x(n){let e=n.length;if(e===0)return new Map;let t=new Map;for(let o of n)for(let s of o)t.set(s,(t.get(s)??0)+1);let r=new Map;for(let[o,s]of t)r.set(o,Math.log(e/s));return r}function p(n){let e=[...n.values()].sort((r,o)=>r-o);if(e.length===0)return 0;let t=Math.floor(e.length/2);return e.length%2===0?(e[t-1]+e[t])/2:e[t]}function v(n,e,t){let r=m(n,e);if(r.size===0)return{similarity:0,significantShared:[],trivialShared:[]};let o=0,s=0,T=0,l=new Set([...n,...e]);for(let i of l){let a=t.get(i)??0,f=n.has(i)?a:0,u=e.has(i)?a:0;o+=f*u,s+=f*f,T+=u*u}let h=Math.sqrt(s)*Math.sqrt(T),g=h>0?o/h:0,S=p(t),c=[],d=[];for(let i of r)(t.get(i)??0)>=S?c.push(i):d.push(i);return c.sort((i,a)=>(t.get(a)??0)-(t.get(i)??0)),{similarity:g,significantShared:c,trivialShared:d}}export{m as a,M as b,w as c,x as d,v as e};
2
+ //# sourceMappingURL=chunk-LORWXBOO.js.map
@@ -0,0 +1,89 @@
1
+ import{u as p}from"./chunk-IYFZS4PV.js";import{b as N,c as E,f as R,g as I}from"./chunk-TINPMWJK.js";function T(e,t){let n=v(e,t.trim());if(n)return n;let i=t.match(/^(.+):(\d+)-(\d+)$/);if(i){let[,c,_,h]=i,u=Math.max(0,parseInt(_,10)-1),f=Math.max(u,parseInt(h,10)-1),m=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
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 der.start_line <= ? AND der.end_line >= ?
7
+ ${e.pathExclusionsFor("d")}
8
+ ORDER BY (der.end_line - der.start_line) ASC
9
+ LIMIT 1`,`%${c}%`,u,f);if(m||(m=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
10
+ FROM global_symbols gs
11
+ JOIN mentions m ON m.symbol_id = gs.id
12
+ JOIN chunks c ON m.chunk_id = c.id
13
+ JOIN documents d ON c.document_id = d.id
14
+ WHERE m.role = 1
15
+ AND d.relative_path LIKE ?
16
+ AND c.start_line <= ? AND c.end_line >= ?
17
+ ${e.pathExclusionsFor("d")}
18
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
19
+ ORDER BY (MAX(c.end_line) - MIN(c.start_line)) ASC
20
+ LIMIT 1`,`%${c}%`,u,f)),m&&!e.isIgnored(m.relative_path))return p(e,m)}let d=M(t),o=w(t),l=$(e,o),a=x(l,t,d);if(a&&!e.isIgnored(a.relative_path))return p(e,a);let r=null;for(let c of l){if(e.isIgnored(c.relative_path))continue;let _=D(c,t,d,o);_<=0||(!r||_>r.score)&&(r={row:c,score:_})}return r?p(e,r.row):null}function v(e,t){let i=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
21
+ FROM global_symbols gs
22
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
23
+ JOIN documents d ON der.document_id = d.id
24
+ WHERE gs.symbol = ?
25
+ ${e.pathExclusionsFor("d")}
26
+ ORDER BY d.relative_path, der.start_line
27
+ LIMIT 1`,t)??e.get(`SELECT
28
+ gs.id,
29
+ gs.symbol,
30
+ c.document_id,
31
+ MIN(c.start_line) AS start_line,
32
+ MAX(c.end_line) AS end_line,
33
+ d.relative_path
34
+ FROM global_symbols gs
35
+ JOIN mentions m ON m.symbol_id = gs.id
36
+ JOIN chunks c ON m.chunk_id = c.id
37
+ JOIN documents d ON c.document_id = d.id
38
+ WHERE gs.symbol = ?
39
+ AND m.role = 1
40
+ ${e.pathExclusionsFor("d")}
41
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
42
+ ORDER BY d.relative_path, start_line
43
+ LIMIT 1`,t);return!i||e.isIgnored(i.relative_path)?null:p(e,i)}function W(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=A(e,t.symbolId)[0];return n?p(e,n):null}function A(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
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.id = ?
48
+ ORDER BY der.start_line, der.end_line`,t);return n.length>0?n:e.all(`SELECT
49
+ gs.id,
50
+ gs.symbol,
51
+ c.document_id,
52
+ MIN(c.start_line) AS start_line,
53
+ MAX(c.end_line) AS end_line,
54
+ d.relative_path,
55
+ gs.display_name
56
+ FROM global_symbols gs
57
+ JOIN mentions m ON m.symbol_id = gs.id
58
+ JOIN chunks c ON m.chunk_id = c.id
59
+ JOIN documents d ON c.document_id = d.id
60
+ WHERE gs.id = ?
61
+ AND m.role = 1
62
+ ${e.pathExclusionsFor("d")}
63
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name
64
+ ORDER BY start_line, end_line`,t)}function $(e,t){let n=t.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),i=t.flatMap(o=>{let l=`%${o}%`;return[l,l,l]}),d=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name
65
+ FROM global_symbols gs
66
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
67
+ JOIN documents d ON der.document_id = d.id
68
+ WHERE ${n.join(`
69
+ AND `)}
70
+ ${e.pathExclusionsFor("d")}
71
+ LIMIT 200`,...i);return d.length>0?d: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
+ FROM global_symbols gs
80
+ JOIN mentions m ON m.symbol_id = gs.id
81
+ JOIN chunks c ON m.chunk_id = c.id
82
+ JOIN documents d ON c.document_id = d.id
83
+ WHERE m.role = 1
84
+ AND ${n.join(`
85
+ AND `)}
86
+ ${e.pathExclusionsFor("d")}
87
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name
88
+ LIMIT 200`,...i)}function D(e,t,n,i){let d=t.trim(),o=n,l=o.replace(/\(\)$/,""),a=t.toLowerCase(),r=n.toLowerCase(),c=r.replace(/\(\)$/,""),_=e.symbol,h=N(e.symbol),u=E(e.symbol),f=e.display_name??"",m=e.symbol.toLowerCase(),y=h.toLowerCase(),S=u.toLowerCase(),O=f.toLowerCase(),g=e.relative_path.toLowerCase(),L=/[/:.]/.test(n),s=0;return(_===d||_===o)&&(s+=1150),(h===d||h===o)&&(s+=1100),f===l&&(s+=980),u===l&&(s+=960),(`${u}()`===d||`${u}()`===o)&&(s+=955),(m===a||m===r)&&(s+=1e3),(y===a||y===r)&&(s+=950),(g===a||g===r)&&(s+=925),(g.endsWith(`/${r}`)||g.endsWith(`/${a}`))&&(s+=875),O===c&&(s+=850),S===c&&(s+=825),(`${S}()`===a||`${S}()`===r)&&(s+=820),(y.endsWith(`:${r}`)||y.endsWith(`:${c}`)||y.endsWith(`:${c}()`))&&(s+=800),m.includes(r)&&(s+=120),y.includes(r)&&(s+=140),g.includes(r)&&(s+=140),O.includes(r)&&(s+=110),i.every(C=>{let b=C.toLowerCase();return m.includes(b)||y.includes(b)||g.includes(b)||O.includes(b)})&&(s+=100+i.length*15),R(e.symbol)&&S===c&&(s+=60),!L&&I(e.symbol)&&(s-=160),s-=Math.min(50,Math.max(0,e.end_line-e.start_line)),s}function M(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function w(e){let t=M(e),n=t.split(/[^A-Za-z0-9_]+/).map(i=>i.trim()).filter(i=>i.length>0);return n.length>0?[...new Set(n)]:[t]}function x(e,t,n){let i=t.trim(),d=e.filter(o=>{let l=N(o.symbol),a=(o.display_name??"").trim();return o.symbol===i||l===i||l===n||a===i||a===n||`${a}()`===i||o.relative_path===i});return d.length===0?null:(d.sort((o,l)=>o.end_line-o.start_line-(l.end_line-l.start_line)||o.relative_path.localeCompare(l.relative_path)||o.symbol.localeCompare(l.symbol)),d[0]??null)}export{T as a,v as b,W as c};
89
+ //# sourceMappingURL=chunk-LX4H4LLG.js.map
@@ -0,0 +1,2 @@
1
+ function o(t){let e=t.get("SELECT COUNT(*) as c FROM documents").c,s=t.get("SELECT COUNT(*) as c FROM global_symbols").c,c=t.get("SELECT COUNT(*) as c FROM mentions WHERE role = 1").c,n=t.get("SELECT COUNT(*) as c FROM mentions WHERE role != 1").c;return{documents:e,symbols:s,definitions:c,references:n,indexSizeBytes:t.sizeBytes(),lastBuilt:t.lastModified()}}export{o as a};
2
+ //# sourceMappingURL=chunk-N3Z2SJCR.js.map
@@ -0,0 +1,25 @@
1
+ import{f as d}from"./chunk-WCDXJGYT.js";import{q as l}from"./chunk-IYFZS4PV.js";import{b as r}from"./chunk-TINPMWJK.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
2
+ gs.symbol,
3
+ COUNT(*) AS ref_count,
4
+ COUNT(DISTINCT ref_d.id) AS file_count,
5
+ def_d.relative_path AS defined_in
6
+ FROM mentions m
7
+ JOIN chunks c ON m.chunk_id = c.id
8
+ JOIN documents ref_d ON c.document_id = ref_d.id
9
+ JOIN global_symbols gs ON m.symbol_id = gs.id
10
+ JOIN (
11
+ SELECT m2.symbol_id, c2.document_id
12
+ FROM mentions m2
13
+ JOIN chunks c2 ON m2.chunk_id = c2.id
14
+ WHERE m2.role = 1
15
+ GROUP BY m2.symbol_id
16
+ ) sym_def ON sym_def.symbol_id = gs.id
17
+ JOIN documents def_d ON sym_def.document_id = def_d.id
18
+ WHERE m.role != 1
19
+ ${o.pathExclusionsFor("def_d")}
20
+ ${o.symbolNoiseFor("gs")}
21
+ ${n}
22
+ GROUP BY gs.id
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-NTDA4A2D.js.map
@@ -0,0 +1,24 @@
1
+ import{b as g}from"./chunk-TINPMWJK.js";import{execFileSync as r}from"child_process";function N(e,a={}){let{base:m="HEAD"}=a,o;try{o=b(e.config.projectRoot,m)}catch{return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:"Unable to compute git diff."}}}if(o.length===0)return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:"No changed files found."}};let i=[],n=[];for(let t of o){let s=e.get(`SELECT id, relative_path FROM documents
2
+ WHERE relative_path LIKE ?
3
+ LIMIT 1`,`%${t}`);s&&!e.isIgnored(s.relative_path)&&(i.push(s.relative_path),n.push(s.id))}if(n.length===0)return{changedFiles:o,changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:o.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}};let u=n.map(()=>"?").join(","),p=e.all(`SELECT DISTINCT gs.id AS symbol_id, gs.symbol, d.relative_path
4
+ FROM mentions m
5
+ JOIN chunks c ON m.chunk_id = c.id
6
+ JOIN global_symbols gs ON m.symbol_id = gs.id
7
+ JOIN documents d ON c.document_id = d.id
8
+ WHERE m.role = 1
9
+ AND c.document_id IN (${u})
10
+ ${e.symbolNoiseFor("gs")}
11
+ ORDER BY d.relative_path`,...n),d=[],l=new Map;for(let t of p){let _=e.get(`SELECT COUNT(DISTINCT c.document_id) AS fan_in
12
+ FROM mentions m
13
+ JOIN chunks c ON m.chunk_id = c.id
14
+ WHERE m.symbol_id = ?
15
+ AND m.role != 1`,t.symbol_id)?.fan_in??0,h=g(t.symbol);d.push({symbol:t.symbol,shortName:h,file:t.relative_path,fanIn:_});let y=e.all(`SELECT DISTINCT ref_d.relative_path
16
+ FROM mentions m
17
+ JOIN chunks c ON m.chunk_id = c.id
18
+ JOIN documents ref_d ON c.document_id = ref_d.id
19
+ WHERE m.symbol_id = ?
20
+ AND m.role != 1
21
+ AND ref_d.relative_path NOT IN (${i.map(()=>"?").join(",")})
22
+ ${e.pathExclusionsFor("ref_d")}`,t.symbol_id,...i);for(let c of y)e.isIgnored(c.relative_path)||(l.has(c.relative_path)||l.set(c.relative_path,new Set),l.get(c.relative_path).add(h))}let f=[...l.entries()].map(([t,s])=>({file:t,consumedSymbols:s.size})).sort((t,s)=>s.consumedSymbols-t.consumedSymbols);return{changedFiles:i,changedSymbols:d,affectedConsumers:f,summary:{totalChangedFiles:i.length,totalChangedSymbols:d.length,totalAffectedFiles:f.length}}}function b(e,a){let m=r("git",["diff","--name-only",a],{encoding:"utf-8",cwd:e,timeout:1e4}),o=r("git",["diff","--name-only","--cached",a],{encoding:"utf-8",cwd:e,timeout:1e4}),i=r("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:1e4});return[...new Set([m,o,i].flatMap(n=>n.split(`
23
+ `)).map(n=>n.trim()).filter(n=>n.length>0))]}export{N as a};
24
+ //# sourceMappingURL=chunk-NXMYYHDO.js.map
@@ -0,0 +1,7 @@
1
+ import{b as m}from"./chunk-VEUMRDHW.js";import{g}from"./chunk-WCDXJGYT.js";import{a as R}from"./chunk-LX4H4LLG.js";import{d as h}from"./chunk-IYFZS4PV.js";import{f as u}from"./chunk-TINPMWJK.js";function $(t,a){let e=R(t,a);if(!e)return[];let i=!u(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],r=m(t,e),l=(r.length>0?r:g(t,e)).filter(n=>!t.isIgnored(n.file)).map(n=>({relativePath:n.file,line:n.line})),c=S(t,e),o=new Set,f=[];for(let n of[...i,...l,...c]){let p=`${n.relativePath}:${n.line}`;o.has(p)||(o.add(p),f.push(n))}return f}function S(t,a){if(!a.relativePath.endsWith(".rb"))return[];let e=d(a.symbol);if(e.length===0)return[];let s=t.all(`SELECT relative_path
2
+ FROM documents
3
+ WHERE relative_path LIKE '%.rb'
4
+ ${t.pathExclusionsFor("documents")}
5
+ ORDER BY relative_path`),i=[];for(let r of s){if(t.isIgnored(r.relative_path))continue;let l=h(t,r.relative_path);if(!l)continue;let c=l.split(`
6
+ `);for(let o=0;o<c.length;o++){let f=c[o]??"";e.some(n=>new RegExp(`@${n}\\b|\\b${n}:`).test(f))&&i.push({relativePath:r.relative_path,line:o})}}return i}function d(t){let e=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),s=e.split("_").filter(Boolean),i=new Set;return e&&i.add(e),s.length>=1&&i.add(s[s.length-1]),s.length>=2&&i.add(s.slice(-2).join("_")),[...i]}export{$ as a};
7
+ //# sourceMappingURL=chunk-PZ6ESKRH.js.map
@@ -0,0 +1,6 @@
1
+ import{a as f}from"./chunk-WTSTDJZ7.js";import{a as p}from"./chunk-LX4H4LLG.js";import{b as g}from"./chunk-TINPMWJK.js";import{readFileSync as v}from"fs";import{join as d}from"path";function _(e,u,l={}){let{context:a=0}=l,r=u.match(/^(.+\.\w+):(\d+)-(\d+)$/);if(r)return y(e,r[1],parseInt(r[2],10),parseInt(r[3],10),a);let t=p(e,u);if(!t)return null;let n=e.get("SELECT language FROM documents WHERE relative_path = ?",t.relativePath),m=d(e.config.projectRoot,t.relativePath),o;try{o=v(m,"utf-8")}catch{return null}let i=o.split(`
2
+ `),s=Math.max(0,t.startLine-a),c=Math.min(i.length-1,t.endLine+a),h=i.slice(s,c+1).join(`
3
+ `);return{symbol:t.symbol,shortName:g(t.symbol),relativePath:t.relativePath,startLine:s,endLine:c,language:n?.language??null,source:h}}function y(e,u,l,a,r){let t=f(e,u);if(!t)return null;let n=e.get("SELECT relative_path, language FROM documents WHERE relative_path = ?",t);if(!n)return null;let m=d(e.config.projectRoot,n.relative_path),o;try{o=v(m,"utf-8")}catch{return null}let i=o.split(`
4
+ `),s=Math.max(0,l-1-r),c=Math.min(i.length-1,a-1+r),h=i.slice(s,c+1).join(`
5
+ `);return{symbol:`${n.relative_path}:${l}-${a}`,shortName:`${n.relative_path}:${l}-${a}`,relativePath:n.relative_path,startLine:s,endLine:c,language:n.language,source:h}}export{_ as a};
6
+ //# sourceMappingURL=chunk-QXE6EDY2.js.map
@@ -0,0 +1,5 @@
1
+ import{c as I}from"./chunk-VEUMRDHW.js";import{j as A}from"./chunk-WCDXJGYT.js";import{d as M}from"./chunk-BQ3INTYT.js";import{a as P,d,e as x,f as F,h as w,j as D,r as C}from"./chunk-IYFZS4PV.js";import{b as L,c as b}from"./chunk-TINPMWJK.js";function te(t,n){let{scope:s,minLoc:i=3,limit:o=30,includeLowConfidence:a=!1}=n??{},c=k(t,s),r=C(t,s).filter(e=>e.isTypeLike&&T(e)>=i).filter(e=>!t.isIgnored(e.relativePath)).filter(e=>!x(t,e.relativePath,e.startLine)),l=A(t,r),u=I(t,r),f=G(l,u),g=new Map;for(let e of r){let m=g.get(e.relativePath);m||(m=new Map,g.set(e.relativePath,m));let p=b(e.symbol);p&&m.set(p,e)}return r.map(e=>{let p=[...f.get(e.symbolId)??new Set].filter(v=>v!==e.relativePath&&!t.isIgnored(v)),{realConsumers:h,barrelConsumers:S}=E(t,e.relativePath,e.symbol,p),_=$(t,e,f,g);return{definition:e,realConsumers:h,barrelConsumers:S,transitivelyReachable:_}}).filter(e=>!e.transitivelyReachable).filter(e=>e.realConsumers.length<=1).filter(e=>!(e.realConsumers.length===0&&e.barrelConsumers>0)).filter(e=>R(e.definition,e.realConsumers.length,c)).map(e=>{let m=B(t,e.definition.relativePath,e.definition.startLine),p=W(t,e.definition),{confidence:h,reason:S}=z(e.realConsumers.length,m,p);return{symbol:e.definition.symbol,shortName:L(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:T(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:m,definerUsesType:p,confidence:h,reason:S}}).filter(e=>a||e.confidence!=="low").sort((e,m)=>{let p={high:0,medium:1,low:2};return p[e.confidence]-p[m.confidence]||m.loc-e.loc||e.file.localeCompare(m.file)||e.startLine-m.startLine}).slice(0,o)}function k(t,n){return new Set(C(t,n).filter(s=>s.isFunctionLike).map(s=>s.relativePath))}function R(t,n,s){return!(((t.relativePath.split("/").pop()??"").includes("types")||t.relativePath.includes("/types/"))&&n>0||n===0&&s.has(t.relativePath))}function E(t,n,s,i){let o=[],a=0,c=b(s);for(let r of i)j(t,r,n,c)||U(t,r,c)?a++:o.push(r);return{realConsumers:o,barrelConsumers:a}}function $(t,n,s,i){let o=D(t,n.relativePath),a=b(n.symbol);if(!a)return!1;let c=o.get(a);if(!c||c.size===0)return!1;let r=i.get(n.relativePath);if(!r)return!1;for(let l of c){let u=r.get(l);if(!u)continue;let f=s.get(u.symbolId);if(f){for(let g of f)if(g!==n.relativePath&&!t.isIgnored(g))return!0}}return!1}var N=P("stale-abs-file-usage");function U(t,n,s){if(!s)return!1;let i=F(n);if(!i)return!1;let o=N.get(t,n,()=>O(t,n,i));return o.importedLeaves.has(s)&&!o.usedLeaves.has(s)}function O(t,n,s){let i=new Set,o=new Set,a=w(t,n);if(!a)return{importedLeaves:i,usedLeaves:o};let c=s==="rust"?new Set(["use_declaration"]):s==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),r=(l,u)=>{let f=u||c.has(l.type);(l.type==="identifier"||l.type==="type_identifier"||l.type==="property_identifier"||l.type==="field_identifier")&&(f?i.add(l.text):o.add(l.text));for(let g of l.children)r(g,f)};return r(a.rootNode,!1),{importedLeaves:i,usedLeaves:o}}function j(t,n,s,i){if(!i)return!1;let o=d(t,n);if(!o)return!1;let a=M(t,n);if(a.length===0)return!1;let c=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${c}\\b`),l=o.split(`
2
+ `),u=0;for(let f=0;f<l.length;f++){if(!r.test(l[f]??""))continue;if(u++,!a.find(y=>y.startLine<=f&&f<=y.endLine))return!1}return u>0}function B(t,n,s){let i=d(t,n);if(!i)return"other";let o=i.split(`
3
+ `),a=Math.max(0,s-2),c=Math.min(o.length-1,s+2);for(let r=a;r<=c;r++){let u=(o[r]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(u))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(u))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(u))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(u))return"enum"}return"other"}function W(t,n){let s=d(t,n.relativePath);if(!s)return!1;let i=b(n.symbol);if(!i)return!1;let o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${o}\\b`),c=s.split(`
4
+ `);for(let r=0;r<c.length;r++)if(!(r>=n.startLine&&r<=n.endLine)&&a.test(c[r]??""))return!0;return!1}function z(t,n,s){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&n==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!s?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}function T(t){return t.endLine-t.startLine+1}function G(...t){let n=new Map;for(let s of t)for(let[i,o]of s){let a=n.get(i);a||(a=new Set,n.set(i,a));for(let c of o)a.add(c)}return n}export{te as a};
5
+ //# sourceMappingURL=chunk-RJ7SPBJ5.js.map
@@ -0,0 +1,3 @@
1
+ import{a as f}from"./chunk-LX4H4LLG.js";import{a as g,b as m}from"./chunk-TINPMWJK.js";function S(n,d){let c=f(n,d);if(!c)return[];let t=n.get(`SELECT symbol, enclosing_symbol FROM global_symbols
2
+ WHERE id = ? LIMIT 1`,c.symbolId);if(!t)return[];let o=[{symbol:t.symbol,shortName:m(t.symbol),depth:0}],e=t.enclosing_symbol,r=1,a=new Set([t.symbol]);for(;e&&!a.has(e)&&r<20;){a.add(e);let s=n.get("SELECT symbol, enclosing_symbol FROM global_symbols WHERE symbol = ?",e);if(!s)break;o.push({symbol:s.symbol,shortName:m(s.symbol),depth:r}),e=s.enclosing_symbol,r++}if(o.length>1)return o;let y=g(t.symbol);if("kind"in y)return o;let l=y.descriptors;if(l.length<=1)return o;let b=[o[0]];for(let s=l.length-2,p=1;s>=0;s--,p++){let h=l.slice(0,s+1).map(i=>i.suffix==="method"?`${i.name}()`:i.name.replace(/\.(ts|tsx|js|jsx|mjs|cjs|py|pyi|rs|java|scala|kt|kts|rb|go|cs|vb|dart|php|c|cc|cpp|cxx|h|hpp)$/,"")).join(":");b.push({symbol:h,shortName:h,depth:p})}return b}export{S as a};
3
+ //# sourceMappingURL=chunk-RWE6FHG3.js.map
@@ -0,0 +1,2 @@
1
+ import{q as p}from"./chunk-IYFZS4PV.js";import{a as d,b as f,d as u}from"./chunk-TINPMWJK.js";var m={0:"UnspecifiedKind",1:"AbstractMethod",2:"Accessor",3:"Array",4:"Assertion",5:"AssociatedType",6:"Attribute",7:"Axiom",8:"Boolean",9:"Class",10:"Constant",11:"Constructor",12:"Contract",13:"DataFamily",14:"DefinitionMacro",15:"Delegate",16:"Enum",17:"EnumMember",18:"Error",19:"Event",20:"Fact",21:"Field",22:"File",23:"Function",24:"Getter",25:"Grammar",26:"Instance",27:"Interface",28:"Key",29:"Lang",30:"Lemma",31:"Library",32:"Macro",33:"Method",34:"MethodAlias",35:"MethodReceiver",36:"MethodSpecification",37:"Message",38:"Modifier",39:"Module",40:"Namespace",41:"Null",42:"Number",43:"Object",44:"Operator",45:"Package",46:"PackageObject",47:"Parameter",48:"ParameterLabel",49:"Pattern",50:"Predicate",51:"Property",52:"Protocol",53:"ProtocolMethod",54:"PureVirtualMethod",55:"Quasiquoter",56:"SelfParameter",57:"Setter",58:"Signature",59:"SingletonClass",60:"SingletonMethod",61:"StaticDataMember",62:"StaticEvent",63:"StaticField",64:"StaticMethod",65:"StaticProperty",66:"StaticVariable",67:"String",68:"Struct",69:"Subscript",70:"Tactic",71:"Theorem",72:"ThisParameter",73:"Trait",74:"TraitMethod",75:"Type",76:"TypeAlias",77:"TypeClass",78:"TypeClassMethod",79:"TypeFamily",80:"TypeParameter",81:"Union",82:"Value",83:"Variable"},c=new Map;for(let[e,i]of Object.entries(m))c.set(i.toLowerCase(),Number(e));function g(e){let i=parseInt(e,10);if(!isNaN(i))return i;let s=e.toLowerCase(),n=c.get(s);if(n!==void 0)return n;for(let[r,o]of c)if(r.includes(s))return o;return null}function N(e,i,s={}){let{scope:n,limit:r=100}=s,o=g(i);return o===null?[]:b(e,n).map(t=>({row:t,resolvedKind:y(t)})).filter(t=>t.resolvedKind===o).slice(0,r).map(({row:t,resolvedKind:l})=>({symbol:t.symbol,shortName:f(t.symbol),kind:l,kindName:m[l]??"Unknown",relativePath:t.relative_path,startLine:t.start_line,endLine:t.end_line}))}function P(e,i={}){let s=new Map;for(let n of b(e,i.scope)){let r=y(n);r===null||r===0||s.set(r,(s.get(r)??0)+1)}return[...s.entries()].sort((n,r)=>r[1]-n[1]||n[0]-r[0]).map(([n,r])=>({kind:n,kindName:m[n]??"Unknown",count:r}))}function b(e,i){return p(e,{scope:i}).map(S)}function S(e){return{symbol:e.symbol,kind:e.kind,documentation:e.documentation,enclosing_symbol:e.enclosingSymbol,relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine}}function y(e){return e.kind!==null&&e.kind!==0?h(e.kind,e.symbol,e.documentation):M(e.symbol,e.documentation,e.enclosing_symbol)}function h(e,i,s){let n=(s??"").toLowerCase();if(u(i)==="type"){if(n.includes("type "))return 76;if(n.includes("interface "))return 27;if(n.includes("struct "))return 68;if(n.includes("trait "))return 73;if(n.includes("class "))return 9}return e}function M(e,i,s){let n=d(e);if("kind"in n)return null;let r=n.descriptors,o=r[r.length-2]??null,a=u(e),t=(i??"").toLowerCase();return a==="type"?t.includes("type ")?76:t.includes("interface ")?27:t.includes("struct ")?68:t.includes("trait ")?73:(t.includes("class "),9):a==="method"?o?.suffix==="type"?33:23:a==="namespace"?39:a!=="term"?null:t.includes("async def ")||t.includes("def ")?23:(s?u(s):o?.suffix??null)==="type"?21:83}export{N as a,P as b};
2
+ //# sourceMappingURL=chunk-SDX6MDBL.js.map
@@ -0,0 +1,2 @@
1
+ import{b as g}from"./chunk-VEUMRDHW.js";import{e as c,f as y,g as S}from"./chunk-WCDXJGYT.js";import{a}from"./chunk-LX4H4LLG.js";import{b as r}from"./chunk-TINPMWJK.js";function v(l,i){let o=a(l,i);if(!o)return null;let n=[{file:o.relativePath,line:o.startLine}],t=g(l,o),s=(t.length>0?t:S(l,o)).filter(e=>!l.isIgnored(e.file)).map(e=>({file:e.file,line:e.line,enclosingSymbol:e.enclosingSymbol??"(top-level)",enclosingShort:e.enclosingSymbol?r(e.enclosingSymbol):"(top-level)"})),{producers:u,consumers:b}=p(l,o,s);return{symbol:o.symbol,shortName:r(o.symbol),relativePath:o.relativePath,definitionSites:n.filter(e=>!l.isIgnored(e.file)),usageSites:s,producers:u.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:r(e.symbol),file:e.file})),consumers:b.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:e.symbol===e.file?"(top-level)":r(e.symbol),file:e.file}))}}function p(l,i,o){let n=m(c(l,i,{limit:30}).map(s=>({symbol:s.symbol,file:s.file}))),t=m(y(l,i,{limit:30})),f=t.length>0?t:m(o.map(s=>({symbol:s.enclosingSymbol==="(top-level)"?s.file:s.enclosingSymbol,file:s.file})));return{producers:n,consumers:f}}function m(l){let i=new Set,o=[];for(let n of l){let t=`${n.symbol}|${n.file}`;i.has(t)||(i.add(t),o.push(n))}return o}export{v as a};
2
+ //# sourceMappingURL=chunk-SG35Y7J2.js.map
@@ -0,0 +1,4 @@
1
+ import{b as S}from"./chunk-VEUMRDHW.js";import{g as d}from"./chunk-WCDXJGYT.js";import{a as g}from"./chunk-LX4H4LLG.js";import{d as u,n as m,o as f}from"./chunk-IYFZS4PV.js";import{b as s,f as a}from"./chunk-TINPMWJK.js";function _(n,o){let e=g(n,o);if(!e)return{definitions:[],referencedBy:[]};let i=n.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",e.symbolId),t=f(i?.documentation??null),c=n.isIgnored(e.relativePath)?[]:[{relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,signature:b(t,i?.display_name??null,e.symbol),source:y(n,e.relativePath,e.startLine,e.endLine)}],l=S(n,e),p=(l.length>0?l:d(n,e)).filter(r=>!n.isIgnored(r.file)).map(r=>({relativePath:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol,enclosingShort:r.enclosingSymbol?s(r.enclosingSymbol):"(top-level)"}));return{definitions:c,referencedBy:p}}function y(n,o,e,i){let t=u(n,o);if(!t)return null;let l=t.split(`
2
+ `).slice(e,i+1).join(`
3
+ `).trimEnd();return l.length>0?l:null}function b(n,o,e){let i=m(n);if(i&&!h(i))return i;let t=(o??"").trim();return t?a(e)&&!t.endsWith("()")?`${t}()`:t:s(e)}function h(n){return n.startsWith("undefined")||n.includes("|")||n.includes("```")}export{_ as a};
4
+ //# sourceMappingURL=chunk-STOGKRJH.js.map
@@ -0,0 +1,2 @@
1
+ var m={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function f(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let r=e.split(" ");if(r.length<4)return{scheme:r[0]??"",manager:r[1]??"",packageName:r[2]??"",version:"",descriptors:[],raw:e};let s=r[0],i=r[1],n=e.slice(s.length+1+i.length+1),t;if(n.startsWith("`")){let a=n.indexOf("`",1);a===-1?(t=n.slice(1),n=""):(t=n.slice(1,a),n=n.slice(a+2))}else{let a=n.indexOf(" ");a===-1?(t=n,n=""):(t=n.slice(0,a),n=n.slice(a+1))}let c,o=n.indexOf(" ");o===-1?(c=n,n=""):(c=n.slice(0,o),n=n.slice(o+1));let l=u(n);return{scheme:s,manager:i,packageName:t,version:c,descriptors:l,raw:e}}function u(e){let r=[],s=0;for(;s<e.length;){if(e[s]==="["){let t=e.indexOf("]",s+1);if(t===-1){r.push({name:e.slice(s+1),suffix:"type-param"});break}r.push({name:e.slice(s+1,t),suffix:"type-param"}),s=t+1;continue}if(e[s]==="("&&(r.length===0||s===0||d(e[s-1]))){let t=e.indexOf(")",s+1);if(t!==-1&&e[t+1]!=="."){r.push({name:e.slice(s+1,t),suffix:"parameter"}),s=t+1;continue}}let i;if(e[s]==="`"){let t=e.indexOf("`",s+1);if(t===-1){i=e.slice(s+1),r.push({name:i,suffix:"term"});break}i=e.slice(s+1,t),s=t+1}else{let t=s;for(;s<e.length&&!d(e[s]);)s++;i=e.slice(t,s)}if(s>=e.length){i&&r.push({name:i,suffix:"term"});break}let n=e[s];if(n==="("){let t=e.indexOf(")",s+1);t!==-1&&e[t+1]==="."?(r.push({name:i,suffix:"method"}),s=t+2):t!==-1?(r.push({name:i,suffix:"method"}),s=t+1):(r.push({name:i,suffix:"term"}),s++)}else{let t=m[n];t&&r.push({name:i,suffix:t}),s+=1}}return r}function d(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function h(e){let r=f(e);if("kind"in r&&r.kind==="local")return`local:${r.id}`;let s=r;if(s.descriptors.length===0)return s.raw;let i=[];for(let n of s.descriptors){let t=n.name;n.suffix==="namespace"&&(t=t.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")),t&&(n.suffix==="method"?i.push(`${t}()`):i.push(t))}return i.join(":")}function g(e){let r=f(e);if("kind"in r&&r.kind==="local")return r.id;let s=r;return s.descriptors.length===0?"":s.descriptors[s.descriptors.length-1].name}function p(e){let r=f(e);if("kind"in r&&r.kind==="local")return null;let s=r;return s.descriptors[s.descriptors.length-1]?.suffix??null}function x(e){return e.endsWith("().")||p(e)==="method"}function S(e){let r=p(e);return r==="method"||r==="term"}function b(e){return p(e)==="namespace"}function y(e,r){let s=f(e),i=f(r);if("kind"in s||"kind"in i)return!1;let n=s.descriptors,t=i.descriptors;if(t.length!==n.length+1)return!1;for(let c=0;c<n.length;c++){let o=n[c],l=t[c];if(o.name!==l.name||o.suffix!==l.suffix)return!1}return!0}function k(e,r){let s=f(e),i=f(r);if("kind"in s||"kind"in i)return!1;let n=s.descriptors,t=i.descriptors;if(t.length<=n.length)return!1;for(let c=0;c<n.length;c++){let o=n[c],l=t[c];if(o.name!==l.name||o.suffix!==l.suffix)return!1}return!0}export{f as a,h as b,g as c,p as d,x as e,S as f,b as g,y as h,k as i};
2
+ //# sourceMappingURL=chunk-TINPMWJK.js.map
@@ -0,0 +1,2 @@
1
+ import{a as z}from"./chunk-5IADAU5B.js";import{b as B}from"./chunk-K6GBKEQE.js";import{a as E}from"./chunk-RJ7SPBJ5.js";import{a as H}from"./chunk-N3Z2SJCR.js";import{a as A}from"./chunk-7Z4COVMC.js";import{a as W}from"./chunk-7VOF4ZG6.js";import{a as V}from"./chunk-7754WFFV.js";import{a as I}from"./chunk-F2LLHRRZ.js";import{a as k}from"./chunk-EEF3YEHW.js";import{a as j}from"./chunk-KO7YJRWP.js";import{d as y}from"./chunk-GNXRLK5G.js";import{a as q}from"./chunk-Y7H6D2EV.js";function ut(e,F={}){let{scope:r}=F,a=H(e),N=j(e,{scope:r,minLoc:3,skipBarrels:!0}),x=A(e,{scope:r,minLoc:3}),b=k(e,{scope:r}),T=B(e,{scope:r,minSimilarity:.6,limit:50,minCallees:4}),m=I(e,{scope:r,minLoc:15,minCallees:5,limit:50}),c=z(e,{scope:r,maxLoc:15,limit:50}),l=W(e,{scope:r,maxLoc:15,limit:50}),R=E(e,{scope:r,minLoc:3,limit:50}),n=V(e,{scope:r}),v=q(e,{scope:r,minLoc:10,limit:10}),S=N.symbols.filter(t=>!y(e,t.relativePath)&&t.kind==="dead-code"),u=S.length,$=S.reduce((t,o)=>t+o.loc,0),h=x.filter(t=>!y(e,t.relativePath)).length,p=R.length,M=n.results.length,d=T.length,s=[];u>0&&s.push({category:"Dead code",description:`${u} symbols with zero references anywhere \u2014 safe to delete`,effort:"low",impact:"high",count:u,locRecoverable:$}),h>0&&s.push({category:"Isolated symbols",description:`${h} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:h,locRecoverable:x.filter(t=>!y(e,t.relativePath)).reduce((t,o)=>t+o.loc,0)});let C=b.filter(t=>t.kind==="real");if(C.length>0&&s.push({category:"Circular dependencies",description:`${C.length} cycle(s) \u2014 break with dependency inversion or module restructuring`,effort:"medium",impact:"high",count:C.length,locRecoverable:0}),d>0&&s.push({category:"Similar functions",description:`${d} pairs with real logic overlap (beyond shared imports) \u2014 consolidation candidates`,effort:"medium",impact:"medium",count:d,locRecoverable:0}),m.length>0&&s.push({category:"Extraction candidates",description:`${m.length} large functions with isolated callee clusters \u2014 extract method opportunities`,effort:"medium",impact:"medium",count:m.length,locRecoverable:0}),c.length>0&&s.push({category:"Wrapper functions",description:`${c.length} single-consumer symbols that could be inlined`,effort:"low",impact:"low",count:c.length,locRecoverable:c.reduce((t,o)=>t+o.loc,0)}),l.length>0&&s.push({category:"Passthrough functions",description:`${l.length} functions that just forward to one callee \u2014 unnecessary indirection`,effort:"low",impact:"low",count:l.length,locRecoverable:l.reduce((t,o)=>t+o.loc,0)}),p>0){let t=R.filter(w=>w.consumers===0).length,o=p-t,g=[];t>0&&g.push(`${t} unused`),o>0&&g.push(`${o} single-consumer (not in types file)`),s.push({category:"Stale abstractions",description:`${g.join(", ")} \u2014 premature abstraction`,effort:"low",impact:"medium",count:p,locRecoverable:R.reduce((w,Z)=>w+Z.loc,0)})}if(M>0){let t=[];n.unusedImports>0&&t.push(`${n.unusedImports} unused imports`),n.layerViolations>0&&t.push(`${n.layerViolations} layer violations`),n.patternDeviations>0&&t.push(`${n.patternDeviations} unique deps`),s.push({category:"Structural drift",description:t.join(", "),effort:n.layerViolations>0?"medium":"low",impact:n.layerViolations>0?"medium":"low",count:M,locRecoverable:0})}let P={high:3,medium:2,low:1},L={low:3,medium:2,high:1};s.sort((t,o)=>{let g=P[t.impact]*L[t.effort];return P[o.impact]*L[o.effort]-g});let U=Math.max(a.documents,1),f=Math.max(a.symbols,1),i=100,G=u/f;i-=Math.min(20,Math.round(G*200));let J=h/f;i-=Math.min(10,Math.round(J*200));let D=b.filter(t=>t.kind==="real").length;i-=Math.min(15,D*5);let K=d/f*1e3;i-=Math.min(10,Math.round(K));let O=m.length/f*1e3;i-=Math.min(5,Math.round(O/2)),i-=Math.min(3,c.length),i-=Math.min(3,l.length);let Q=p/Math.max(f*.1,1);i-=Math.min(8,Math.round(Q*10));let X=M/U;i-=Math.min(5,Math.round(X*50));let Y=v.filter(t=>t.score>50).length;return i-=Math.min(5,Y*2),i=Math.max(0,Math.min(100,i)),{score:i,overview:{documents:a.documents,symbols:a.symbols,indexSizeBytes:a.indexSizeBytes},findings:{deadSymbols:u,deadLoc:$,isolatedSymbols:h,isolatedLoc:x.filter(t=>!y(e,t.relativePath)).reduce((t,o)=>t+o.loc,0),cycles:D,similarPairs:d,extractionCandidates:m.length,wrappers:c.length,passthroughs:l.length,staleTypes:p,driftedFiles:M,complexityHotspotCount:v.length},actions:s,topComplexity:v.slice(0,5).map(t=>({symbol:t.shortName,score:t.score}))}}export{ut as a};
2
+ //# sourceMappingURL=chunk-UJB62HV3.js.map
@@ -0,0 +1,2 @@
1
+ import{a as u}from"./chunk-ZSRXMNMK.js";import{a as y,b as h,i as x}from"./chunk-WCDXJGYT.js";import{e as I}from"./chunk-BQ3INTYT.js";import{c as S}from"./chunk-LX4H4LLG.js";import{d,p as g,t as b}from"./chunk-IYFZS4PV.js";import{c as p}from"./chunk-TINPMWJK.js";function w(o,c,n){let t=x(o).get(n);if(!t||t.length===0)return[];if(t.length===1)return[l(t[0])];let s=t.find(f=>f.file===c);if(s)return[l(s)];let e=D(o,c),i=e.get(n);if(i)for(let f of i){let r=t.filter(m=>R(f,m.file));if(r.length>0)return r.map(l)}let a=new Set;for(let f of e.values())for(let r of f)a.add(r);for(let f of a){let r=t.filter(m=>R(f,m.file));if(r.length>0&&r.length===t.length)return r.map(l)}return[]}function j(o,c){let n=S(o,c);if(!n)return[];let t=p(n.symbol);if(!t)return[];let s=new Map;for(let e of u(o)){let i=d(o,e);if(!i||i.indexOf(t)===-1||e!==n.relativePath&&!w(o,e,t).some(r=>r.symbolId===n.symbolId))continue;let a=y(o,e,t,e===n.relativePath?{excludeStartLine:n.startLine,excludeEndLine:n.endLine}:{});a.length>0&&s.set(e,a)}return F(o,s)}function C(o,c){let n=new Map;for(let e of c){if(!e.leaf)continue;let i=n.get(e.leaf)??[];i.push(e),n.set(e.leaf,i)}if(n.size===0)return new Map;let t=new Set(c.map(e=>e.symbolId)),s=new Map;for(let e of u(o)){let i=h(o,e);if(i.size!==0){for(let a of i)if(n.has(a))for(let f of w(o,e,a)){if(!t.has(f.symbolId)||e===f.relativePath)continue;let r=s.get(f.symbolId);r||(r=new Set,s.set(f.symbolId,r)),r.add(e)}}}return s}function D(o,c){let n=new Map;for(let t of I(o,c)){if(!t.sourcePath)continue;let s=t.localName??t.importedName;if(s){let e=n.get(s);e||(e=new Set,n.set(s,e)),e.add(t.sourcePath)}if(t.kind==="namespace")for(let e of t.usedMembers){let i=n.get(e);i||(i=new Set,n.set(e,i)),i.add(t.sourcePath)}}return n}function R(o,c){let n=t=>t.replace(/\\/g,"/").replace(/^\.\//,"");return n(o)===n(c)}function l(o){return{symbolId:o.symbolId,symbol:o.symbol,relativePath:o.file}}function F(o,c){let n=[],t=new Set;for(let[s,e]of c){let i=g(o,s);for(let a of e){let f=b(i,a),r=`${s}|${a}|${f?.symbol??""}`;t.has(r)||(t.add(r),n.push({file:s,line:a,enclosingSymbol:f?.symbol??null}))}}return n}export{w as a,j as b,C as c};
2
+ //# sourceMappingURL=chunk-VEUMRDHW.js.map
@@ -0,0 +1,65 @@
1
+ import{a as v,b as D,c as F,e as T}from"./chunk-BQ3INTYT.js";import{c as C}from"./chunk-LX4H4LLG.js";import{a as h,b as R,d as M,f as _,h as k,i as L,p as N,q as A,t as x}from"./chunk-IYFZS4PV.js";import{c as I}from"./chunk-TINPMWJK.js";function J(n,i,o,a={}){if(!o)return[];let l=M(n,i);if(!l)return[];if(l.indexOf(o)===-1)return[];if(_(i))return(w(n,i).get(o)??[]).filter(d=>!$(d,a));let s=D(n,i,l),r=new RegExp(`\\b${F(o)}\\b`),e=[];for(let c=0;c<s.length;c++)$(c,a)||r.test(s[c]??"")&&e.push(c);return e}function $(n,i){return typeof i.excludeStartLine=="number"&&typeof i.excludeEndLine=="number"&&n>=i.excludeStartLine&&n<=i.excludeEndLine}var G=h("file-identifiers");function re(n,i){return G.get(n,i,()=>new Set(w(n,i).keys()))}var Y=h("file-ident-lines");function w(n,i){return Y.get(n,i,()=>z(n,i))}var j=h("file-idents-by-line");function H(n,i){return j.get(n,i,()=>{let o=w(n,i),a=0;for(let s of o.values()){let r=s[s.length-1];r!==void 0&&r>a&&(a=r)}let l=new Array(a+1);for(let s=0;s<=a;s+=1)l[s]=new Set;for(let[s,r]of o)for(let e of r)l[e].add(s);return l})}function z(n,i){let o=new Map,a=(e,c)=>{let t=o.get(e);if(!t){o.set(e,[c]);return}t[t.length-1]!==c&&t.push(c)};if(_(i)){let e=k(n,i);if(e){let c=_(i),t=c==="rust"?new Set(["identifier","type_identifier","field_identifier"]):c==="python"?new Set(["identifier"]):new Set(["identifier","property_identifier","type_identifier"]),d=new Set(["rust","python"]),g=/\{(?:\?\s*)?([A-Za-z_][\w]*)/g,u=m=>{if(t.has(m.type)&&a(m.text,m.startPosition.row),c&&d.has(c)&&m.type==="string_content"){let b=m.startPosition.row;for(let f of m.text.matchAll(g))f[1]&&a(f[1],b)}for(let b of m.children)u(b)};return u(e.rootNode),o}}let l=M(n,i);if(!l)return o;let s=v(l).split(/\r?\n/),r=/\b([A-Za-z_$][\w$]*)\b/g;for(let e=0;e<s.length;e+=1){let c=s[e]??"";for(let t of c.matchAll(r))t[1]&&a(t[1],e)}return o}var K=h("file-dep-graph");function be(n,i){return K.get(n,i??"",()=>{let o=i?`AND d1.relative_path LIKE '%${i}%'`:"",a=n.all(`SELECT DISTINCT
2
+ d1.relative_path AS from_file,
3
+ d2.relative_path AS to_file
4
+ FROM mentions m
5
+ JOIN chunks c ON m.chunk_id = c.id
6
+ JOIN documents d1 ON c.document_id = d1.id
7
+ JOIN global_symbols gs ON m.symbol_id = gs.id
8
+ JOIN (
9
+ SELECT m2.symbol_id, c2.document_id
10
+ FROM mentions m2
11
+ JOIN chunks c2 ON m2.chunk_id = c2.id
12
+ WHERE m2.role = 1
13
+ GROUP BY m2.symbol_id
14
+ ) sym_def ON sym_def.symbol_id = gs.id
15
+ JOIN documents d2 ON sym_def.document_id = d2.id
16
+ WHERE d1.id != d2.id
17
+ AND m.role != 1
18
+ ${n.pathExclusionsFor("d1","d2")}
19
+ ${o}`),l=new Map,s=new Set(n.all(`SELECT relative_path
20
+ FROM documents
21
+ WHERE 1 = 1
22
+ ${n.pathExclusionsFor("documents")}
23
+ ORDER BY relative_path`).map(e=>e.relative_path).filter(e=>!n.isIgnored(e))),r=(e,c)=>{e!==c&&(n.isIgnored(e)||n.isIgnored(c)||s.has(c)&&(l.has(e)||l.set(e,new Set),l.get(e).add(c)))};for(let e of a)r(e.from_file,e.to_file);for(let e of s)if(!(i&&!e.includes(i)))for(let c of T(n,e))c.sourcePath&&r(e,c.sourcePath);return l})}function pe(n,i,o={}){let l=P(n,[i]).get(i.symbolId)??[];return typeof o.limit=="number"?l.slice(0,o.limit):l}function _e(n,i,o={}){let l=Z(n).get(i.symbolId)??[];return typeof o.limit=="number"?l.slice(0,o.limit):l}var U=R("caller-rows");function Z(n){return U.get(n,()=>{let i=A(n),o=P(n,i),a=new Map;for(let r of i)a.set(r.symbol,r.symbolId);let l=new Map,s=new Map;for(let r of i){let e=o.get(r.symbolId);if(!(!e||e.length===0))for(let c of e){let t=a.get(c.symbol);if(t===void 0||t===r.symbolId)continue;let d=l.get(t);d||(d=[],l.set(t,d),s.set(t,new Set));let g=`${r.symbol}|${r.relativePath}`;s.get(t).has(g)||(s.get(t).add(g),d.push({symbol:r.symbol,file:r.relativePath}))}}return l})}function ye(n,i){let o=X(n,i);return o?q(n,V(n,o.match,o.identifier)):[]}function V(n,i,o){let a=n.all(`SELECT DISTINCT d.relative_path, c.start_line, c.end_line
24
+ FROM mentions m
25
+ JOIN chunks c ON m.chunk_id = c.id
26
+ JOIN documents d ON c.document_id = d.id
27
+ WHERE m.symbol_id = ?
28
+ AND m.role != 1
29
+ ${n.pathExclusionsFor("d")}
30
+ ORDER BY d.relative_path, c.start_line`,i.symbolId),l=new Map;for(let r of a){if(n.isIgnored(r.relative_path))continue;let e=l.get(r.relative_path);e||(e=[],l.set(r.relative_path,e)),e.push({start_line:r.start_line,end_line:r.end_line})}let s=new Map;for(let[r,e]of l){let c=r===i.relativePath?{excludeStartLine:i.startLine,excludeEndLine:i.endLine}:{},t=o?J(n,r,o,c):[],d=[];for(let g of e){let u=t.filter(b=>b>=g.start_line&&b<=g.end_line),m=u.length>0?u:[g.start_line];for(let b of m)d.push(b)}s.set(r,d)}return s}function X(n,i){let o=C(n,i);return o?{match:o,identifier:I(o.symbol)||null}:null}function q(n,i){let o=[],a=new Set;for(let[l,s]of i){let r=N(n,l);for(let e of s){let c=x(r,e),t=`${l}|${e}|${c?.symbol??""}`;a.has(t)||(a.add(t),o.push({file:l,line:e,enclosingSymbol:c?.symbol??null}))}}return o}function P(n,i,o={}){if(i.length===0)return new Map;let a=o.additive??!1,l=[],s=[];for(let t of i)_(t.relativePath)&&L(n,t.relativePath)!==null?l.push(t):s.push(t);let r=new Map,e=t=>{for(let[d,g]of t){let u=r.get(d);u||(u=[],r.set(d,u));let m=new Set(u.map(b=>`${b.symbol}|${b.chunkId}`));for(let b of g){let f=`${b.symbol}|${b.chunkId}`;m.has(f)||(m.add(f),u.push(b))}}};l.length>0&&e(Q(n,l));let c=a?i:s;return c.length>0&&e(ne(n,c)),r}function Q(n,i){let o=new Map,a=new Map;for(let s of i){let r=a.get(s.relativePath);r?r.push(s):a.set(s.relativePath,[s]),o.set(s.symbolId,[])}let l=B(n);for(let[s,r]of a){let e=L(n,s);if(!e)continue;let c=[...r].sort((t,d)=>{let g=t.endLine-t.startLine,u=d.endLine-d.startLine;return g-u});for(let t of e){let d=null;for(let f of c)if(t.line>=f.startLine&&t.line<=f.endLine){d=f;break}if(!d)continue;let g=l.get(t.calleeLeaf);if(!g||g.length===0)continue;let u=null,m=g.find(f=>f.file===s);if(m?u=m:g.length===1&&(u=g[0]),!u||u.symbol===d.symbol)continue;o.get(d.symbolId).push({symbol:u.symbol,file:u.file,chunkId:t.line})}}return o}var ee=R("global-leaf-index");function B(n){return ee.get(n,()=>{let i=n.all(`SELECT gs.id, gs.symbol,
31
+ COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
32
+ FROM global_symbols gs
33
+ LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
34
+ LEFT JOIN documents der_doc ON der_doc.id = der.document_id
35
+ LEFT JOIN (
36
+ SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
37
+ FROM mentions m
38
+ JOIN chunks c ON m.chunk_id = c.id
39
+ JOIN documents d ON c.document_id = d.id
40
+ WHERE m.role = 1
41
+ GROUP BY m.symbol_id
42
+ ) mention_doc ON mention_doc.symbol_id = gs.id
43
+ WHERE 1 = 1
44
+ ${n.symbolNoiseFor("gs")}`),o=new Map;for(let a of i){if(!a.relative_path||n.isIgnored(a.relative_path))continue;let l=I(a.symbol);if(!l)continue;let s=o.get(l);s||(s=[],o.set(l,s)),s.some(r=>r.symbolId===a.id)||s.push({symbol:a.symbol,symbolId:a.id,file:a.relative_path})}return o})}function ne(n,i){if(i.length===0)return new Map;let o=n.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
45
+ FROM mentions m
46
+ JOIN chunks c ON m.chunk_id = c.id
47
+ WHERE m.role != 1`),a=new Map;for(let t of o)a.has(t.document_id)||a.set(t.document_id,[]),a.get(t.document_id).push(t);let l=new Map(n.all("SELECT id, relative_path FROM documents").map(t=>[t.id,t.relative_path])),s=new Map,r=n.all(`SELECT gs.id AS symbol_id, gs.symbol,
48
+ COALESCE(der.document_id, def_chunk.document_id) AS document_id
49
+ FROM global_symbols gs
50
+ LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
51
+ LEFT JOIN (
52
+ SELECT m.symbol_id, MIN(c.document_id) AS document_id
53
+ FROM mentions m
54
+ JOIN chunks c ON m.chunk_id = c.id
55
+ WHERE m.role = 1
56
+ GROUP BY m.symbol_id
57
+ ) def_chunk ON def_chunk.symbol_id = gs.id`);for(let t of r)s.has(t.symbol_id)||s.set(t.symbol_id,{symbol:t.symbol,file:t.document_id!==null?l.get(t.document_id)??"":""});let e=new Map,c=l;for(let t of i){let d=a.get(t.documentId)??[],g=new Set,u=[],m=null,b=()=>{if(m)return m;let f=c.get(t.documentId)??"",p=new Set;if(f){let E=H(n,f),S=Math.max(0,t.startLine),O=Math.min(E.length-1,t.endLine);for(let y=S;y<=O;y+=1)for(let W of E[y])p.add(W)}return m=p,p};for(let f of d){if(f.symbol_id===t.symbolId)continue;let p=s.get(f.symbol_id);if(!p)continue;if(!(f.start_line>=t.startLine&&f.end_line<=t.endLine)){if(!(f.start_line<=t.endLine&&f.end_line>=t.startLine))continue;let y=I(p.symbol);if(!y||!b().has(y))continue}let S=`${p.symbol}|${f.chunk_id}`;g.has(S)||(g.add(S),u.push({...p,chunkId:f.chunk_id}))}e.set(t.symbolId,u)}return e}function he(n,i){let o=new Map,a=n.all(`SELECT relative_path FROM documents
58
+ WHERE 1 = 1 ${n.pathExclusionsFor("documents")}`),l=B(n);for(let e of a){if(!_(e.relative_path)||n.isIgnored(e.relative_path))continue;let c=L(n,e.relative_path);if(c)for(let t of c){let d=l.get(t.calleeLeaf);if(!d||d.length===0)continue;let u=d.find(b=>b.file===e.relative_path)??(d.length===1?d[0]:null);if(!u||u.file===e.relative_path)continue;let m=o.get(u.symbolId);m||(m=new Set,o.set(u.symbolId,m)),m.add(e.relative_path)}}let s=n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
59
+ c.start_line AS chunk_start, c.end_line AS chunk_end
60
+ FROM mentions m
61
+ JOIN chunks c ON m.chunk_id = c.id
62
+ JOIN documents d ON c.document_id = d.id
63
+ WHERE m.role != 1
64
+ ${n.pathExclusionsFor("d")}`),r=new Map;if(i)for(let e of i)r.set(e.symbolId,{docId:e.documentId,startLine:e.startLine,endLine:e.endLine});for(let e of s){if(n.isIgnored(e.relative_path))continue;let c=r.get(e.symbol_id);if(c&&c.docId===e.document_id&&e.chunk_start>=c.startLine&&e.chunk_end<=c.endLine)continue;let t=o.get(e.symbol_id);t||(t=new Set,o.set(e.symbol_id,t)),t.add(e.relative_path)}return o}export{J as a,re as b,w as c,be as d,pe as e,_e as f,ye as g,P as h,B as i,he as j};
65
+ //# sourceMappingURL=chunk-WCDXJGYT.js.map
@@ -0,0 +1,6 @@
1
+ import{a as c}from"./chunk-LX4H4LLG.js";import{existsSync as m}from"fs";import{basename as p,isAbsolute as f,join as g}from"path";function S(e,r){let t=u(e,r,{allowMultiple:!1})[0]?.relativePath;return t||v(e,r)}function M(e,r){return u(e,r,{allowMultiple:!0}).map(t=>t.relativePath)}function v(e,r){if(!r)return null;let t=r.replace(/\\/g,"/").replace(/^\.\//,""),a=f(t)&&t.startsWith(e.config.projectRoot)?t.slice(e.config.projectRoot.length).replace(/^\/+/,""):t,n=g(e.config.projectRoot,a);return m(n)?a:null}function u(e,r,t){let a=h(r);if(!a)return[];let i=e.all(`SELECT relative_path
2
+ FROM documents
3
+ WHERE 1 = 1
4
+ ${e.pathExclusionsFor("documents")}
5
+ ORDER BY relative_path`).filter(o=>!e.isIgnored(o.relative_path)).map(o=>({relativePath:o.relative_path,score:d(o.relative_path,a)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.relativePath.localeCompare(l.relativePath));if(i.length===0){let o=c(e,r);return!o||e.isIgnored(o.relativePath)?[]:[{relativePath:o.relativePath,score:700}]}let s=i.filter(o=>o.score>=800);return s.length>0?t.allowMultiple?s:[s[0]]:t.allowMultiple?i:[i[0]]}function d(e,r){let t=h(e),a=p(t),n=p(r),i=0;return t===r&&(i+=1200),t.endsWith(`/${r}`)&&(i+=1100),a===n&&(i+=900),t.startsWith(`${r}/`)&&(i+=850),t.includes(r)&&(i+=250),i}function h(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}export{S as a,M as b};
6
+ //# sourceMappingURL=chunk-WTSTDJZ7.js.map
@@ -0,0 +1,2 @@
1
+ import{d,q as b}from"./chunk-IYFZS4PV.js";import{b as g}from"./chunk-TINPMWJK.js";function I(n,e={}){let{scope:i,minLoc:u=1,limit:l}=e,p=new Map;for(let t of b(n,{scope:i})){if(!t.isFunctionLike||n.isIgnored(t.relativePath))continue;let s=t.endLine-t.startLine+1;if(s<u)continue;let f=x(n,t);if(!f)continue;let a={symbol:t.symbol,shortName:g(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:s},r=p.get(f);r?r.push(a):p.set(f,[a])}let c=[];for(let[t,s]of p)s.length<2||c.push({signature:t,functions:s});return c.sort((t,s)=>{let f=s.functions.length-t.functions.length;if(f!==0)return f;let a=t.functions.reduce((o,m)=>o+m.loc,0);return s.functions.reduce((o,m)=>o+m.loc,0)-a}),l?c.slice(0,l):c}function x(n,e){let i=S(e.documentation),u=i?L(i):null;return u||D($(n,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)}function S(n){if(!n||!n.includes("|"))return null;let e=n.slice(n.indexOf("|")+1).replace(/\n/g," ").trim();return e.length>0?e:null}function $(n,e,i,u,l){let p=d(n,e);if(!p)return null;let c=p.split(/\r?\n/),t=v(c,i,u,l);for(let s of t){let f=Math.min(c.length-1,Math.max(s,s+4)),a="";for(let r=s;r<=f;r+=1){let o=c[r]?.trim();if(o&&(a=a?`${a} ${o}`:o,y(a)))return a}if(a&&a.includes("("))return a}return null}function y(n){let e=n.replace(/\s+/g," ").trim();return!e.includes("(")||w(e)>0?!1:/[;{]$/.test(e)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(e)||/\)\s*As\s+.+$/i.test(e)}function L(n){if(!n||!n.trim())return null;let e=n.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),i=e.indexOf("(");return i===-1||(e=e.slice(i),e=e.replace(/\s+/g,"").toLowerCase(),e.length<3)?null:e}function D(n,e){if(!n||!n.trim())return null;let i=n.replace(/\s+/g," ").trim(),u=i.indexOf("(");if(u===-1)return null;let l=i.slice(0,u),c=new RegExp(`\\b${h(e)}\\b`,"i").exec(l);c&&typeof c.index=="number"&&(l=l.slice(0,c.index)),l=l.replace(/\b(public|private|protected|internal|final|static|abstract|sealed|virtual|override|async|suspend|inline|constexpr|consteval|constinit|const|pub|fn|function|def|sub|friend|shared|readonly|new|open|partial|export)\b/gi," ").replace(/\s+/g," ").trim();let t=i.slice(u).replace(/\s*\{[\s\S]*$/,"").replace(/\s*=>[\s\S]*$/,"").replace(/\)\s*=\s*[\s\S]*$/,")").replace(/\s+throws\s+[^={]+$/i,"").replace(/\s+where\s+.+$/i,"").replace(/\s+/g," ").trim();if(!t.startsWith("("))return null;let s=`${l?`${l} `:""}${t}`.replace(/\s+/g,"").toLowerCase();return s.length>=3?s:null}function v(n,e,i,u){let l=h(u),p=new RegExp(`\\b${l}\\b\\s*\\(`,"i"),c=new RegExp(`\\bdef\\s+${l}\\b`,"i"),t=[],s=new Set,f=Math.max(0,Math.min(e,n.length-1)),a=Math.max(f,Math.min(n.length-1,Math.max(i,e+4)));for(let r=f;r<=a;r+=1){let o=n[r]??"";(p.test(o)||c.test(o))&&!s.has(r)&&(s.add(r),t.push(r))}for(let r=0;r<n.length;r+=1){let o=n[r]??"";(p.test(o)||c.test(o))&&!s.has(r)&&(s.add(r),t.push(r))}return t}function w(n){let e=0;for(let i of n)i==="("&&(e+=1),i===")"&&(e-=1);return e}function h(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{I as a};
2
+ //# sourceMappingURL=chunk-XAZTIDST.js.map
@@ -0,0 +1,35 @@
1
+ import{b as o}from"./chunk-WTSTDJZ7.js";import{s as m}from"./chunk-IYFZS4PV.js";function y(t,l){let s=o(t,l);if(s.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let d=s.map(()=>"?").join(", "),i=t.all(`SELECT relative_path FROM documents
2
+ WHERE relative_path IN (${d})
3
+ ORDER BY relative_path`,...s).map(e=>e.relative_path).filter(e=>!t.isIgnored(e)),n=m(t,i,{onlyDocumented:!0,sort:!0}).map(({relativePath:e,...c})=>c),a=t.all(`SELECT DISTINCT d2.relative_path
4
+ FROM mentions m
5
+ JOIN chunks c ON m.chunk_id = c.id
6
+ JOIN documents d1 ON c.document_id = d1.id
7
+ JOIN global_symbols gs ON m.symbol_id = gs.id
8
+ JOIN (
9
+ SELECT m2.symbol_id, c2.document_id
10
+ FROM mentions m2
11
+ JOIN chunks c2 ON m2.chunk_id = c2.id
12
+ WHERE m2.role = 1
13
+ GROUP BY m2.symbol_id
14
+ ) sym_def ON sym_def.symbol_id = gs.id
15
+ JOIN documents d2 ON sym_def.document_id = d2.id
16
+ WHERE d1.relative_path IN (${d})
17
+ AND d2.relative_path NOT IN (${d})
18
+ AND ${t.localSymbolPredicate}
19
+ ORDER BY d2.relative_path`,...s,...s).map(e=>e.relative_path).filter(e=>!t.isIgnored(e)),r=t.all(`SELECT DISTINCT d1.relative_path
20
+ FROM mentions m
21
+ JOIN chunks c ON m.chunk_id = c.id
22
+ JOIN documents d1 ON c.document_id = d1.id
23
+ JOIN global_symbols gs ON m.symbol_id = gs.id
24
+ JOIN (
25
+ SELECT m2.symbol_id, c2.document_id
26
+ FROM mentions m2
27
+ JOIN chunks c2 ON m2.chunk_id = c2.id
28
+ WHERE m2.role = 1
29
+ GROUP BY m2.symbol_id
30
+ ) sym_def ON sym_def.symbol_id = gs.id
31
+ JOIN documents d2 ON sym_def.document_id = d2.id
32
+ WHERE d2.relative_path IN (${d})
33
+ AND d1.relative_path NOT IN (${d})
34
+ ORDER BY d1.relative_path`,...s,...s).map(e=>e.relative_path).filter(e=>!t.isIgnored(e));return{files:i,symbols:n,dependsOn:a,dependedOnBy:r}}export{y as a};
35
+ //# sourceMappingURL=chunk-XVDASCN7.js.map
@@ -0,0 +1,2 @@
1
+ import{h as y,j as u}from"./chunk-WCDXJGYT.js";import{r as m}from"./chunk-IYFZS4PV.js";import{b as c}from"./chunk-TINPMWJK.js";function D(l,r){let{scope:o,minLoc:a=10,limit:b=30}=r??{},{definitions:f,callerMap:C,calleeMap:M}=S(l,o);return f.map(e=>{let s=e.endLine-e.startLine+1,p=C.get(e.symbolId)?.size??0,n=M.get(e.symbolId)??[],d=n.filter(t=>t.file!==e.relativePath),i=new Set(d.map(t=>`${t.symbol}|${t.file}`)).size,L=new Set(n.map(t=>`${t.symbol}|${t.file}`)).size;return{symbol:e.symbol,shortName:c(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:s,fanIn:p,fanOut:i,calleeCount:L,score:Math.round(s/50*(p/5)*Math.max(i/5,1)*100)/100}}).filter(e=>e.loc>=a).sort((e,s)=>s.score-e.score||s.loc-e.loc).slice(0,b)}function S(l,r){let o=m(l,r).filter(a=>a.isFunctionLike&&!l.isIgnored(a.relativePath));return{definitions:o,callerMap:u(l,o),calleeMap:y(l,o)}}export{D as a};
2
+ //# sourceMappingURL=chunk-Y7H6D2EV.js.map
@@ -0,0 +1,2 @@
1
+ import{d as M}from"./chunk-WCDXJGYT.js";function H(o,c={}){let{minSimilarity:e=.5,limit:n=15,scope:r,minChainLength:g=3,maxChainLength:s=8}=c,l=M(o,r),t=R(l,g,s);if(t.length===0)return[];let h=new Map,u=new Map;for(let i of t){let a=new Set;for(let f of i)a.has(f)||(h.set(f,(h.get(f)??0)+1),a.add(f));for(let f=Math.max(0,i.length-2);f<i.length;f++)u.set(i[f],(u.get(i[f])??0)+1)}let P=t.length*.9,q=t.length*.8,x=new Set;for(let[i,a]of h)a>P&&x.add(i);for(let[i,a]of u)a>q&&x.add(i);let E=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let i of h.keys()){let a=i.split("/").pop()??"";E.includes(a)&&x.add(i)}let p=[];for(let i of t){let a=i.filter(f=>!x.has(f));a.length>=2&&p.push({original:i,filtered:a})}if(p.length<2)return[];let b=[];for(let i=0;i<p.length;i++){for(let a=i+1;a<p.length;a++){let f=p[i],m=p[a],F=new Set(f.filtered),S=!1;for(let d of m.filtered)if(F.has(d)){S=!0;break}if(!S)continue;let{distance:C,ops:A}=T(f.filtered,m.filtered),j=Math.max(f.filtered.length,m.filtered.length);if(j===0)continue;let B=1-C/j;if(B<e||C===0)continue;let w=A.filter(d=>d.type==="substitute").map(d=>({index:d.indexA,nodeA:f.filtered[d.indexA],nodeB:m.filtered[d.indexB]}));if(w.length===0||A.filter(d=>d.type==="match").length<2)continue;let N=v(f.original,m.original),O=z(f.original,m.original);b.push({chainA:f.original,chainB:m.original,similarity:B,editDistance:C,divergencePoints:w,commonPrefix:N,commonSuffix:O})}if(b.length>n*10)break}b.sort((i,a)=>Math.abs(a.similarity-i.similarity)>.01?a.similarity-i.similarity:i.divergencePoints.length-a.divergencePoints.length);let y=[];for(let i of b)if(y.some(f=>k(i.chainA,f.chainA)&&k(i.chainB,f.chainB))||y.push(i),y.length>=n)break;return y}function R(o,c,e){let n=[];for(let g of o.keys()){if(n.length>=500)break;D(o,g,[g],new Set([g]),c,e,n,500)}return n}function D(o,c,e,n,r,g,s,l){if(s.length>=l)return;if(e.length>=g){e.length>=r&&s.push([...e]);return}let t=o.get(c);if(!t||t.size===0){e.length>=r&&s.push([...e]);return}let h=!1;for(let u of t)if(!n.has(u)&&(n.add(u),e.push(u),D(o,u,e,n,r,g,s,l),e.pop(),n.delete(u),h=!0,s.length>=l))return;!h&&e.length>=r&&s.push([...e])}function T(o,c){let e=o.length,n=c.length,r=Array.from({length:e+1},()=>Array(n+1).fill(0));for(let t=0;t<=e;t++)r[t][0]=t;for(let t=0;t<=n;t++)r[0][t]=t;for(let t=1;t<=e;t++)for(let h=1;h<=n;h++)o[t-1]===c[h-1]?r[t][h]=r[t-1][h-1]:r[t][h]=1+Math.min(r[t-1][h],r[t][h-1],r[t-1][h-1]);let g=[],s=e,l=n;for(;s>0||l>0;)s>0&&l>0&&o[s-1]===c[l-1]?(g.unshift({type:"match",indexA:s-1,indexB:l-1}),s--,l--):s>0&&l>0&&r[s][l]===r[s-1][l-1]+1?(g.unshift({type:"substitute",indexA:s-1,indexB:l-1}),s--,l--):l>0&&r[s][l]===r[s][l-1]+1?(g.unshift({type:"insert",indexA:s,indexB:l-1}),l--):(g.unshift({type:"delete",indexA:s-1,indexB:l}),s--);return{distance:r[e][n],ops:g}}function v(o,c){let e=[];for(let n=0;n<Math.min(o.length,c.length)&&o[n]===c[n];n++)e.push(o[n]);return e}function z(o,c){let e=[],n=o.length-1,r=c.length-1;for(;n>=0&&r>=0&&o[n]===c[r];)e.unshift(o[n]),n--,r--;return e}function k(o,c){if(o.length>c.length)return!1;let e=c.join("\u2192"),n=o.join("\u2192");return e.includes(n)}export{H as a};
2
+ //# sourceMappingURL=chunk-Y7LOQSWY.js.map
@@ -0,0 +1,70 @@
1
+ import{b as E}from"./chunk-GNXRLK5G.js";import{e as h,f as _}from"./chunk-BQ3INTYT.js";import{p as b}from"./chunk-IYFZS4PV.js";import{b as m,d as p}from"./chunk-TINPMWJK.js";function C(e,s={}){let{scope:n,limit:i}=s,l=n?`AND barrel_d.relative_path LIKE '%${n}%'`:"",o=e.all(`SELECT DISTINCT
2
+ barrel_d.id AS barrel_doc_id,
3
+ barrel_d.relative_path AS barrel_path,
4
+ gs.id AS symbol_id,
5
+ gs.symbol AS symbol,
6
+ orig_d.id AS original_doc_id,
7
+ orig_d.relative_path AS original_path
8
+ FROM mentions m
9
+ JOIN chunks c ON m.chunk_id = c.id
10
+ JOIN documents barrel_d ON c.document_id = barrel_d.id
11
+ JOIN global_symbols gs ON m.symbol_id = gs.id
12
+ JOIN (
13
+ SELECT m2.symbol_id, c2.document_id
14
+ FROM mentions m2
15
+ JOIN chunks c2 ON m2.chunk_id = c2.id
16
+ WHERE m2.role = 1
17
+ GROUP BY m2.symbol_id
18
+ ) sym_def ON sym_def.symbol_id = gs.id
19
+ JOIN documents orig_d ON sym_def.document_id = orig_d.id
20
+ WHERE m.role != 1
21
+ AND (barrel_d.relative_path LIKE '%/index.ts'
22
+ OR barrel_d.relative_path LIKE '%/index.js'
23
+ OR barrel_d.relative_path = 'index.ts'
24
+ OR barrel_d.relative_path = 'index.js')
25
+ AND orig_d.id != barrel_d.id
26
+ ${e.pathExclusionsFor("barrel_d","orig_d")}
27
+ ${e.symbolNoiseFor("gs")}
28
+ -- Only function-level symbols (ending with ().), not module-level
29
+ AND gs.symbol LIKE '%().'
30
+ ${l}
31
+ ORDER BY barrel_d.relative_path, gs.symbol`),a=[];for(let r of o){if(e.isIgnored(r.barrel_path)||e.isIgnored(r.original_path)||E(e,r.barrel_path))continue;let t=e.get(`SELECT
32
+ SUM(CASE WHEN uses_barrel = 1 THEN 1 ELSE 0 END) AS barrel_consumers,
33
+ SUM(CASE WHEN uses_barrel = 0 THEN 1 ELSE 0 END) AS direct_consumers
34
+ FROM (
35
+ SELECT
36
+ consumer_d.id AS consumer_doc_id,
37
+ MAX(CASE WHEN EXISTS (
38
+ SELECT 1
39
+ FROM mentions barrel_m
40
+ JOIN chunks barrel_c ON barrel_m.chunk_id = barrel_c.id
41
+ WHERE barrel_c.document_id = consumer_d.id
42
+ AND barrel_m.role != 1
43
+ AND barrel_m.symbol_id IN (
44
+ SELECT m2.symbol_id
45
+ FROM mentions m2
46
+ JOIN chunks c2 ON m2.chunk_id = c2.id
47
+ WHERE c2.document_id = ?
48
+ AND m2.role != 1
49
+ )
50
+ ) THEN 1 ELSE 0 END) AS uses_barrel
51
+ FROM mentions ref_m
52
+ JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
53
+ JOIN documents consumer_d ON ref_c.document_id = consumer_d.id
54
+ WHERE ref_m.symbol_id = ?
55
+ AND ref_m.role != 1
56
+ AND consumer_d.id != ?
57
+ AND consumer_d.id != ?
58
+ ${e.pathExclusionsFor("consumer_d")}
59
+ GROUP BY consumer_d.id
60
+ )`,r.barrel_doc_id,r.symbol_id,r.barrel_doc_id,r.original_doc_id),c=t?.barrel_consumers??0,u=t?.direct_consumers??0;c===0&&u===0&&a.push({barrelFile:r.barrel_path,symbol:r.symbol,shortName:m(r.symbol),originalFile:r.original_path,barrelConsumers:c,directConsumers:u})}a.sort((r,t)=>t.directConsumers-r.directConsumers||r.barrelFile.localeCompare(t.barrelFile)||r.shortName.localeCompare(t.shortName));let d=R([...a,...g(e,n)]);return d.sort((r,t)=>t.directConsumers-r.directConsumers||r.barrelFile.localeCompare(t.barrelFile)||r.shortName.localeCompare(t.shortName)),i?d.slice(0,i):d}function g(e,s){let i=e.all(`SELECT relative_path
61
+ FROM documents
62
+ WHERE 1 = 1
63
+ ${s?"AND relative_path LIKE ?":""}
64
+ ${e.pathExclusionsFor("documents")}
65
+ ORDER BY relative_path`,...s?[`%${s}%`]:[]).map(o=>o.relative_path).filter(o=>!e.isIgnored(o)).filter(o=>_(e,o).length>0),l=[];for(let o of i){let a=_(e,o).filter(r=>r.sourcePath&&!e.isIgnored(r.sourcePath));if(!(a.length===0||f(e,o,o)>0))for(let r of a){let t=r.sourcePath,c=N(e,t);c&&l.push({barrelFile:o,symbol:c.symbol,shortName:m(c.symbol),originalFile:t,barrelConsumers:0,directConsumers:f(e,t,o)})}}return l}function f(e,s,n){let i=e.all(`SELECT relative_path
66
+ FROM documents
67
+ WHERE 1 = 1
68
+ ${e.pathExclusionsFor("documents")}
69
+ ORDER BY relative_path`),l=new Set;for(let o of i)if(!(e.isIgnored(o.relative_path)||o.relative_path===n))for(let a of h(e,o.relative_path))a.sourcePath===s&&l.add(o.relative_path);return l.size}function N(e,s){let n=b(e,s);return n.find(i=>p(i.symbol)==="method")??n[0]??null}function R(e){let s=new Set,n=[];for(let i of e){let l=`${i.barrelFile}|${i.symbol}|${i.originalFile}`;s.has(l)||(s.add(l),n.push(i))}return n}export{C as a};
70
+ //# sourceMappingURL=chunk-YIPCV7M7.js.map
@@ -0,0 +1,5 @@
1
+ import{a as u}from"./chunk-IYFZS4PV.js";import{readdirSync as l}from"fs";import{extname as d,join as p}from"path";var x=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"];var S=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function v(o,i={}){let s=i.includeIndexed??!0,r=i.includeAuxiliary??!0,t=i.extensions?new Set(i.extensions.map(n=>n.toLowerCase())):new Set(x.map(n=>n.toLowerCase())),c=`${s?"1":"0"}|${r?"1":"0"}|${[...t].sort().join(",")}`;return f.get(o,c,()=>{let n=new Set;if(s){let e=o.all(`SELECT relative_path
2
+ FROM documents
3
+ WHERE 1 = 1
4
+ ${o.pathExclusionsFor("documents")}`);for(let a of e)o.isIgnored(a.relative_path)||t.has(d(a.relative_path).toLowerCase())&&n.add(a.relative_path)}if(r)for(let e of g(o.config.projectRoot,t))o.isIgnored(e)||n.add(e);return[...n].sort()})}var f=u("source-files");function g(o,i){let s=new Set,r=t=>{let c=t?p(o,t):o,n=[];try{n=l(c,{withFileTypes:!0})}catch{return}for(let e of n)if(!S.has(e.name)){if(e.isDirectory()){r(t?`${t}/${e.name}`:e.name);continue}i.has(d(e.name).toLowerCase())&&s.add(t?`${t}/${e.name}`:e.name)}};return r(""),s}export{v as a};
5
+ //# sourceMappingURL=chunk-ZSRXMNMK.js.map