scip-query 0.17.1 → 0.17.2
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.
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-HZVG4KID.js → chunk-2A7LUMZP.js} +2 -2
- package/dist/{chunk-WENI5ZDR.js → chunk-4H7T7FIM.js} +2 -2
- package/dist/{chunk-V7MX6YUF.js → chunk-4QBRVI7D.js} +2 -2
- package/dist/chunk-4XTPZ5CR.js +9 -0
- package/dist/chunk-6AITNECC.js +928 -0
- package/dist/chunk-6JSTKSZH.js +3 -0
- package/dist/{chunk-2DUWNJKE.js → chunk-7LERNHDG.js} +2 -2
- package/dist/{chunk-75H6GOND.js → chunk-7ROLM67J.js} +2 -2
- package/dist/{chunk-RPPV6Y4K.js → chunk-7VR5TNOI.js} +2 -2
- package/dist/chunk-A2GX3PYV.js +5 -0
- package/dist/{chunk-E5HPTSRD.js → chunk-APCXCRED.js} +2 -2
- package/dist/{chunk-5QSMW5IO.js → chunk-ATC4MEVA.js} +2 -2
- package/dist/chunk-AWYKDRYV.js +2 -0
- package/dist/{chunk-QYBCGCY5.js → chunk-AY44MGWS.js} +2 -2
- package/dist/{chunk-WT34AUWL.js → chunk-BEGHYHOQ.js} +2 -2
- package/dist/{chunk-JYBP5ZIR.js → chunk-BPMBOZAN.js} +2 -2
- package/dist/{chunk-BW4VDICR.js → chunk-C7MBQSIC.js} +2 -2
- package/dist/{chunk-KWQKWY6M.js → chunk-CHJ3QROR.js} +2 -2
- package/dist/{chunk-BBTVIIOI.js → chunk-CVWX24IY.js} +2 -2
- package/dist/chunk-DJI446FQ.js +18 -0
- package/dist/{chunk-CSMPXDYE.js → chunk-ELLPMCWA.js} +2 -2
- package/dist/{chunk-35DURZXI.js → chunk-FVLZB54V.js} +2 -2
- package/dist/{chunk-WGDIA2TU.js → chunk-G6DDSHMD.js} +2 -2
- package/dist/{chunk-OP5JXGDV.js → chunk-IG6X65MG.js} +2 -2
- package/dist/{chunk-KZ2LZBQT.js → chunk-IKMOYFUM.js} +2 -2
- package/dist/{chunk-G4IUQW27.js → chunk-IS7DZ7TB.js} +2 -2
- package/dist/{chunk-HGO3D2JD.js → chunk-J7IMQRCU.js} +2 -2
- package/dist/{chunk-OBPR6E5Z.js → chunk-K4XL4HOK.js} +2 -2
- package/dist/{chunk-W3HSUCRG.js → chunk-K53GNKY3.js} +2 -2
- package/dist/{chunk-5N5ZC566.js → chunk-K65T4TJS.js} +2 -2
- package/dist/{chunk-OC7XDK62.js → chunk-KA7RMBVU.js} +2 -2
- package/dist/{chunk-IKAJI4SI.js → chunk-KJOKTZUE.js} +2 -2
- package/dist/chunk-KSD6IWF4.js +38 -0
- package/dist/{chunk-SQJ72PQW.js → chunk-LEKXKHIQ.js} +4 -4
- package/dist/{chunk-2TM23JYJ.js → chunk-LFPQFRCX.js} +2 -2
- package/dist/{chunk-Y5BOEWAE.js → chunk-LL5NQB5V.js} +2 -2
- package/dist/{chunk-FY6RCFDH.js → chunk-MBVHEPHQ.js} +2 -2
- package/dist/{chunk-SSH2NPYS.js → chunk-MFIA6EIT.js} +2 -2
- package/dist/{chunk-HYRSGWFX.js → chunk-N3JH45WR.js} +2 -2
- package/dist/{chunk-KWMRY4RN.js → chunk-NJD4C5G5.js} +3 -3
- package/dist/{chunk-UKUISUS6.js → chunk-NJTIAQY7.js} +2 -2
- package/dist/{chunk-LG33DNTZ.js → chunk-NX2YAXVQ.js} +2 -2
- package/dist/{chunk-VDHEX6YO.js → chunk-O5A7BTMA.js} +2 -2
- package/dist/{chunk-FZXN37RN.js → chunk-O7NA5FCA.js} +2 -2
- package/dist/{chunk-U3JW5AYG.js → chunk-OINSINYW.js} +2 -2
- package/dist/{chunk-CKRVVBM6.js → chunk-OQFA2SUQ.js} +2 -2
- package/dist/{chunk-DQYG5JHT.js → chunk-OQFPCIXO.js} +2 -2
- package/dist/{chunk-PPAT3XUL.js → chunk-P6FOIU7O.js} +2 -2
- package/dist/{chunk-7H37Z4UO.js → chunk-PQD7P6WB.js} +2 -2
- package/dist/{chunk-Y4BBVPRK.js → chunk-Q4GKL4CC.js} +2 -2
- package/dist/{chunk-IZLWLO4X.js → chunk-ROMKXEUM.js} +2 -2
- package/dist/{chunk-BTYDBDX5.js → chunk-RUV4KHWA.js} +2 -2
- package/dist/{chunk-O56VBJKB.js → chunk-S22ICAWV.js} +2 -2
- package/dist/chunk-SALRDXWM.js +121 -0
- package/dist/{chunk-MON5XXTG.js → chunk-SON6DQNK.js} +2 -2
- package/dist/{chunk-W2I4QAW7.js → chunk-SSGACGAD.js} +2 -2
- package/dist/{chunk-PA2MQKXD.js → chunk-SUYCF4SX.js} +2 -2
- package/dist/chunk-SXDXR5FH.js +2 -0
- package/dist/{chunk-TR7C5HOC.js → chunk-T4P27T6S.js} +2 -2
- package/dist/{chunk-O27267B6.js → chunk-U4G4UYLB.js} +2 -2
- package/dist/{chunk-MBDBNQBW.js → chunk-W7FNZKX5.js} +2 -2
- package/dist/chunk-WD3PAQJT.js +10 -0
- package/dist/{chunk-623AZLTE.js → chunk-XLJORP6N.js} +2 -2
- package/dist/chunk-XTF6ELXT.js +3 -0
- package/dist/{chunk-7Z5UT44B.js → chunk-YMFHC5J2.js} +2 -2
- package/dist/{chunk-HJYHSTCP.js → chunk-YYYERNQL.js} +2 -2
- package/dist/chunk-Z4MCFCGX.js +3 -0
- package/dist/cli.js +3 -1528
- package/dist/command-descriptors-7UUURHWT.js +599 -0
- package/dist/direct-navigation-CVCFER5G.js +3 -0
- package/dist/index.js +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -0
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -0
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/watch-server.js +4 -4
- package/docs/COMMAND_REFERENCE.md +3 -0
- package/package.json +1 -1
- package/dist/chunk-2HCWAL42.js +0 -3
- package/dist/chunk-3YEBIYXL.js +0 -38
- package/dist/chunk-6TJERPN3.js +0 -2
- package/dist/chunk-E7BTIEAY.js +0 -2
- package/dist/chunk-EUMETOTD.js +0 -21
- package/dist/chunk-GRHA5NGF.js +0 -2
- package/dist/chunk-IHD2CHMX.js +0 -10
- package/dist/chunk-U267E6YN.js +0 -120
- package/dist/chunk-X566NT42.js +0 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as T,c as E,g as L,h as D}from"./chunk-
|
|
1
|
+
import{a as T,c as E,g as L,h as D}from"./chunk-DJI446FQ.js";import{j as O,o as A}from"./chunk-7LERNHDG.js";import{d as H}from"./chunk-KMVGRIO2.js";import{a as _}from"./chunk-RUV4KHWA.js";import{d as C,e as F}from"./chunk-7XP7ZRSI.js";import{a as w}from"./chunk-JLZUM476.js";var J=5;function ae(e,t={}){let{base:a="HEAD",minContainment:o=.7,minCallees:r=3,minSiteCoverage:n=.4,maxHelpers:c=Number.POSITIVE_INFINITY,limit:m=20,scanLimit:g}=t,f=t.semantic!==!1,s=t.diffPlan??E(e,{base:a}),l={available:s.note!==T,base:a,changedFiles:s.changedFiles,helpersChecked:0,skipped:[],findings:[]};if(!l.available||s.changedFiles.length===0)return l;let x=new _(e),k=new Set(s.changedFiles),$=new Map(s.renamedFiles.map(i=>[i.to,i.from])),j=t.baseContentAt??L(e.config.projectRoot,a,D(s)),h=Z(x,k,$,j);if(h.length===0)return l;let R=h.slice(0,c);h.length>c&&(l.note=`helper scoring capped at ${c} of ${h.length} new symbols`);let q=x.calleeMap(R,{semantic:f}),B=R.map(i=>({def:i,callees:A((q.get(i.symbolId)??[]).map(p=>p.symbol))})),V=O(e),M,G=()=>(M??=V.calleeIndex({minCallees:Math.min(3,r),scanLimit:g,semantic:f}),M);for(let{def:i,callees:p}of B){let d=C(i.symbol);if(p.size<r){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let P=G(),N=Y(p,P);if(N===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let b=Q(e,i.symbolId);if(b.length===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}l.helpersChecked+=1;let I=K({candidateIndex:P,changed:k,helperCallees:p,helperFile:i.relativePath,helperSymbol:i.symbol,minContainment:o,minSiteCoverage:n,migratedFiles:b});I.length!==0&&(I.sort((u,S)=>z(S.migrationScope)-z(u.migrationScope)||S.containment-u.containment||S.siteCoverage-u.siteCoverage||u.file.localeCompare(S.file)),l.findings.push({helperSymbol:i.symbol,helperShortName:d,helperFile:i.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:N,migratedFiles:b.sort(),leftovers:I.slice(0,J)}))}return l.findings.sort((i,p)=>(p.leftovers[0]?.containment??0)-(i.leftovers[0]?.containment??0)||i.helperFile.localeCompare(p.helperFile)),l.findings=l.findings.slice(0,m),l}function K(e){let t=[],a=U(e.helperSymbol,e.helperFile,e.migratedFiles),o=new Set;for(let r of e.helperCallees)for(let n of e.candidateIndex.candidateIndexesByCallee.get(r)??[])o.add(n);for(let r of o){let n=e.candidateIndex.corpus[r];if(n.symbol===e.helperSymbol||e.changed.has(n.file)||n.callees.has(e.helperSymbol))continue;let c=H(e.helperCallees,n.callees);if(c<e.minContainment)continue;let m=[...e.helperCallees].filter(s=>n.callees.has(s)),g=n.callees.size===0?0:m.length/n.callees.size;if(g<e.minSiteCoverage||!m.some(s=>(e.candidateIndex.docFreq.get(s)??0)<=e.candidateIndex.ubiquityThreshold))continue;let f=W(a,n.symbol,n.file);t.push({symbol:n.symbol,shortName:C(n.symbol),file:n.file,...f,containment:c,siteCoverage:g,uniqueSiteCalleeCount:Math.max(0,n.callees.size-m.length),sharedCallees:m.map(C).sort()})}return t}function z(e){return e==="same-scope"?2:e==="unknown"?1:0}function U(e,t,a){let o=new Set([...y(t),...v(F(e))]);for(let r of a)for(let n of y(r))o.add(n);return o}function W(e,t,a){let o=new Set([...y(a),...v(F(t))]);if(e.size===0||o.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...o].filter(n=>e.has(n)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var X=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function y(e){return v(e.replace(/\.[^.]+$/,""))}function v(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!X.has(t))}function Y(e,t){let a=0;for(let o of e)(t.docFreq.get(o)??0)<=t.ubiquityThreshold&&(a+=1);return a}function Z(e,t,a,o){return e.productionCallableDefinitions({files:[...t],requireFunctionLikeSymbol:!0}).filter(r=>{if(!t.has(r.relativePath))return!1;let n=a.get(r.relativePath)??r.relativePath,c=o(n);return c===null||!new RegExp(`\\b${w(r.leaf)}\\b`).test(c)})}function Q(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
5
5
|
WHERE m.symbol_id = ?
|
|
6
6
|
AND m.role != 1
|
|
7
7
|
${e.pathExclusionsFor("ref_d")}`,t).map(o=>o.relative_path)}export{ae as a};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-FVLZB54V.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./chunk-BGUYAA3Q.js";import{c as C}from"./chunk-
|
|
1
|
+
import{a as M}from"./chunk-BGUYAA3Q.js";import{c as C}from"./chunk-P6FOIU7O.js";import{a as I}from"./chunk-RUV4KHWA.js";import{h as d}from"./chunk-KSD6IWF4.js";import{f as h}from"./chunk-NJD4C5G5.js";import{d as f}from"./chunk-MTDBHTSF.js";import{d as g}from"./chunk-7XP7ZRSI.js";import{f as y}from"./chunk-JLZUM476.js";var x=new Set(f());function N(e,n){let{scope:o,minLoc:r=10,limit:i=30,scanLimit:t}=n??{},s=new I(e);return M({candidates:()=>s.productionCallableDefinitions({scope:o,minLoc:r,requireFunctionLikeSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof t=="number"&&t>0}),scanLimit:t,filterCandidate:S,profile:{name:"complexity-hotspots"},prepare:a=>{let l=B(e,a),m=n?.semantic!==!1,c=m?h(e):null;c?.materializeReferences(a,{prefetchCallees:!0});let u=s.crossFileCallerMap(a,{semantic:!1});return{callerMap:c?d(u,c.callerMap(a)):u,calleeMap:s.calleeMap(a,{semantic:m}),languageByFile:l,clojureCallableIds:D(e,a,l),branchEstimates:C(e,a)}},evaluate:(a,l)=>L(a,l,r),orderResults:(a,l)=>l.score-a.score||l.loc-a.loc,limit:i})}function S(e){return e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&x.has(e.kind):!0}function L(e,n,o){if(n.languageByFile.get(e.relativePath)==="clojure"&&!n.clojureCallableIds.has(e.symbolId))return null;let r=e.endLine-e.startLine+1;if(r<o)return null;let i=n.callerMap.get(e.symbolId)?.size??0,t=n.calleeMap.get(e.symbolId)??[],s=new Set,a=new Set;for(let p of t){let b=`${p.symbol}|${p.file}`;s.add(b),p.file!==e.relativePath&&a.add(b)}let l=a.size,m=s.size,c=n.branchEstimates.get(e.symbolId)??{branches:0,estimateBasis:"regex-fallback"},u=c.branches+1;return{symbol:e.symbol,shortName:g(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:r,fanIn:i,fanOut:l,calleeCount:m,branches:c.branches,estimateBasis:c.estimateBasis,score:Math.round(r/50*(i/5)*Math.max(l/5,1)*Math.max(u/5,1)*100)/100}}function B(e,n){let o=[...new Set(n.map(t=>t.relativePath))];if(o.length===0)return new Map;let r=o.map(()=>"?").join(", "),i=e.all(`SELECT relative_path, language
|
|
2
2
|
FROM documents
|
|
3
3
|
WHERE relative_path IN (${r})`,...o);return new Map(i.map(t=>[t.relative_path,t.language?.toLowerCase()??null]))}function D(e,n,o){let r=new Set,i=new Map;for(let t of n){if(o.get(t.relativePath)!=="clojure")continue;let s=i.get(t.relativePath);s||(s=new Set((y(e,t.relativePath)?.callables??[]).map(a=>`${a.name}:${a.startLine}`)),i.set(t.relativePath,s)),s.has(`${t.leaf}:${t.startLine}`)&&r.add(t.symbolId)}return r}export{N as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-G6DDSHMD.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as U}from"./chunk-QZ4JVECJ.js";import{a as G}from"./chunk-WXVGNFAO.js";import{a as _}from"./chunk-
|
|
1
|
+
import{a as U}from"./chunk-QZ4JVECJ.js";import{a as G}from"./chunk-WXVGNFAO.js";import{a as _}from"./chunk-4XTPZ5CR.js";import{h as F,o as O,p as L,q as H,s as $,v as K,x as z,y as X}from"./chunk-M2TRDR25.js";import{existsSync as Y,readFileSync as P,statSync as St}from"fs";import{join as T}from"path";function I(t,n){let e=it(t,n)??rt(t,n)??ot(t,n)??st(t,n);return ct(t,e,n)}function it(t,n){let e=-1,i=null;for(let r=0;r<=n;r+=1){let o=j(t[r]??"");o&&(i===null?(i=o,e=r):o===i&&(i=null,e=-1))}if(i===null||e<0)return null;for(let r=n+1;r<t.length;r+=1)if(j(t[r]??"")===i)return{start:e,end:r+1};return{start:e,end:t.length}}function j(t){let n=t.match(/^\s*(```+|~~~+)/);return n?n[1].startsWith("`")?"`":"~":null}function rt(t,n){if(!v(t[n]??""))return null;let e=n;for(;e>0&&v(t[e-1]??"");)e-=1;let i=n+1;for(;i<t.length&&v(t[i]??"");)i+=1;return{start:e,end:i}}function v(t){let n=t.trim();return n.startsWith("|")&&n.endsWith("|")&&n.includes("|")}function ot(t,n){let e=n;for(;e>=0;){let o=t[e]??"";if(w(o)!==null)break;if(N(o)!==null)return null;e-=1}if(e<0)return null;let i=w(t[e]??"");if(i===null)return null;let r=e+1;for(;r<t.length;){let o=t[r]??"",s=w(o);if(s!==null){if(s<=i)break;r+=1;continue}if(N(o)!==null)break;r+=1}return{start:e,end:r}}function w(t){let n=t.match(/^(\s*)(?:[-*+]\s+|\d+[.)]\s+)/);return n?n[1].length:null}function st(t,n){let e=t[n]??"";if(V(e)||e.trim().length===0)return{start:n,end:n+1};let i=n;for(;i>0&&q(t[i-1]??"");)i-=1;let r=n+1;for(;r<t.length&&q(t[r]??"");)r+=1;return{start:i,end:r}}function q(t){return N(t)===null}function N(t){return t.trim().length===0?"blank":V(t)?"heading":j(t)?"fence":v(t)?"table":w(t)!==null?"list":null}function V(t){return/^#{1,6}\s+/.test(t.trim())}function ct(t,n,e){let{start:i,end:r}=n;if(r-i>40){let s=Math.floor(20);i=Math.max(i,e-s),r=Math.min(r,i+40),i=Math.max(n.start,r-40)}let o=t.slice(i,r).join(`
|
|
2
2
|
`).trim();return o.length<=2e3?o:`${o.slice(0,2e3).trimEnd()}...`}function R(t,n){return n.filter(e=>t.includes(e))}import{existsSync as at,readFileSync as W}from"fs";var lt=/<!--\s*scip-query:\s*snapshot\s*-->/i;function Z(t,n){if((t.config.docs?.snapshotPaths??[]).some(r=>U(r,n)))return!0;let i=X(t,n);return i.length>0&<.test(i)}var J={classifyCitation:ut,citationContexts:ft,citationKindLabel:mt,citationRemediation:ht,referenceTargets:pt,hasLineAnchoredCitation:dt};function dt(t){return t.some(n=>(n.lineReferences?.length??0)>0)}function ut(t){let n=t.join(`
|
|
3
3
|
`).toLowerCase(),e=[],i=R(n,[".scipquery","declaredcouplings","suppression","suppressions","config","configuration","json"]);if(i.length>0)return e.push(`configuration/example terms near citation: ${i.join(", ")}`),{citationKind:"configuration-example",actionTier:"support",reasons:e};let r=R(n,["accepted","intentional","intentionally","retained","historical"]);if(r.length>0)return e.push(`intentional-record terms near citation: ${r.join(", ")}`),{citationKind:"intentional-record",actionTier:"support",reasons:e};let o=R(n,["command","cli","usage","example","run","workflow"]);return o.length>0?(e.push(`guide/reference terms near citation: ${o.join(", ")}`),{citationKind:"guide-reference",actionTier:"signal",reasons:e}):(e.push(t.length>0?"citation appears in prose without config or guide markers":"citation context unavailable"),{citationKind:"behavioral-claim",actionTier:"direct",reasons:e})}function ft(t,n,e){let i;try{i=W(`${t.config.projectRoot}/${n}`,"utf-8").split(/\r?\n/)}catch{return[]}let r=e.flatMap(gt),o=[];for(let s=0;s<i.length;s+=1){let c=i[s]??"";r.some(a=>c.includes(a))&&o.push(I(i,s))}return o}function gt(t){let n=t.split("/");return[t,`./${t}`,n.slice(-3).join("/"),n.slice(-2).join("/")].filter((e,i,r)=>e.length>0&&r.indexOf(e)===i)}function mt(t){switch(t){case"behavioral-claim":return"a behavioral doc claim";case"configuration-example":return"a configuration example";case"guide-reference":return"a guide reference";case"intentional-record":return"an intentional record"}}function ht(t,n){switch(t){case"behavioral-claim":return`Re-read ${n} and update the behavioral claim or citation.`;case"configuration-example":return`Verify the configuration example in ${n} still points at the intended file; update only if the example target changed.`;case"guide-reference":return`Verify the guide reference in ${n} still sends readers to the right implementation or command surface.`;case"intentional-record":return`Verify the intentional citation in ${n} is still meant to name this file.`}}function pt(t,n,e){let i=G(e),r=new Set;for(let o of n)yt(t,o,i.get(o)??[])&&r.add(o);return r}function yt(t,n,e){if(!Ct.test(n))return!0;let i=`${t.config.projectRoot}/${n}`;if(!at(i))return!0;if(e.length===0)return!1;let r=W(i,"utf-8").split(/\r?\n/),o=bt(r);for(let s of e)for(let c=s.startLine;c<=s.endLine;c+=1)if((r[c]??"").trim()!==""&&!o.has(c))return!0;return!1}var Ct=/\.(?:[cm]?[jt]sx?)$/i;function bt(t){let n=new Set,e=!1;for(let i=0;i<t.length;i+=1){let r=t[i].trim();!e&&Dt(r)&&(e=!0),e&&(n.add(i),r.endsWith(";")&&(e=!1))}return n}function Dt(t){return/^import(?:\s|$)/.test(t)||/^export(?:\s+type)?\s+(?:\*|\{)/.test(t)}var Q=K({kind:"doc-path-evidence",invalidation:z("doc-path-evidence"),serialize:Nt,deserialize:Bt}),M=/\.(?:md|mdx|rst|txt)$/i;function xt(t){return/(?:^|\/)(?:docs\/plans|plans|adrs?|rfcs?|decisions|changelogs?|archive|reports?)\//i.test(t)||/(?:^|\/)CHANGELOG\.(?:md|mdx|rst|txt)$/i.test(t)}var Rt=3,Tt=/([A-Za-z0-9_@-]+(?:\/[A-Za-z0-9_.@-]+)+\.[A-Za-z0-9]{1,6})(?::([1-9][0-9]*))?\b/g;function sn(t,n={}){let{doc:e,limit:i=20,minCoupling:r=Rt,includeSnapshotExcluded:o=!1}=n,s=wt(t,n.historyMode??"bounded");if(!s)return{available:!1,commitsAnalyzed:0,docsScanned:0,findings:[]};let c=[];for(let a of s.docFiles){if(e!==void 0&&!a.includes(e)||e===void 0&&!tt(t,a)||e!==void 0&&!Y(T(t.config.projectRoot,a)))continue;let d=Z(t,a);if(d&&!o)continue;let{value:p,estimated:y}=At(t,a,s.changeTimes.get(a)),g=Mt(t,a),u=new Map,{resolved:l,broken:m,citations:D}=kt(t,a,s.tracked,s.trackedBySuffix,s.everSeenInHistory),S=new Map(D.map(f=>[f.file,f]));for(let f of l){if(f===a||M.test(f))continue;let C=(s.changeTimes.get(f)??[]).filter(b=>b>p).length;if(C===0)continue;let h=S.get(f);u.set(f,{file:f,evidence:"reference",coChanges:0,changesSinceDocUpdate:C,...B("reference",g,h?.contexts),citationContexts:h?.contexts,citedLines:h?.lineReferences})}for(let[f,C]of s.coupling.get(a)??[]){if(C<r||!s.tracked.has(f))continue;let h=(s.changeTimes.get(f)??[]).filter(A=>A>p).length;if(h===0)continue;let b=u.get(f);b?(b.evidence="both",b.coChanges=C,Object.assign(b,B("both",g,b.citationContexts))):u.set(f,{file:f,evidence:"co-change",coChanges:C,changesSinceDocUpdate:h,...B("co-change",g)})}if(u.size===0&&m.length===0)continue;let x=[...u.values()].sort((f,C)=>C.changesSinceDocUpdate-f.changesSinceDocUpdate);c.push({doc:a,docLastChangedAt:p,staleness:x.reduce((f,C)=>f+C.changesSinceDocUpdate,0)+m.length*10,subjects:x.slice(0,8),brokenReferences:m,...d?{snapshotExcluded:!0}:{},...y?{docLastChangedAtEstimated:!0}:{}})}return c.sort((a,d)=>d.staleness-a.staleness),{available:!0,commitsAnalyzed:s.historyCommitCount,docsScanned:s.docFiles.length,findings:c.slice(0,i)}}function At(t,n,e){if(e&&e.length>0)return{value:Math.max(...e),estimated:!1};try{return{value:Math.floor(St(T(t.config.projectRoot,n)).mtimeMs/1e3),estimated:!0}}catch{return{value:0,estimated:!1}}}function Mt(t,n){let e;try{e=P(T(t.config.projectRoot,n),"utf8").slice(0,6e3)}catch{return{docIntent:"unknown",reasons:["doc text unavailable"]}}let i=`${n}
|
|
4
4
|
${e}`.toLowerCase(),r=R(i,["historical note","historical record","history note","retrospective","postmortem","post-mortem","archived","archive","previously","legacy","recorded","record of","snapshot","as of","migration note","decision record"]);if(r.length>0)return{docIntent:"historical-note",reasons:[`historical-note terms: ${r.join(", ")}`]};let o=R(i,["current","standard","standards","must","should","policy","guide","guidance","workflow","contract","invariant","source of truth"]);return o.length>0?{docIntent:"current-guidance",reasons:[`current-guidance terms: ${o.join(", ")}`]}:{docIntent:"unknown",reasons:["no current-guidance or historical-note markers found"]}}function B(t,n,e=[]){let i=t==="co-change"||e.length===0?null:J.classifyCitation(e);return{actionTier:vt(t,n.docIntent,i?.actionTier),docIntent:n.docIntent,docIntentReasons:n.reasons,...i?{citationKind:i.citationKind,citationKindReasons:i.reasons}:{}}}function vt(t,n,e){return n==="historical-note"?"support":e||(t==="co-change"?"signal":"direct")}function wt(t,n){let e=_(t,{historyMode:n}),i=e.commitHistory();if(!i)return null;let r=e.trackedFiles()??new Set,o=new Map,s=new Map,c=new Set;for(let a of i.commits){let d=[...new Set(a.files)],p=d.filter(g=>M.test(g)),y=d.filter(g=>!M.test(g));for(let g of d){c.add(g);let u=o.get(g)??[];u.push(a.timestamp),o.set(g,u)}for(let g of p){let u=s.get(g);u||(u=new Map,s.set(g,u));for(let l of y)u.set(l,(u.get(l)??0)+1)}}return{changeTimes:o,coupling:s,docFiles:[...r].filter(a=>M.test(a)),everSeenInHistory:c,historyCommitCount:i.commits.length,tracked:r,trackedBySuffix:nt(r)}}function cn(t,n){if(n.size===0)return[];let e=H(),i=0,r=0,o=0,s=0,c=0,a=0;return $("doc-reference.docs-citing-files",()=>{let d=_(t).trackedFiles()??new Set;i=d.size;let p=nt(d),y=It(n,p),g=[];for(let u of d){if(!tt(t,u))continue;e&&(r+=1);let l;try{l=P(T(t.config.projectRoot,u),"utf-8")}catch{e&&(o+=1);continue}if(!_t(l,y)){e&&(s+=1);continue}let m=et(t,u,l);if(!m)continue;e&&(c+=1);let D=Et(m.candidates,n,y,d,p);if(D.size===0)continue;let S=[...new Set([...D.values()].flatMap(h=>[...h]))],x=Lt(m.contextsByCandidate,S),f=[...D].map(([h,b])=>({file:h,contexts:E([...b].flatMap(A=>x.get(A)??[])).slice(0,3),lineReferences:k([...b].flatMap(A=>m.lineReferencesByCandidate.get(A)??[]))})).filter(h=>h.contexts.length>0),C=[...D.keys()];if(C.length>0){e&&(a+=1);let h=C.sort();g.push({doc:u,cited:h,citations:f,citedClaims:E(f.flatMap(b=>b.contexts)).slice(0,3)})}}return g},()=>({targets:n.size,trackedFiles:i,livingDocs:r,unreadableDocs:o,candidateMisses:s,evidenceDocs:c,citedDocs:a}))}function tt(t,n){return M.test(n)&&!xt(n)&&Y(T(t.config.projectRoot,n))}function nt(t){let n=new Map;for(let e of t){let i=e.split("/");for(let r of[2,3]){if(i.length<r)continue;let o=i.slice(-r).join("/"),s=n.get(o)??[];s.push(e),n.set(o,s)}}return n}function It(t,n){let e=new Set(t);for(let i of t){let r=i.split("/");for(let o of[2,3]){if(r.length<o)continue;let s=r.slice(-o).join("/"),c=n.get(s);c?.length===1&&c[0]===i&&e.add(s)}}return e}function Et(t,n,e,i,r){let o=new Map;for(let s of t){if(!e.has(s))continue;let c;if(n.has(s))c=s;else if(i.has(s))c=s;else{let d=r.get(s);d?.length===1&&(c=d[0])}if(!c||!n.has(c))continue;let a=o.get(c)??new Set;a.add(s),o.set(c,a)}return o}function kt(t,n,e,i,r){let o=new Set,s=new Set,c=et(t,n);if(!c)return{resolved:o,broken:[],citations:[]};let a=c.candidates,d=c.contextsByCandidate,p=c.lineReferencesByCandidate,y=new Map,g=new Map,u=(l,m)=>{let D=d.get(m);if(D&&D.length>0){let x=y.get(l)??[];x.push(...D),y.set(l,E(x).slice(0,3))}let S=p.get(m);S&&S.length>0&&g.set(l,k([...g.get(l)??[],...S]))};for(let l of a){if(e.has(l)){o.add(l),u(l,l);continue}let m=i.get(l);if(m&&m.length===1){o.add(m[0]),u(m[0],l);continue}m&&m.length>1||r.has(l)&&s.add(l)}return{resolved:o,broken:[...s],citations:[...y].map(([l,m])=>({file:l,contexts:m,lineReferences:g.get(l)}))}}function Lt(t,n){let e=new Map;for(let i of n){let r=t.get(i);r&&r.length>0&&e.set(i,[...r])}return e}function et(t,n,e){let i=e;if(i===void 0)try{i=P(T(t.config.projectRoot,n),"utf-8")}catch{return null}let r=F(t,n,i),o=Q.read(t,n,r);if(o)return o;let s=jt(i);return Q.write(t,n,r,s),s}function _t(t,n){for(let e of n)if(t.includes(e))return!0;return!1}function jt(t){let n=t.split(/\r?\n/),e=new Set,i=new Map,r=new Map;for(let o=0;o<n.length;o+=1){let s=n[o]??"";for(let c of s.matchAll(Tt)){let a=(c[1]??"").replace(/^\.?\//,"");if(a.length===0)continue;e.add(a);let d=c[2]?Number(c[2]):null;d!==null&&Number.isSafeInteger(d)&&r.set(a,k([...r.get(a)??[],d]));let p=I(n,o);if(p.length===0)continue;let y=i.get(a)??[];y.push(p),i.set(a,E(y).slice(0,3))}}return{candidates:[...e],contextsByCandidate:i,lineReferencesByCandidate:r}}function Nt(t){let n={candidates:t.candidates,contextsByCandidate:[...t.contextsByCandidate.entries()],lineReferencesByCandidate:[...t.lineReferencesByCandidate.entries()]};return JSON.stringify(n)}function Bt(t){try{let n=JSON.parse(t);if(!O(n))return null;let e=L(n.candidates),i=Ft(n.contextsByCandidate),r=Pt(n.lineReferencesByCandidate);return!e||!i?null:{candidates:e,contextsByCandidate:new Map(i),lineReferencesByCandidate:new Map(r??[])}}catch{return null}}function Pt(t){if(t===void 0)return[];if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string"||!Array.isArray(e[1]))return null;let i=[];for(let r of e[1]){if(typeof r!="number"||!Number.isSafeInteger(r))return null;i.push(r)}n.push([e[0],k(i)])}return n}function Ft(t){if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;let i=L(e[1]);if(!i)return null;n.push([e[0],i])}return n}function E(t){let n=[];for(let e of new Set(t))n.some(i=>Ot(i,e))||n.push(e);return n}function k(t){return[...new Set(t)].sort((n,e)=>n-e)}function Ot(t,n){if(t===n)return!0;let e=t.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0),i=n.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0),r=Math.min(e.length,i.length);if(r===0)return!1;if(r<3)return t.includes(n)||n.includes(t);let o=new Set(i),s=e.filter(c=>o.has(c)).length;return s>=3&&s/r>=.6}export{Z as a,J as b,xt as c,sn as d,cn as e};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-IG6X65MG.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as y}from"./chunk-
|
|
1
|
+
import{b as y}from"./chunk-4XTPZ5CR.js";import{b as I}from"./chunk-B75HZHUP.js";import{b as w}from"./chunk-5CJ6AQN7.js";import{d as k}from"./chunk-JLZUM476.js";import{L as R}from"./chunk-TLTLJ4SW.js";import{y as b}from"./chunk-M2TRDR25.js";var C=60;function nt(t,s={}){let{scope:n,limit:e=30,scanLimit:i,rotDays:r=C}=s,c=I(R(t,{extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs"]}).filter(a=>w(a)==="test").filter(a=>!n||a.includes(n)).filter(a=>!t.isIgnored(a)).sort(),i),o=[],l=[],p=[];for(let a of c){let d=b(t,a);if(!d)continue;let x=k(d),h=K(d);for(let u of j(x,h))h.add(u);let O=P(x);for(let u of O){if(u.skip){l.push(H(t,a,u,r));continue}if(u.kind==="describe")continue;let S=F(d,u.argsStart),m=x.slice(u.argsStart,u.callEnd),M=d.slice(u.argsStart,u.callEnd);_(m,h)||o.push({file:a,startLine:f(d,u.callStart),endLine:f(d,u.callEnd),title:S,severity:/\bawait\b/.test(m)?"low":"high"});let A=B(m,M);A&&p.push({file:a,startLine:f(d,u.callStart),endLine:f(d,u.callEnd),title:S,echoedValue:A})}}return{assertionFree:e?o.slice(0,e):o,skipped:e?l.slice(0,e):l,mockEcho:e?p.slice(0,e):p}}var E=/(?<!\.)\b(?:x(it|test|describe)|(it|test|describe)(?:\.\s*(skip|only|todo|each\s*\([^)]*\)))?)\s*\(/g;function P(t){let s=[];E.lastIndex=0;let n;for(;n=E.exec(t);){let e=n[1],i=e??n[2];if(!i)continue;let r=n[3]?.split(/\s*\(/)[0],c=n.index,o=n.index+n[0].length-1,l=g(t,o);E.lastIndex=o+1,r!=="each"&&s.push({kind:i,skip:e!==void 0||r==="skip"||r==="todo",skipKind:r==="todo"?"todo":"skip",callStart:c,argsStart:o+1,callEnd:l+1})}return s}function g(t,s){let n=0;for(let e=s;e<t.length;e+=1){let i=t[e];if(i==="(")n+=1;else if(i===")"&&(n-=1,n===0))return e}return t.length-1}function f(t,s){let n=0;for(let e=0;e<s&&e<t.length;e+=1)t[e]===`
|
|
2
2
|
`&&(n+=1);return n}function F(t,s){let n=t.slice(s,s+400),e=/^\s*(['"`])((?:\\.|(?!\1)[\s\S])*)\1/.exec(n);return e?e[2]:"(anonymous)"}var D=new Set(["vitest","chai","jest","@jest/globals","assert","node:assert","node:assert/strict","assert/strict","uvu/assert","expect","chai-as-promised"]),L=/import\s+(?:\*\s+as\s+(\w+)|\{([^}]*)\}|(\w+))\s+from\s+['"]([^'"]+)['"]/g;function K(t){let s=new Set(["expect","assert"]);L.lastIndex=0;let n;for(;n=L.exec(t);){let[,e,i,r,c]=n;if(!(!c||!D.has(c))&&(e&&s.add(e),r&&s.add(r),i))for(let o of i.split(",")){let l=o.trim().replace(/^type\s+/,"");if(!l)continue;let p=/^(\w+)\s+as\s+(\w+)$/.exec(l);s.add(p?p[2]:l)}}return s}function _(t,s){if(/\.should\b/.test(t)||/\bawait\s+(?:[\w$.]+\.)?findBy[A-Z]\w*\s*\(/.test(t)||/\bawait\s+\w*waitFor(?:Text|Value|Condition|Result|Event)\s*\(/.test(t)||/\bthrow\b/.test(t))return!0;for(let n of s){let e=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${e}\\s*(?:<[^<>]*>)?\\s*[.(]`).test(t))return!0}return!1}var v=/\bfunction\s+(\w+)\s*\(/g,V=/\b(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\(/g,$=60;function j(t,s){let n=new Set;for(let e of[v,V]){e.lastIndex=0;let i;for(;i=e.exec(t);){let r=i[1],c=i.index+i[0].length-1,o=g(t,c),l=t.indexOf("{",o+1);if(l===-1||l-o>$)continue;let p=Q(t,l),a=t.slice(l+1,p);_(a,s)&&n.add(r)}}return n}function Q(t,s){let n=0;for(let e=s;e<t.length;e+=1){let i=t[e];if(i==="{")n+=1;else if(i==="}"&&(n-=1,n===0))return e}return t.length-1}var U=/\bmock(?:ReturnValue|ResolvedValue)(?:Once)?\s*\(/g,T=/\bexpect\s*\(/g,q=/^\s*\.\s*(?:toBe|toEqual|toStrictEqual)\s*\(/,N=/^(?:-?\d+(?:\.\d+)?|(['"`]).+\1)$/;function B(t,s){let n=G(t,s,U);if(n.length===0)return null;let e=Y(t,s);for(let i of e)if(n.includes(i))return i;return null}function G(t,s,n){let e=[];n.lastIndex=0;let i;for(;i=n.exec(t);){let r=i.index+i[0].length-1,c=g(t,r),o=s.slice(r+1,c).trim();N.test(o)&&e.push(o),n.lastIndex=c+1}return e}function Y(t,s){let n=[];T.lastIndex=0;let e;for(;e=T.exec(t);){let i=e.index+e[0].length-1,r=g(t,i),c=t.slice(r+1),o=q.exec(c);if(T.lastIndex=r+1,!o)continue;let l=r+1+o[0].length-1,p=g(t,l),a=s.slice(l+1,p).trim();N.test(a)&&n.push(a)}return n}function H(t,s,n,e){let i=b(t,s),r=F(i,n.argsStart),c=f(i,n.callStart),o=X(t.config.projectRoot,s,c),l=o===null?"unknown":o>=e?"rot":"workflow";return{file:s,startLine:c,title:r,skipKind:n.skipKind,blockKind:n.kind,ageDays:o,rot:l}}function X(t,s,n){let e=n+1;try{let i=y(t,["blame","-L",`${e},${e}`,"--porcelain","--",s]),r=/^author-time (\d+)$/m.exec(i);if(!r)return null;let c=Number(r[1]);return Number.isFinite(c)?Math.max(0,Math.round((Date.now()/1e3-c)/86400)):null}catch{return null}}export{nt as a};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-IKMOYFUM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as m}from"./chunk-B75HZHUP.js";import{a as g,c as b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as m}from"./chunk-B75HZHUP.js";import{a as g,c as b}from"./chunk-KSD6IWF4.js";import{m as y}from"./chunk-MBVHEPHQ.js";import{a as c}from"./chunk-6JSTKSZH.js";import{d as r}from"./chunk-7XP7ZRSI.js";function v(l,t,n={}){let o=c(l,t);if(!o)return null;let a=[{file:o.relativePath,line:o.startLine}],s=y(l,o,{semantic:n.semantic}).map(e=>({file:e.file,line:e.line,enclosingSymbol:e.enclosingSymbol??"(top-level)",enclosingShort:e.enclosingSymbol?r(e.enclosingSymbol):"(top-level)"})),{producers:f,consumers:i}=S(l,o,s,{semantic:n.semantic!==!1});return{symbol:o.symbol,shortName:r(o.symbol),relativePath:o.relativePath,definitionSites:a.filter(e=>!l.isIgnored(e.file)),usageSites:s,producers:f.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:r(e.symbol),file:e.file})),consumers:i.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 S(l,t,n,o){let a=m(g(l,t,{limit:30,semantic:o.semantic}).map(i=>({symbol:i.symbol,file:i.file}))),s=m(b(l,t,{limit:30,semantic:o.semantic})),f=s.length>0?s:m(n.map(i=>({symbol:i.enclosingSymbol==="(top-level)"?i.file:i.enclosingSymbol,file:i.file})));return{producers:a,consumers:f}}export{v as a};
|
|
2
|
+
//# sourceMappingURL=chunk-IS7DZ7TB.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as B,g as S}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{f as B,g as S}from"./chunk-O5A7BTMA.js";import{b as O}from"./chunk-B75HZHUP.js";import{b as L,c as k}from"./chunk-5CJ6AQN7.js";import{a as E}from"./chunk-BGBBVSH4.js";import{d as P}from"./chunk-MTDBHTSF.js";import{d as I,g as z,j as D,t as $}from"./chunk-7XP7ZRSI.js";import{b as T,k as v,p as A}from"./chunk-JLZUM476.js";import{c as b}from"./chunk-TLTLJ4SW.js";import{C as _,s as p}from"./chunk-M2TRDR25.js";var U=new Set(P());function $e(e,t={}){let{includeHomonyms:n=!1,limit:i}=t,s=X(e,t).filter(r=>r.relationship==="divergent"||n&&r.relationship==="homonym");return i?s.slice(0,i):s}function X(e,t={}){let{scope:n,minSimilarity:i=.3,scanLimit:s}=t,r=Q(e,{scope:n,scanLimit:s});return Y(r,{minSimilarity:i,isDelegatePair:De(e)}).filter(a=>!a.members.some(o=>_(e,o.file,o.startLine,"twin")))}function Y(e,t={}){let n=t.minSimilarity??.3,i=t.isDelegatePair,s=e.filter(c=>!V(c.leaf)&&!fe(c.leaf)&&L(c.file)!=="test"&&!D(c.symbol)&&!Z(c.symbol)&&!j(c.symbol,c.leaf)),{recordsByLeaf:r,recordOrder:a}=p("twin-drift.group-by-leaf",()=>q(s),()=>({records:s.length})),o=p("twin-drift.cluster-leaf-names",()=>W([...r.keys()]),()=>({leaves:r.size}));return p("twin-drift.compare-clusters",()=>{let c=[];for(let h of o){let u=J(h,r,a);if(u.length<2||new Set(u.map(f=>f.file)).size<2)continue;let m=null,R=!1,C=!1,y=new Set;for(let f=0;f<u.length;f+=1)for(let w=f+1;w<u.length;w+=1){let d=u[f],g=u[w];if(d.file===g.file||!ge(d,g)||i?.(d,g,u)||i?.(g,d,u))continue;if(R=!0,y.add(d.symbol),y.add(g.symbol),d.normalizedBody===g.normalizedBody){C=!0;continue}let M=oe(d.tokens,g.tokens);(!m||M>m.similarity)&&(m={a:d,b:g,similarity:M})}if(!R)continue;let x=u.filter(f=>y.has(f.symbol)).sort((f,w)=>f.file.localeCompare(w.file)||f.startLine-w.startLine).map(se);if(!m){c.push({leaf:G(h),relationship:C?"identical":"homonym",maxDivergence:0,members:x});continue}let N=m.similarity>=n?"divergent":"homonym";c.push({leaf:G(h),relationship:N,maxDivergence:Math.round((1-m.similarity)*1e3)/1e3,members:x,...N==="divergent"?{firstDivergentTokens:ae(m.a.tokens,m.b.tokens)}:{}})}return c},()=>({clusters:o.length,records:s.length})).sort((c,h)=>h.members.length-c.members.length||h.maxDivergence-c.maxDivergence||c.leaf.localeCompare(h.leaf))}function q(e){let t=new Map,n=new Map;for(let[i,s]of e.entries()){let r=t.get(s.leaf)??[];r.push(s),t.set(s.leaf,r),n.set(s,i)}return{recordsByLeaf:t,recordOrder:n}}function J(e,t,n){let i=[...e].flatMap(s=>t.get(s)??[]);return e.size>1&&i.sort((s,r)=>(n.get(s)??0)-(n.get(r)??0)),i}function Q(e,t){let n=p("twin-drift.load-definitions",()=>$(e,{scope:t.scope}).filter(r=>ee(r)&&!e.isIgnored(r.relativePath)).filter(r=>!k(r.relativePath)));p("twin-drift.sort-definitions",()=>n.sort((r,a)=>r.relativePath.localeCompare(a.relativePath)||r.startLine-a.startLine),()=>({definitions:n.length}));let i=O(n,t.scanLimit),s=p("twin-drift.select-candidates",()=>te(i),()=>({scanned:i.length}));return p("twin-drift.build-records",()=>{let r=[];for(let a of s){let o=ne(e,a);o&&r.push(o)}return r},()=>({candidates:s.length,scanned:i.length}))}function ee(e){return e.isFunctionLike?e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&U.has(e.kind):!0:!1}function te(e){let t=e.filter(r=>r.leaf&&!V(r.leaf)&&!D(r.symbol)&&!Z(r.symbol)&&!j(r.symbol,r.leaf)),n=new Map;for(let r of t){let a=n.get(r.leaf)??[];a.push(r),n.set(r.leaf,a)}let i=W([...n.keys()]),s=new Set;for(let r of i){let a=[...r].flatMap(o=>n.get(o)??[]);if(!(a.length<2)&&!(new Set(a.map(o=>o.relativePath)).size<2)&&!a.every(o=>L(o.relativePath)==="test"))for(let o of a)s.add(o)}return e.filter(r=>s.has(r))}function ne(e,t){if(!t.leaf)return null;let n=B(e,t);if(!n||!z(t.symbol)&&!re(n,t.leaf))return null;let i=T(S(n)),s=i.replace(/\s+/g,"");if(!s||s.length<8)return null;let r=i.match(ie)??[];return r.length===0?null:{leaf:t.leaf,symbol:t.symbol,shortName:I(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:E(t),normalizedBody:s,tokens:r,isThinForwarder:H(i)}}function re(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`\\b(?:const|let|var)\\s+${n}(?:\\s*:[^=]+)?\\s*=\\s*(?:async\\s*)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>`,"s").test(e)}var ie=/[A-Za-z_$][A-Za-z0-9_$]*|\d+(?:\.\d+)?|[^\sA-Za-z0-9_$]/g;function se(e){return{symbol:e.symbol,shortName:e.shortName,file:e.file,startLine:e.startLine,endLine:e.endLine,loc:e.loc}}function oe(e,t){let n=new Set(e),i=new Set(t);if(n.size===0&&i.size===0)return 1;if(n.size===0||i.size===0)return 0;let s=0;for(let a of n)i.has(a)&&(s+=1);let r=n.size+i.size-s;return r===0?0:s/r}function ae(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i+=1;let s=e.slice(i,i+6).join(" "),r=t.slice(i,i+6).join(" ");return!s&&!r?"(bodies differ only in trailing length)":`A: ${s||"(end)"} | B: ${r||"(end)"}`}function W(e){let t=new Map;for(let a of e)t.set(a,a);let n=a=>{let o=a;for(;t.get(o)!==o;)o=t.get(o);let l=a;for(;t.get(l)!==o;){let c=t.get(l);t.set(l,o),l=c}return o},i=(a,o)=>{let l=n(a),c=n(o);l!==c&&t.set(l,c)},s=new Map;for(let a of e){let o=a.slice(0,2).toLowerCase(),l=s.get(o)??[];l.push(a),s.set(o,l)}for(let a of s.values())for(let o=0;o<a.length;o+=1)for(let l=o+1;l<a.length;l+=1)le(a[o],a[l])&&i(a[o],a[l]);let r=new Map;for(let a of e){let o=n(a),l=r.get(o)??new Set;l.add(a),r.set(o,l)}return[...r.values()]}function le(e,t){return e===t||e.toLowerCase()===t.toLowerCase()?!0:e.length<8||t.length<8||Math.abs(e.length-t.length)>2||ce(e.toLowerCase(),t.toLowerCase())/Math.max(e.length,t.length)<.8?!1:pe(e.toLowerCase(),t.toLowerCase(),2)}function ce(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i+=1;return i}function fe(e){return/^[A-Z][A-Z0-9_]*$/.test(e)||/^__[^_].*__$/.test(e)||ue.has(e.toLowerCase())}var ue=new Set(["main","row"]),me=new Set(["app","component","components","feature","features","impl","index","lib","route","routes","shared","src","tsx","typescript","ui"]);function Z(e){return e.startsWith("rust-analyzer ")&&/\/(?:tests?|benches?)\//.test(e)}var de=new Set(["default","new","reset"]);function j(e,t){return e.startsWith("rust-analyzer ")&&de.has(t.toLowerCase())}function ge(e,t){if(e.leaf.toLowerCase()!==t.leaf.toLowerCase()||e.leaf.length>4)return!0;let n=F(e);return[...F(t)].some(i=>n.has(i))}function F(e){let t=e.leaf.toLowerCase();return new Set(`${e.file}/${e.shortName}`.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>2&&n!==t&&!me.has(n)))}function pe(e,t,n){if(Math.abs(e.length-t.length)>n)return!1;let i=Array.from({length:t.length+1},(s,r)=>r);for(let s=1;s<=e.length;s+=1){let r=[s],a=r[0];for(let o=1;o<=t.length;o+=1){let l=e[s-1]===t[o-1]?0:1,c=Math.min(i[o]+1,r[o-1]+1,i[o-1]+l);r.push(c),a=Math.min(a,c)}if(a>n)return!1;i=r}return i[t.length]<=n}function ke(e){return H(T(S(e)))}function H(e){let t=e.trim();if(!t||he.test(t))return!1;let n=be(t);return n.length===0||n.length>2?!1:ye(n[n.length-1])}var he=/\b(?:if|else|for|while|switch|try|catch|do)\b/,we=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[[^[\]]*\])*\((?:[^()]|\([^()]*\))*\)$/;function ye(e){let t=e.trim().replace(/^return\s+/,"").replace(/^await\s+/,"").replace(/;\s*$/,"").trim();return we.test(t)}function be(e){let t=[],n=0,i="";for(let s of e){if(s==="("||s==="["||s==="{"?n+=1:(s===")"||s==="]"||s==="}")&&(n=Math.max(0,n-1)),s===";"&&n===0){t.push(i),i="";continue}i+=s}return i.trim()&&t.push(i),t.map(s=>s.trim()).filter(s=>s.length>0)}var Te=3;function De(e){let t=new Map;return(n,i,s)=>{if(!n.isThinForwarder)return!1;let r=`${n.symbol}\0${i.symbol}`,a=t.get(r);if(a!==void 0)return a;let o=K(e,n,i,s,Te,new Set);return t.set(r,o),o}}function K(e,t,n,i,s,r){if(s<=0||r.has(t.symbol)||(r.add(t.symbol),(v(e,t.file)??[]).filter(l=>l.line>=t.startLine&&l.line<=t.endLine&&l.calleeLeaf===n.leaf).length===0))return!1;let o=new Set(A(e,t.file).filter(l=>l.sourcePath&&(l.kind!=="namespace"||l.usedMembers.includes(n.leaf))).map(l=>l.sourcePath));if([...o].some(l=>b(l,n.file)))return!0;for(let l of i)if(!(l.symbol===t.symbol||l.symbol===n.symbol||!l.isThinForwarder)&&[...o].some(c=>b(c,l.file))&&K(e,l,n,i,s-1,r))return!0;return!1}function V(e){return e.startsWith("<")&&e.endsWith(">")}function G(e){return[...e].sort()[0]}export{$e as a,X as b,Y as c,ke as d,be as e};
|
|
2
|
+
//# sourceMappingURL=chunk-J7IMQRCU.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x}from"./chunk-UWR52GNZ.js";import{b as g}from"./chunk-B75HZHUP.js";import{a as k}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as x}from"./chunk-UWR52GNZ.js";import{b as g}from"./chunk-B75HZHUP.js";import{a as k}from"./chunk-RUV4KHWA.js";import{b as L}from"./chunk-5CJ6AQN7.js";import{a as n}from"./chunk-BGBBVSH4.js";import{j as v}from"./chunk-NJD4C5G5.js";import{d as S}from"./chunk-7XP7ZRSI.js";import{s as a}from"./chunk-M2TRDR25.js";function E(c,f={}){let{scope:P,minLoc:F=3,scanLimit:d}=f,l=new k(c),b=f.semantic!==!1,y=0,m=a("isolated.candidates",()=>{let s=g(l.productionCallableDefinitions({scope:P,minLoc:F,excludeEntrySurfaces:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0,includeSuppressed:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:typeof d=="number"&&d>0}),d).filter(R=>!x(c,R));return y=s.length,s},()=>({definitions:y})),p=0,i=a("isolated.strict-callees",()=>{let e=l.symbolsWithNonSelfCallees(m,{additive:!1,semantic:!1});return p=e.size,e},()=>({definitions:m.length,symbols:p})),r=m.filter(e=>!i.has(e.symbolId)),C=0,N=a("isolated.scip-callers",()=>{let e=l.crossFileCallerMap(r,{semantic:!1});return C=e.size,e},()=>({definitions:r.length,symbols:C})),o=new Set(N.keys());for(let e of l.frameworkReferencedSymbolIds(r))o.add(e);let t=r.filter(e=>!o.has(e.symbolId));if(b&&t.length>0){for(let e of v(c,t).keys())o.add(e);for(let e of l.symbolsWithNonSelfCallees(t,{additive:!1,semantic:!0}))i.add(e);t=t.filter(e=>!o.has(e.symbolId)).filter(e=>!i.has(e.symbolId))}let h=0,W=a("isolated.source-fallback-callers",()=>{let e=l.sourceFallbackCallerFiles(t,{skipPath:s=>L(s)==="test"});return h=e.size,e},()=>({definitions:t.length,symbols:h}));for(let e of W.keys())o.add(e);let u=t.filter(e=>!o.has(e.symbolId)),I=0,M=a("isolated.additive-callees",()=>{let e=l.symbolsWithNonSelfCallees(u,{additive:!0,semantic:b});return I=e.size,e},()=>({definitions:u.length,symbols:I}));for(let e of M)i.add(e);return u.filter(e=>!i.has(e.symbolId)).sort((e,s)=>n(s)-n(e)||e.relativePath.localeCompare(s.relativePath)||e.startLine-s.startLine).map(e=>({symbol:e.symbol,shortName:S(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:n(e)}))}export{E as a};
|
|
2
|
+
//# sourceMappingURL=chunk-K4XL4HOK.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as d}from"./chunk-B75HZHUP.js";import{a as u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as d}from"./chunk-B75HZHUP.js";import{a as u}from"./chunk-RUV4KHWA.js";import{a as y,c as p}from"./chunk-KSD6IWF4.js";import{d as f}from"./chunk-7XP7ZRSI.js";function F(s,o={}){let{limit:l=20,scope:a,minFanIn:i=2,minFanOut:m=2,scanLimit:t}=o,r=new u(s);return d(r.productionCallableDefinitions({scope:a,requireCallableSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof t=="number"&&t>0}),t).map(e=>g(s,e,o.semantic!==!1)).filter(e=>e.fanIn>=i&&e.fanOut>=m).sort((e,b)=>b.score-e.score||b.fanIn-e.fanIn).slice(0,l)}function g(s,o,l){let a=[...new Set(p(s,o,{limit:500,semantic:l}).map(n=>n.file))].sort(),i=new Map;for(let n of y(s,o,{limit:500,semantic:l})){if(n.file===o.relativePath)continue;let e=`${n.symbol}|${n.file}`;i.has(e)||i.set(e,{symbol:n.symbol,shortName:f(n.symbol),file:n.file})}let m=[...i.values()].sort((n,e)=>n.file.localeCompare(e.file)||n.symbol.localeCompare(e.symbol)),t=a.length,r=m.length,c=t*r;return{symbol:o.symbol,shortName:f(o.symbol),fanIn:t,fanOut:r,callerFiles:a,externalCallees:m,score:c,definedIn:o.relativePath,actionTier:"signal",riskKind:"coordination-hotspot",evidenceReasons:[`${t} incoming file(s) reference this symbol`,`${r} distinct cross-file callee symbol(s) are reached from it`,`centrality score is ${c} (fan-in * fan-out)`],recommendation:"Review ownership, API stability, and caller groups before changing this central symbol; do not refactor solely from graph centrality."}}export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-K53GNKY3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as u}from"./chunk-6JSTKSZH.js";import{a as c}from"./chunk-64MNV6AB.js";import{existsSync as m}from"fs";import{basename as p,isAbsolute as g,join as d}from"path";function S(t,r){let e=f(t,r,{allowMultiple:!1})[0]?.relativePath;return e||x(t,r)}function j(t,r){return f(t,r,{allowMultiple:!0}).map(e=>e.relativePath)}function x(t,r){if(!r)return null;let e=r.replace(/\\/g,"/").replace(/^\.\//,""),s=g(e)&&e.startsWith(t.config.projectRoot)?e.slice(t.config.projectRoot.length).replace(/^\/+/,""):e,i=d(t.config.projectRoot,s);return m(i)?s:null}function f(t,r,e){let s=h(r);if(!s)return[];let i=c(t,{includeIgnored:!1}).map(o=>({relativePath:o,score:v(o,s)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.relativePath.localeCompare(l.relativePath));if(i.length===0){let o=u(t,r);return!o||t.isIgnored(o.relativePath)?[]:[{relativePath:o.relativePath,score:700}]}let n=i.filter(o=>o.score>=1100);if(n.length>0)return e.allowMultiple?n:[n[0]];let a=i.filter(o=>o.score>=800);return a.length>0?e.allowMultiple?a:[a[0]]:e.allowMultiple?i:[i[0]]}function v(t,r){let e=h(t),s=p(e),i=p(r),n=0;return e===r&&(n+=1200),e.endsWith(`/${r}`)&&(n+=1100),s===i&&(n+=900),e.startsWith(`${r}/`)&&(n+=850),e.includes(r)&&(n+=250),n}function h(t){return t.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}export{S as a,j as b};
|
|
2
|
+
//# sourceMappingURL=chunk-K65T4TJS.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
1
|
+
import{a as g}from"./chunk-K65T4TJS.js";import{h as p}from"./chunk-NJD4C5G5.js";import{a as f}from"./chunk-6JSTKSZH.js";import{d as u,e as _,i as N}from"./chunk-7XP7ZRSI.js";import{p as d}from"./chunk-JLZUM476.js";import{B as l,b as c}from"./chunk-TLTLJ4SW.js";import{a as I}from"./chunk-64MNV6AB.js";import{y as b}from"./chunk-M2TRDR25.js";function Y(e,t,r={}){return T(e,t,r)?.map(s=>({symbol:s.symbol,shortName:s.shortName,fromFile:s.fromFile}))??[]}function Z(e,t){let r=f(e,t),s=O(e,t);if(s.length>0&&!x(r))return s;let o=k(e,t,r);return h(t)&&o.length>0?o:D([...s,...o])}function G(e,t,r={}){let s=g(e,t);if(!s)return[];let o=S(e,s),n=r.semantic===!1?null:E(e,s);return(n?R(n,o):o).filter(m=>!m.used).map(m=>({symbol:m.symbol,shortName:m.shortName,importedIn:m.importer}))}function R(e,t){let r=new Map;for(let o of t){let n=r.get(o.shortName);n?n.push(o):r.set(o.shortName,[o])}let s=e.map(o=>{let n=r.get(o.shortName),i=n?.shift();return n?.length===0&&r.delete(o.shortName),i?{...o,used:o.used||i.used}:o});return s.push(...[...r.values()].flat()),s}function O(e,t){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d ON c.document_id = d.id
|
|
@@ -32,4 +32,4 @@ import{a as g}from"./chunk-5N5ZC566.js";import{h as p}from"./chunk-KWMRY4RN.js";
|
|
|
32
32
|
WHERE imp_d.relative_path = ?
|
|
33
33
|
AND m.role = 2
|
|
34
34
|
ORDER BY def_d.relative_path, gs.symbol`,t).filter(n=>!e.isIgnored(n.importer));if(o.length>0){let n=r.semantic===!1?[]:p(e,t);return o.map(i=>({symbol:i.symbol,shortName:u(i.symbol),fromFile:i.from_file??"(external)",importer:i.importer,used:i.used!==0||n.some(m=>m.isUsed&&m.sourcePath===i.from_file)}))}return null}function E(e,t){let r=p(e,t);return r.length>0?r.map(s=>{let o=y(s.importedName,s.localName,s.kind);return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:s.kind==="side-effect"?!0:s.isUsed}}):null}function S(e,t){let r=A(t,b(e,t));return d(e,t).map(s=>{let o=y(s.importedName,s.localName,s.kind),n=s.kind==="side-effect"||v(t,s)||r.has(s.localName??s.importedName)?!0:s.used;return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:n}})}function A(e,t){let r=new Set;if(l(e)!=="python")return r;let s=/(?:^|\n)\s*__all__\s*(?:\+?=)\s*[[(]([\s\S]*?)[\])]/g;for(let o of t.matchAll(s)){let n=o[1]??"";for(let i of n.matchAll(/(['"])([A-Za-z_]\w*)\1/g))r.add(i[2])}return r}function v(e,t){if(l(e)!=="rust"||t.used||t.kind==="side-effect")return!1;let r=t.localName??t.importedName;return r==="_"||/^[A-Z]/.test(r)}function y(e,t,r){return r==="namespace"&&e==="*"&&t?`* as ${t}`:r==="default"&&t?`default as ${t}`:r==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function $(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{Y as a,Z as b,G as c};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-KA7RMBVU.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as n}from"./chunk-B75HZHUP.js";import{a as m,c as a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as n}from"./chunk-B75HZHUP.js";import{a as m,c as a}from"./chunk-KSD6IWF4.js";import{a as i}from"./chunk-6JSTKSZH.js";import{d as o,h as r}from"./chunk-7XP7ZRSI.js";function R(s,c,y={}){let e=i(s,c);if(!e)return null;let t=y.semantic!==!1,b=a(s,e,{semantic:t}).filter(l=>r(l.symbol)).slice(0,50),f=n(m(s,e,{limit:50,additive:!0,callableOnly:!0,semantic:t}));return{symbol:e.symbol,shortName:o(e.symbol),callers:b.map(l=>({symbol:l.symbol,shortName:o(l.symbol),file:l.file})),callees:f.map(l=>({symbol:l.symbol,shortName:o(l.symbol),file:l.file}))}}export{R as a};
|
|
2
|
+
//# sourceMappingURL=chunk-KJOKTZUE.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{b as le,c as O,d as T,e as H,k as be,l as ye}from"./chunk-MBVHEPHQ.js";import{d as re,e as de,f as $,g as ue,l as fe,m as pe}from"./chunk-NJD4C5G5.js";import{D as me,n as ce,x as j}from"./chunk-LEKXKHIQ.js";import{a as te}from"./chunk-QEIGJJBC.js";import{d as ge,e as he}from"./chunk-MTDBHTSF.js";import{e as N,g as oe,s as ie,t as P,y as ae,z as se}from"./chunk-7XP7ZRSI.js";import{k as E,m as ee,p as ne}from"./chunk-JLZUM476.js";import{B as D,c as q}from"./chunk-TLTLJ4SW.js";import{a as Z}from"./chunk-64MNV6AB.js";import{c as z,d as Q,g as G,h as x,j as Y,l as K,q as X,s as _,y as F}from"./chunk-M2TRDR25.js";function Rn(e,n,t={}){let o=Me(e,[n],{additive:t.additive,semantic:t.semantic}),i=t.callableOnly?(o.get(n.symbolId)??[]).filter(s=>oe(s.symbol)||s.source==="ast-callsite"):o.get(n.symbolId)??[];return typeof t.limit=="number"?i.slice(0,t.limit):i}function Ce(e,n,t={}){return U(e,[n],t).get(n.symbolId)??[]}function U(e,n,t={}){let o=De(e)?Ee(e,n,{semantic:t.semantic!==!1}):ke(e);return typeof t.limit!="number"?new Map(n.map(i=>[i.symbolId,o.get(i.symbolId)??[]])):new Map(n.map(i=>[i.symbolId,(o.get(i.symbolId)??[]).slice(0,t.limit)]))}var Le=Q("caller-rows",{clearGroups:["whole-project"]}),_e=2e4;function De(e){return(e.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>_e}function ke(e){return Le.get(e,()=>{let n=P(e),t=Me(e,n),o=new Map;for(let a of n)o.set(a.symbol,a.symbolId);let i=new Map,s=new Map;for(let a of n){let r=t.get(a.symbolId);if(!(!r||r.length===0))for(let d of r){let c=o.get(d.symbol);if(c===void 0||c===a.symbolId)continue;let m=i.get(c);m||(m=[],i.set(c,m),s.set(c,new Set));let b=`${a.symbol}|${a.relativePath}`;s.get(c).has(b)||(s.get(c).add(b),m.push({symbol:a.symbol,file:a.relativePath,source:"caller-map-inversion"}))}}return i})}function Ee(e,n,t){let o=t.semantic?n.flatMap(r=>{let d=ve(e,r);return d?[d]:[]}):[],i=new Map(o.map(r=>[r.symbolId,r])),s=fe(e,o),a=new Map;for(let r of n){let d=[],c=new Set,m=p=>{if(p.symbol===r.symbol)return;let l=`${p.symbol}|${p.file}`;c.has(l)||(c.add(l),d.push(p))};for(let p of ye(e,r))p.file!==r.relativePath&&m({symbol:p.enclosingSymbol??p.file,file:p.file,source:"resolved-reference"});let b=i.get(r.symbolId);if(b)for(let p of s.get(b.symbolId)??[]){if(p.file===r.relativePath||e.isIgnored(p.file))continue;let l=se(ie(e,p.file),p.line);m({symbol:l?.symbol??p.file,file:p.file,source:"semantic-reference"})}a.set(r.symbolId,d)}return a}function ve(e,n){let t=ge().join(", "),o=he().join(", ");return e.get(`SELECT
|
|
2
|
+
d.id AS documentId,
|
|
3
|
+
gs.id AS symbolId,
|
|
4
|
+
gs.symbol,
|
|
5
|
+
d.relative_path AS relativePath,
|
|
6
|
+
COALESCE(der.start_line, c.start_line) AS startLine,
|
|
7
|
+
COALESCE(der.end_line, c.end_line) AS endLine,
|
|
8
|
+
COALESCE(gs.display_name, '') AS leaf,
|
|
9
|
+
NULL AS parentTypeName,
|
|
10
|
+
CASE WHEN gs.kind IN (${t}) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
|
|
11
|
+
CASE WHEN gs.kind IN (${o}) THEN 1 ELSE 0 END AS isTypeLike,
|
|
12
|
+
gs.kind AS kind,
|
|
13
|
+
gs.documentation AS documentation,
|
|
14
|
+
gs.enclosing_symbol AS enclosingSymbol
|
|
15
|
+
FROM global_symbols gs
|
|
16
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
17
|
+
LEFT JOIN chunks c ON c.document_id = der.document_id
|
|
18
|
+
JOIN documents d ON d.id = COALESCE(der.document_id, c.document_id)
|
|
19
|
+
WHERE gs.id = ?
|
|
20
|
+
LIMIT 1`,n.symbolId)??null}function Me(e,n,t={}){if(n.length===0)return new Map;let o=t.additive??!1,i=[],s=[];for(let m of n)D(m.relativePath)&&E(e,m.relativePath)!==null?i.push(m):s.push(m);let a=new Map,r=new Map,d=m=>{for(let[b,p]of m){let l=a.get(b);l||(l=[],a.set(b,l));let g=r.get(b);g||(g=new Set,r.set(b,g));for(let R of p){let C=`${R.symbol}|${R.chunkId}`;g.has(C)||(g.add(C),l.push(R))}}};i.length>0&&d(Te(e,i)),t.semantic!==!1&&d(Ke(Ae(e,n)));let c=o?n:s;return c.length>0&&d(Be(e,c)),a}function Ae(e,n){let t=X(),o=new Map,i=ue(e,n),s=[],a=[],r=0,d=0,c=0,m=0,b=0,p=0,l=0;for(let{definition:f,callees:u}of i.hits)b+=1,u.length>0&&(p+=1,l+=u.length,o.set(f.symbolId,u));let g=xe(e,i.hits);if(g.entries.length>0&&_("semantic.callees.prefetch-cache-write",()=>K(e,g.entries),()=>({entries:g.entries.length,sourceMissing:g.sourceMissing,skippedUnsupportedLanguage:g.skippedUnsupportedLanguage})),_("semantic.callees.cache-scan",()=>{for(let[f,u]of de(i.misses)){if(!j(f)){t&&(r+=u.length);continue}let h=F(e,f);if(!h){t&&(d+=u.length),a.push(...u);continue}let k=x(e,f,h),I=Re(e,f);if(!I){a.push(...u);continue}let B=Y(e,f,k,I);for(let y of u){let S=B.get(y.symbol)??null;if(S!==null){let w=Ne(S);if(w){t&&(c+=1),w.length>0&&o.set(y.symbolId,w);continue}t&&(m+=1)}s.push({def:y,contentHash:k,depsDigest:I})}}},()=>({definitions:n.length,skippedUnsupportedLanguage:r,sourceMissing:d,cacheHits:c,parseFailures:m,misses:s.length,unkeyed:a.length,inMemoryHits:b,inMemoryRows:p,inMemoryCalleeCount:l,resultRows:o.size})),s.length===0&&a.length===0)return o;let R=[...a,...s.map(f=>f.def)],C=0,v=_("semantic.callees.compute-misses",()=>{let f=pe(e,R);return C=f.size,f},()=>({definitions:R.length,misses:s.length,unkeyed:a.length,rows:C}));for(let[f,u]of v)o.set(f,u);let M=s.filter(f=>$(e).capability("semantic-callees",f.def.relativePath).available).map(f=>({relativePath:f.def.relativePath,symbol:f.def.symbol,contentHash:f.contentHash,depsDigest:f.depsDigest,payload:JSON.stringify(v.get(f.def.symbolId)??[])}));return M.length>0?_("semantic.callees.cache-write",()=>K(e,M),()=>({entries:M.length})):_("semantic.callees.cache-write-skip",()=>{},()=>({reason:"provider-unavailable",misses:s.length})),o}function xe(e,n){let t=[],o=new Map,i=0,s=0;for(let{definition:a,callees:r}of n){if(!j(a.relativePath)){s+=1;continue}if(!o.has(a.relativePath)){let c=F(e,a.relativePath),m=c?Re(e,a.relativePath):null;o.set(a.relativePath,c&&m?{contentHash:x(e,a.relativePath,c),depsDigest:m}:null)}let d=o.get(a.relativePath);if(!d){i+=1;continue}t.push({relativePath:a.relativePath,symbol:a.symbol,contentHash:d.contentHash,depsDigest:d.depsDigest,payload:JSON.stringify(r)})}return{entries:t,sourceMissing:i,skippedUnsupportedLanguage:s}}var Fe="typescript-callees-v1";function Re(e,n){let t=j(n);if(t==="typescript")return me(e,n,Fe)?.key??null;let o=Oe(e,n);return t==="rust"?G(JSON.stringify({kind:"semantic-callees",language:t,engine:ce(e.config.projectRoot),positionMapping:"nearby-leaf-v1",depsDigest:o})):o}function Ne(e){try{return JSON.parse(e)}catch{return null}}var Pe=z("semantic-deps-digest",{clearGroups:["whole-project","source-file"]});function Oe(e,n){return Pe.get(e,n,()=>{let o=[...te(e).get(n)??[]].sort().map(i=>`${i}:${x(e,i,F(e,i))}`);return G(o.join("|"))})}function Te(e,n){let t=new Map,o=He(n,t),i=H(e);for(let[s,a]of o){let r=E(e,s);if(!r)continue;let d=ae(a);for(let c of r){let m=d.get(c.line);if(!m)continue;let b=je(e,s,i,c);b&&b.symbol!==m.symbol&&t.get(m.symbolId).push({symbol:b.symbol,file:b.file,chunkId:c.line,source:"ast-callsite"})}}return t}function He(e,n){let t=new Map;for(let o of e){let i=t.get(o.relativePath);i?i.push(o):t.set(o.relativePath,[o]),n.set(o.symbolId,[])}for(let o of t.values())o.sort((i,s)=>i.endLine-i.startLine-(s.endLine-s.startLine));return t}function je(e,n,t,o){let i=O(n,t.get(o.calleeLeaf)??[]);if(i.length===0)return null;let s=$e(e,n,i,o.calleeQualifier);return s||T(e,n,i,o.memberAccess)}function $e(e,n,t,o){if(!o||D(n)!=="clojure")return null;let s=ne(e,n).filter(a=>a.kind==="namespace"&&a.localName===o&&a.sourcePath).map(a=>a.sourcePath);for(let a of s){let r=t.find(d=>q(a,d.file));if(r)return r}return t.find(a=>/`([^`]+)`\//.exec(a.symbol)?.[1]===o)??null}function Be(e,n){if(n.length===0)return new Map;let o=J(n.map(l=>l.documentId)).flatMap(l=>e.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
|
|
21
|
+
FROM mentions m
|
|
22
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
23
|
+
WHERE m.role != 1
|
|
24
|
+
AND c.document_id IN (${l.map(()=>"?").join(",")})`,...l)),i=new Map;for(let l of o)i.has(l.document_id)||i.set(l.document_id,[]),i.get(l.document_id).push(l);let a=J(o.map(l=>l.symbol_id)).flatMap(l=>e.all(`SELECT gs.id AS symbol_id, gs.symbol,
|
|
25
|
+
COALESCE(der.document_id, def_chunk.document_id) AS document_id
|
|
26
|
+
FROM global_symbols gs
|
|
27
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
28
|
+
LEFT JOIN (
|
|
29
|
+
SELECT m.symbol_id, MIN(c.document_id) AS document_id
|
|
30
|
+
FROM mentions m
|
|
31
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
32
|
+
WHERE m.role = 1
|
|
33
|
+
AND m.symbol_id IN (${l.map(()=>"?").join(",")})
|
|
34
|
+
GROUP BY m.symbol_id
|
|
35
|
+
) def_chunk ON def_chunk.symbol_id = gs.id
|
|
36
|
+
WHERE gs.id IN (${l.map(()=>"?").join(",")})`,...l,...l)),r=J([...n.map(l=>l.documentId),...a.flatMap(l=>l.document_id===null?[]:[l.document_id])]),d=new Map(r.flatMap(l=>e.all(`SELECT id, relative_path FROM documents
|
|
37
|
+
WHERE id IN (${l.map(()=>"?").join(",")})`,...l).map(g=>[g.id,g.relative_path]))),c=new Map;for(let l of a)c.has(l.symbol_id)||c.set(l.symbol_id,{symbol:l.symbol,file:l.document_id!==null?d.get(l.document_id)??"":""});let m=new Map,b=d,p=Ge(n);for(let[l,g]of p){let C=[...i.get(l)??[]].sort((u,h)=>u.start_line-h.start_line||u.end_line-h.end_line),v=[...g].sort((u,h)=>u.startLine-h.startLine||u.endLine-h.endLine),M=new Set,f=0;for(let u of v){for(;f<C.length&&C[f].start_line<=u.endLine;)M.add(C[f]),f+=1;for(let y of M)y.end_line<u.startLine&&M.delete(y);let h=new Set,k=[],I=null,B=()=>{if(I)return I;let y=b.get(u.documentId)??"",S=new Set;if(y){let w=le(e,y),A=Math.max(0,u.startLine),V=Math.min(w.length-1,u.endLine);for(let L=A;L<=V;L+=1)for(let we of w[L])S.add(we)}return I=S,S};for(let y of M){if(y.symbol_id===u.symbolId)continue;let S=c.get(y.symbol_id);if(!S)continue;if(!(y.start_line>=u.startLine&&y.end_line<=u.endLine)){if(!(y.start_line<=u.endLine&&y.end_line>=u.startLine))continue;let L=N(S.symbol);if(!L||!B().has(L))continue}let A=`${S.symbol}|${y.chunk_id}`;h.has(A)||(h.add(A),k.push({...S,chunkId:y.chunk_id,source:"scip-chunk"}))}m.set(u.symbolId,k)}}return m}var Se=500;function J(e){let n=[...new Set(e)],t=[];for(let o=0;o<n.length;o+=Se)t.push(n.slice(o,o+Se));return t}function Ge(e){let n=new Map;for(let t of e){let o=n.get(t.documentId);o?o.push(t):n.set(t.documentId,[t])}return n}function Ke(e){let n=new Map;for(let[t,o]of e){let i=[];for(let s of o)i.push({symbol:s.symbol,file:s.file,chunkId:-1,source:"semantic-callee"});n.set(t,i)}return n}function Ie(e,n,t={}){let o=new Map;if(n&&n.length===0)return o;let i=Z(e,{includeIgnored:!1}),s=H(e),a=n??P(e),r=new Set(a.map(c=>c.symbolId)),d=Ye(a);if(Je(e,o,i,s,r,d),Ue(e,o,a,r),Qe(e,o,i,s,r,d),t.semantic!==!1){let c=$(e);qe(o,c.callerMap(Ze(a)))}return o}function Je(e,n,t,o,i,s){for(let a of t){if(!D(a))continue;let r=E(e,a);if(r)for(let d of r){if(s&&!s.has(d.calleeLeaf))continue;let c=O(a,o.get(d.calleeLeaf)??[]);if(!c||c.length===0)continue;let m=T(e,a,c,d.memberAccess);m&&i.has(m.symbolId)&&m.file!==a&&W(n,m.symbolId,a)}}}function Ue(e,n,t,o){let i=Ve(t);for(let s of We(e,o))e.isIgnored(s.relative_path)||ze(s,i.get(s.symbol_id))||W(n,s.symbol_id,s.relative_path)}function We(e,n){return re(e,n?[...n]:void 0)}function Ve(e){let n=new Map;for(let t of e)n.set(t.symbolId,{docId:t.documentId,startLine:t.startLine,endLine:t.endLine});return n}function ze(e,n){return!!n&&n.docId===e.document_id&&e.chunk_start>=n.startLine&&e.chunk_end<=n.endLine}function Qe(e,n,t,o,i,s){for(let a of t){if(D(a)!=="rust")continue;let r=ee(e,a,{includeRustAttributeNames:!0});if(r.length!==0)for(let{name:d}of r){if(s&&!s.has(d))continue;let c=o.get(d);if(c)for(let m of c)i.has(m.symbolId)&&m.file!==a&&W(n,m.symbolId,a)}}}function W(e,n,t){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(t)}function Ye(e){let n=new Set;for(let t of e){let o="leaf"in t&&typeof t.leaf=="string"?t.leaf:"symbol"in t&&typeof t.symbol=="string"?N(t.symbol):"";o&&n.add(o)}return n.size>0?n:null}function Ze(e){return e.filter(n=>"relativePath"in n&&"symbol"in n&&"leaf"in n)}function qe(e,n){for(let[t,o]of n){let i=e.get(t);i||(i=new Set,e.set(t,i));for(let s of o)i.add(s)}}function Pn(e,n,t={}){return Ce(e,n,t)}function On(e,n,t={}){return U(e,n,t)}function Xe(e,n,t={}){return Ie(e,n,t)}function en(e,n,t={}){return be(e,n,t)}function Tn(e,n,t={}){let o=Xe(e,n,{semantic:t.semantic});return t.sourceFallback===!1?o:nn(o,en(e,n))}function nn(e,n){let t=new Map;for(let[o,i]of e)t.set(o,new Set(i));for(let[o,i]of n){let s=t.get(o)??new Set;for(let a of i)s.add(a);t.set(o,s)}return t}export{Rn as a,Me as b,Pn as c,On as d,Xe as e,en as f,Tn as g,nn as h};
|
|
38
|
+
//# sourceMappingURL=chunk-KSD6IWF4.js.map
|