scip-query 0.19.0 → 0.19.1
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/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-YHYTDWFT.js → chunk-24ET4VLC.js} +2 -2
- package/dist/{chunk-IXORBCMR.js → chunk-2NA6TYP4.js} +2 -2
- package/dist/{chunk-XKWEMFHP.js → chunk-2WCXKANA.js} +2 -2
- package/dist/{chunk-GJ3FR5WG.js → chunk-34MLC6UI.js} +2 -2
- package/dist/{chunk-PAZFJMXB.js → chunk-3WLRW5TC.js} +2 -2
- package/dist/{chunk-EZHARAL4.js → chunk-4BU54UJG.js} +2 -2
- package/dist/{chunk-XTSVYYAL.js → chunk-4CZJ4YJB.js} +2 -2
- package/dist/{chunk-TCVRJ56J.js → chunk-4FMT4HPC.js} +2 -2
- package/dist/{chunk-7FG5M53V.js → chunk-53SUJOJA.js} +2 -2
- package/dist/{chunk-YBAC3RON.js → chunk-5GOBZI34.js} +2 -2
- package/dist/{chunk-X36LKKVG.js → chunk-5OZCNAVM.js} +2 -2
- package/dist/{chunk-FMC3BI4I.js → chunk-5TEUKVSM.js} +2 -2
- package/dist/{chunk-WT7TOU2C.js → chunk-5W2VAEVR.js} +2 -2
- package/dist/{chunk-AWSRND4W.js → chunk-63P42UR6.js} +2 -2
- package/dist/{chunk-GNJHHPZE.js → chunk-64QITTX7.js} +2 -2
- package/dist/{chunk-XPYXEEDO.js → chunk-6O5JOS7T.js} +2 -2
- package/dist/{chunk-X65VYV2S.js → chunk-6PKO2TNZ.js} +2 -2
- package/dist/{chunk-X3OOU7CF.js → chunk-7SGOWD2Y.js} +2 -2
- package/dist/{chunk-ZXWFN7CK.js → chunk-7TJJY2C3.js} +2 -2
- package/dist/{chunk-OGHGTD6Z.js → chunk-AEM24WSF.js} +2 -2
- package/dist/{chunk-IWK562KR.js → chunk-AGTATREV.js} +2 -2
- package/dist/{chunk-SATRCB5O.js → chunk-AOSFSYEA.js} +2 -2
- package/dist/{chunk-3OSRXJKK.js → chunk-APLNTJPJ.js} +2 -2
- package/dist/{chunk-TDGCALH6.js → chunk-AYRHVJXW.js} +2 -2
- package/dist/{chunk-AM2LGOEX.js → chunk-B2WQKQKP.js} +2 -2
- package/dist/{chunk-F5L7WEZF.js → chunk-BBBKPOIT.js} +2 -2
- package/dist/{chunk-2FAJTZSX.js → chunk-BCMOTIB6.js} +2 -2
- package/dist/{chunk-RJLU7IMR.js → chunk-BMTBVMA3.js} +2 -2
- package/dist/{chunk-JFGUBZWE.js → chunk-C3KCSAQ4.js} +2 -2
- package/dist/{chunk-FLIF3JWA.js → chunk-CAKPEQZB.js} +2 -2
- package/dist/{chunk-PKAPOFF5.js → chunk-CIYUFF24.js} +2 -2
- package/dist/{chunk-7EI4MU5A.js → chunk-CKFMZE77.js} +2 -2
- package/dist/{chunk-A45K6VUK.js → chunk-DCDOGW32.js} +2 -2
- package/dist/{chunk-4ZCNFENR.js → chunk-DFQNE73Y.js} +2 -2
- package/dist/{chunk-J3U47L4Q.js → chunk-DO775SYA.js} +2 -2
- package/dist/{chunk-NEG77KKH.js → chunk-DRH3AD7W.js} +2 -2
- package/dist/{chunk-UVMME4FI.js → chunk-DZXFZAZO.js} +2 -2
- package/dist/{chunk-GMZYT44R.js → chunk-E3KWOHH7.js} +2 -2
- package/dist/{chunk-F334Z5UA.js → chunk-EMIIOOTM.js} +2 -2
- package/dist/{chunk-GBB2RUDN.js → chunk-ESNRT7QN.js} +130 -130
- package/dist/{chunk-RIGY5DDE.js → chunk-FB6IKAKZ.js} +2 -2
- package/dist/{chunk-BGUYAA3Q.js → chunk-FBUNGRKI.js} +2 -2
- package/dist/{chunk-M2TRDR25.js → chunk-FC5K7T35.js} +1 -1
- package/dist/{chunk-4ZHJAHLE.js → chunk-FHLYJVXF.js} +2 -2
- package/dist/{chunk-KWBA6FDD.js → chunk-FRXB74RQ.js} +2 -2
- package/dist/{chunk-BYPVNKJT.js → chunk-FTRNGQGR.js} +2 -2
- package/dist/{chunk-54UYBTZW.js → chunk-FUFNRZFJ.js} +2 -2
- package/dist/{chunk-QNMOZ3CJ.js → chunk-GAE7WCBK.js} +2 -2
- package/dist/{chunk-547VY366.js → chunk-GIHVWNKQ.js} +2 -2
- package/dist/{chunk-AEDB4WXE.js → chunk-HCS5LB6U.js} +2 -2
- package/dist/{chunk-UXOVHGT6.js → chunk-HFBNIIZX.js} +2 -2
- package/dist/{chunk-JHK2DMUQ.js → chunk-HGFDYOVB.js} +1 -1
- package/dist/{chunk-6SHX42QQ.js → chunk-IOOCKVUA.js} +2 -2
- package/dist/{chunk-XDVT7QPG.js → chunk-J4MYRIYT.js} +2 -2
- package/dist/{chunk-TAB7AWKO.js → chunk-J5XJWCB3.js} +2 -2
- package/dist/{chunk-PXJIEMND.js → chunk-JBZXJXIS.js} +2 -2
- package/dist/{chunk-UJL3N6TC.js → chunk-JJZRS2OP.js} +2 -2
- package/dist/chunk-KC2IFAAU.js +3 -0
- package/dist/{chunk-4XTPZ5CR.js → chunk-KMOMNTB4.js} +2 -2
- package/dist/{chunk-YYR7ADNB.js → chunk-KMUFGAIK.js} +2 -2
- package/dist/{chunk-DWN7QDTV.js → chunk-LF5CIKWZ.js} +2 -2
- package/dist/{chunk-ZL5Y23AJ.js → chunk-LM72NQ7T.js} +1 -1
- package/dist/{chunk-3KQOIXLO.js → chunk-LQUDSHLB.js} +2 -2
- package/dist/{chunk-VV5WJLRO.js → chunk-MP43RX4O.js} +1 -1
- package/dist/{chunk-D5OXYOJP.js → chunk-MQ2B33LQ.js} +1 -1
- package/dist/{chunk-EZGT3NJX.js → chunk-NTOBQK5H.js} +2 -2
- package/dist/{chunk-TOYQTO44.js → chunk-OLG2YPLS.js} +2 -2
- package/dist/{chunk-J65FQLDL.js → chunk-OOUJBAKJ.js} +2 -2
- package/dist/{chunk-PBADFBRR.js → chunk-OQ6TCHBB.js} +2 -2
- package/dist/{chunk-BOXAKNN6.js → chunk-PNESKY2Z.js} +2 -2
- package/dist/{chunk-TDZXQAH7.js → chunk-PYMZU5EG.js} +2 -2
- package/dist/{chunk-HOXI4F5I.js → chunk-Q2WEWIKX.js} +2 -2
- package/dist/{chunk-DQIJMKNE.js → chunk-QHKXGMOI.js} +2 -2
- package/dist/{chunk-MTFHE7ZO.js → chunk-RPEA7P5Z.js} +2 -2
- package/dist/{chunk-DV6B262O.js → chunk-SJ6XSCG7.js} +2 -2
- package/dist/{chunk-LJD7V7UO.js → chunk-SSXEYWN3.js} +2 -2
- package/dist/{chunk-XESK6725.js → chunk-SYGAA54M.js} +2 -2
- package/dist/{chunk-TC3X33N6.js → chunk-TYEGFDOP.js} +2 -2
- package/dist/chunk-UJKZQLDB.js +2 -0
- package/dist/{chunk-QB5WSOTY.js → chunk-US44MEVU.js} +2 -2
- package/dist/{chunk-2ZNZSNVW.js → chunk-V5WBVF6K.js} +2 -2
- package/dist/{chunk-S65OEY2G.js → chunk-V7J4A3AH.js} +2 -2
- package/dist/{chunk-J6BR4MD6.js → chunk-VIKEPD4D.js} +2 -2
- package/dist/{chunk-XDSB47KO.js → chunk-WAU7HVDI.js} +2 -2
- package/dist/{chunk-T5CSWYAZ.js → chunk-WCZAABYF.js} +2 -2
- package/dist/{chunk-KD6TPIXM.js → chunk-WFRET75Z.js} +2 -2
- package/dist/chunk-WWCZCH7W.js +3 -0
- package/dist/{chunk-G6RQVDTI.js → chunk-XCPE3G75.js} +2 -2
- package/dist/{chunk-QN67MWDU.js → chunk-XYBNOILR.js} +2 -2
- package/dist/{chunk-MFBXBLHA.js → chunk-XZXUMGAA.js} +2 -2
- package/dist/{chunk-QHOUNTDZ.js → chunk-YCSTKIYU.js} +2 -2
- package/dist/{chunk-ZNSLF5AC.js → chunk-YGQBJUS6.js} +2 -2
- package/dist/{chunk-6DHPQS72.js → chunk-YILKXTIY.js} +2 -2
- package/dist/{chunk-G6QQCX45.js → chunk-ZJGZCBYT.js} +2 -2
- package/dist/{chunk-MDDF67O2.js → chunk-ZNK6K3LB.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{command-descriptors-SWFWGIFK.js → command-descriptors-3EJHQLQZ.js} +55 -55
- package/dist/direct-navigation-C2A44KFT.js +3 -0
- package/dist/index.js +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.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.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/cycles.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/deep-chains.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.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.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-chains.js +1 -1
- package/dist/queries/similar-files.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/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +5 -5
- package/dist/reindex.js +15 -15
- package/dist/runtime.js +1 -1
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/watch-server.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-42QYU6FD.js +0 -3
- package/dist/chunk-AERYQJ52.js +0 -3
- package/dist/chunk-OYYZLJVT.js +0 -2
- package/dist/direct-navigation-RKMPBXMI.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as te,b as N,e as V,f as j,g as E,h as re,i as se}from"./chunk-KMVGRIO2.js";import{a as q}from"./chunk-ZXWFN7CK.js";import{b as _}from"./chunk-B75HZHUP.js";import{a as ne}from"./chunk-F334Z5UA.js";import{n as ie}from"./chunk-UVMME4FI.js";import{a as D}from"./chunk-UXOVHGT6.js";import{d as I,e as K,h as $}from"./chunk-TDGCALH6.js";import{a as B}from"./chunk-QNMOZ3CJ.js";import{d as z,h as J,q as A,s as y,v as Q,x as ee,y as U,z as H}from"./chunk-M2TRDR25.js";import{a as Y}from"./chunk-64MNV6AB.js";function ve(e,n,t={}){let{minSimilarity:i=.4,limit:r=20}=t,s=ze(e,n,{semantic:t.semantic!==!1});if(!s)return[];if(!$(s.symbol))return[];if(s.callees.size===0)return ae(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"});let a=Me(e,s,i,{scanLimit:t.scanLimit,semantic:t.semantic!==!1});return a.length>0?a.slice(0,r):ae(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"})}function Mn(e,n,t,i={}){let r=D(e,n),s=D(e,t);if(!r||!s)return null;let a=ve(e,r.symbol,{minSimilarity:0,limit:Number.POSITIVE_INFINITY,semantic:i.semantic,scanLimit:i.scanLimit}).find(m=>m.symbolB===s.symbol||m.symbolA===s.symbol);if(!a)return null;let l=r.endLine-r.startLine+1,c=s.endLine-s.startLine+1;return{symbolA:{symbol:r.symbol,shortName:I(r.symbol),file:r.relativePath,loc:l},symbolB:{symbol:s.symbol,shortName:I(s.symbol),file:s.relativePath,loc:c},similarity:a.similarity,similarityBasis:a.similarityBasis??"callees",sharedEvidence:a.sharedCallees,uniqueToA:a.uniqueToA,uniqueToB:a.uniqueToB,evidenceClass:a.evidenceClass,actionTier:a.actionTier,recommendation:a.recommendation,consolidationStrategy:we(a)}}function we(e){let n=e.similarityBasis==="source-tokens"?"source-token":"tracked callee";return e.sharedCallees.length===0?`No shared ${n} evidence survived similar's weighting. Inspect the source before attempting consolidation.`:e.uniqueToA.length===0&&e.uniqueToB.length===0?`The functions have identical ${n} evidence under similar's weighting. Verify signatures, guards, and return values before consolidating.`:e.uniqueToA.length===0?`A's ${n} evidence is a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToB.length===0?`B's ${n} evidence is a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToA.length<=2&&e.uniqueToB.length<=2?`Create a shared helper around the ${e.sharedCallees.length} shared ${n}(s). Pass the ${e.uniqueToA.length+e.uniqueToB.length} divergent point(s) as parameters or callbacks.`:`Extract the ${e.sharedCallees.length} shared ${n}(s) into a common helper. Keep each function's unique logic outside that helper (${e.uniqueToA.length} item(s) in A, ${e.uniqueToB.length} in B).`}function Me(e,n,t,i){let r=G(e).calleeIndex({minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),s=je(n,r.corpus),a=Oe(s,r),l=Te(s,r),c=j(l),m=E(s.callees,l),g=[];for(let f of a){if(f.callees.size<3)continue;let o=E(f.callees,l),u=ue(s,f,l,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0,medianIdf:c,magnitudeA:m,magnitudeB:o});u&&g.push(u)}return g.sort((f,o)=>o.similarity-f.similarity),g}function Te(e,n){let t=new Map(n.docFreq);for(let i of e.callees)t.set(i,(t.get(i)??0)+1);return V(t,n.corpus.length+1)}function ue(e,n,t,i){let r=Re(e,n,t,i);if(!Ae(r,i))return null;let{similarity:s,significantShared:a,trivialShared:l}=r,c=a.length>0?a:l,m=Se(c,"callees");return{symbolA:e.symbol,shortNameA:I(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:I(n.symbol),fileB:n.file,similarity:s,similarityBasis:"callees",sharedCallees:c.map(I),uniqueToA:[...N(e.callees,n.callees)].map(I),uniqueToB:[...N(n.callees,e.callees)].map(I),...m}}function Le(e,n,t,i){let r=i.magnitudeA??E(e.callees,t),s=i.magnitudeB??E(n.callees,t),a=0,l=0,c=0,m=i.medianIdf??j(t);for(let o of e.callees){if(!n.callees.has(o))continue;let u=t.get(o)??0;a+=u*u,c+=1,u>=m&&(l+=1)}if(c===0)return!1;let g=r*s;return(g>0?a/g:0)<i.minSimilarity?!1:l>=i.requireSignificantShared||c>=i.requireSharedCount}function Re(e,n,t,i){return i.magnitudeA===void 0||i.magnitudeB===void 0?re(e.callees,n.callees,t,{medianIdf:i.medianIdf}):se(e.callees,n.callees,t,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB})}function Ae(e,n){if(e.similarity<n.minSimilarity)return!1;let t=e.significantShared.length+e.trivialShared.length;return e.significantShared.length>=n.requireSignificantShared||t>=n.requireSharedCount}function Tn(e,n={}){let{minSimilarity:t=.5,limit:i=20,scope:r,minCallees:s=4,crossFileOnly:a=!1,scanLimit:l}=n,c=n.semantic!==!1,m=A(),g=0,f=0,o=0,u=0,d=0,p=0,S=0;return y("similar.all",()=>{let b=G(e).calleeIndex({minCallees:s,scope:r,scanLimit:l,semantic:c}),C=b.corpus;g=C.length;let v=n.focusFiles,k=[],P=0;return y("similar.all.pair-scan",()=>{for(let x=0;x<C.length;x+=1){let F=C[x],T=v?.has(F.file)??!1,w=b.weightedMagnitudes[x],M=new Set;for(let O of F.callees){let L=b.candidateIndexesByCallee.get(O);if(L)for(let R of L)R<=x||v&&!T&&!v.has(C[R].file)||M.add(R)}m&&(o+=M.size,M.size>0&&(f+=1));for(let O of M){let L=C[O];if(a&&F.file===L.file){m&&(d+=1);continue}if(me(F,L)){m&&(p+=1);continue}m&&(u+=1);let R=ue(F,L,b.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:b.medianIdf,magnitudeA:w,magnitudeB:b.weightedMagnitudes[O]});R&&(Be(k,R,i,P),m&&(S+=1),P+=1)}}},()=>({corpusSize:g,candidateSets:f,candidatePairs:o,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:S,topResults:k.length})),y("similar.all.sort-project",()=>(k.sort((x,F)=>F.result.similarity-x.result.similarity||x.order-F.order),k.map(x=>x.result)),()=>({topResults:k.length}))},()=>({minSimilarity:t,limit:i,scope:r,minCallees:s,crossFileOnly:a,scanLimit:l,semantic:c,corpusSize:g,candidateSets:f,candidatePairs:o,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:S}))}function Ln(e,n={}){let{minSimilarity:t=.5,scope:i,minCallees:r=4,crossFileOnly:s=!1,scanLimit:a}=n,l=n.semantic!==!1,c=A(),m=0,g=0,f=0,o=0,u=0,d=0,p=0;return y("similar.all-count",()=>{let h=G(e).calleeIndex({minCallees:r,scope:i,scanLimit:a,semantic:l}),b=h.corpus;m=b.length;let C=n.focusFiles;return y("similar.all-count.pair-scan",()=>{for(let v=0;v<b.length;v+=1){let k=b[v],P=C?.has(k.file)??!1,x=h.weightedMagnitudes[v],F=new Set;for(let T of k.callees){let w=h.candidateIndexesByCallee.get(T);if(w)for(let M of w)M<=v||C&&!P&&!C.has(b[M].file)||F.add(M)}c&&(f+=F.size,F.size>0&&(g+=1));for(let T of F){let w=b[T];if(s&&k.file===w.file){c&&(u+=1);continue}if(me(k,w)){c&&(d+=1);continue}c&&(o+=1),Le(k,w,h.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:h.medianIdf,magnitudeA:x,magnitudeB:h.weightedMagnitudes[T]})&&(p+=1)}}},()=>({corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:o,crossFileSkips:u,signatureSkips:d,insertedResults:p})),p},()=>({minSimilarity:t,scope:i,minCallees:r,crossFileOnly:s,scanLimit:a,semantic:l,corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:o,crossFileSkips:u,signatureSkips:d,insertedResults:p}))}function me(e,n){if(e.paramCount<0||n.paramCount<0)return!1;let t=Math.abs(e.paramCount-n.paramCount),i=Math.max(2,Math.ceil(Math.max(e.paramCount,n.paramCount)*.5));return t>i}var de=Q({kind:"source-fingerprints",invalidation:ee("source-fingerprints"),serialize:cn,deserialize:ln});function Be(e,n,t,i){if(t<=0)return;if(e.length<t){e.push({result:n,order:i});return}let r=0;for(let a=1;a<e.length;a+=1){let l=e[a],c=e[r];(l.result.similarity<c.result.similarity||l.result.similarity===c.result.similarity&&l.order>c.order)&&(r=a)}let s=e[r];n.similarity<=s.result.similarity||(e[r]={result:n,order:i})}var Ee=["ScipDatabase#all","ScipDatabase#get","ScipDatabase#prepare","ScipDatabase#pathExclusionsFor","ScipDatabase#isIgnored","ScipDatabase#symbolNoiseFor","PerDbValue#get","PerDbValue#has",":storage:db:ScipDatabase:all",":storage:db:ScipDatabase:get",":storage:db:ScipDatabase:prepare",":storage:db:ScipDatabase:pathExclusionsFor",":storage:db:ScipDatabase:isIgnored",":storage:db:ScipDatabase:symbolNoiseFor",":storage:per-db-cache:PerDbValue:get",":storage:per-db-cache:PerDbValue:has"];function ze(e,n,t){let i=D(e,n);if(!i||!$(i.symbol))return null;let r=new q(e),s=ne(e,i,{semantic:t.semantic,semanticEvidence:ie});return{symbol:i.symbol,file:i.relativePath,callees:pe(s.map(a=>a.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}var De=z("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),qe=z("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function fe(e,n){let{minCallees:t,scope:i,excludeSymbol:r,scanLimit:s}=n,a=n.semantic!==!1,l=De.get(e,()=>new Map),c=`${t}|${i??""}|${s??""}|${a}`,m=!0,g=0,f=0;return y("similar.callee-fingerprints.resolve",()=>{let o=l.get(c);if(m=o!==void 0,o||(o=$e(e,{minCallees:t,scope:i,scanLimit:s,semantic:a}),l.set(c,o)),g=o.length,r===void 0)return o;let u=o.filter(d=>d.symbol!==r);return f=o.length-u.length,u},()=>({minCallees:t,scope:i,scanLimit:s,semantic:a,cacheHit:m,corpusSize:g,excludeSymbol:r!==void 0,excludedSymbols:f}))}function Ne(e,n){let{minCallees:t,scope:i,scanLimit:r}=n,s=n.semantic!==!1,a=qe.get(e,()=>new Map),l=`${t}|${i??""}|${r??""}|${s}`,c=!0,m=0,g=0,f=0;return y("similar.callee-index.resolve",()=>{let o=a.get(l);return c=o!==void 0,o||(o=Pe(fe(e,{minCallees:t,scope:i,scanLimit:r,semantic:s})),a.set(l,o)),m=o.corpus.length,g=o.docFreq.size,f=o.candidateIndexesByCallee.size,o},()=>({minCallees:t,scope:i,scanLimit:r,semantic:s,cacheHit:c,corpusSize:m,indexedCallees:g,candidateBuckets:f}))}function G(e){return{calleeCorpus:n=>fe(e,n),calleeIndex:n=>Ne(e,n),sourceCorpus:(n={})=>Fe(e,n),sourceIndex:(n={})=>ce(e,n),sourceCandidates:(n,t)=>(t.candidateMode??"full")==="target-pruned"?Qe(e,n,{minSimilarity:t.minSimilarity,scanLimit:t.scanLimit}):Ye(n,ce(e,{scanLimit:t.scanLimit}))}}function Pe(e){let n=A(),t=0,i=y("similar.callee-index.doc-frequency",()=>{let o=new Map;for(let u of e)for(let d of u.callees)o.set(d,(o.get(d)??0)+1);return t=o.size,o},()=>({corpusSize:e.length,uniqueCallees:t})),r=Math.max(8,Math.ceil(Math.sqrt(e.length))),s=y("similar.callee-index.idf-weights",()=>V(i,e.length),()=>({corpusSize:e.length,uniqueCallees:i.size})),a=y("similar.callee-index.weighted-magnitudes",()=>e.map(o=>E(o.callees,s)),()=>({corpusSize:e.length})),l=0,c=0,m=0,g=y("similar.callee-index.candidate-buckets",()=>{let o=new Map;for(let u=0;u<e.length;u+=1){let d=e[u];for(let p of d.callees){if((i.get(p)??0)>r){n&&(c+=1);continue}let S=o.get(p);S||(S=[],o.set(p,S)),S.push(u),n&&(l+=1)}}return n&&(m=o.size),o},()=>({corpusSize:e.length,buckets:m,candidateRefs:l,ubiquitousSkips:c,ubiquityThreshold:r})),f=y("similar.callee-index.median-idf",()=>j(s),()=>({uniqueCallees:s.size}));return{corpus:e,candidateIndexesByCallee:g,docFreq:i,idfWeights:s,weightedMagnitudes:a,medianIdf:f,ubiquityThreshold:r}}function Oe(e,n){let t=new Map;for(let i of e.callees)for(let r of n.candidateIndexesByCallee.get(i)??[]){let s=n.corpus[r];s.symbol!==e.symbol&&t.set(s.symbol,s)}return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function $e(e,n){let{minCallees:t,scope:i,scanLimit:r,semantic:s}=n,a=A(),l=new q(e),c=0,m=y("similar.callee-fingerprints.candidates",()=>{let p=_(l.productionCallableDefinitions({scope:i,minLoc:5,sortByLocDesc:typeof r=="number"&&r>0}),r);return c=p.length,p},()=>({scope:i,scanLimit:r,candidateCount:c})),g=0,f=y("similar.callee-fingerprints.callee-map",()=>{let p=l.calleeMap(m,{semantic:s});if(a)for(let S of p.values())g+=S.length;return p},()=>({candidateCount:c,semantic:s,calleeEdges:g})),o=0,u=0,d=0;return y("similar.callee-fingerprints.shape",()=>{let p=m.map(b=>({symbol:b.symbol,file:b.relativePath,callees:pe((f.get(b.symbolId)??[]).map(C=>C.symbol)),paramCount:l.callableSignature(b)?.paramCount??-1})),S=_e(p);a&&(d=S.filter((b,C)=>b.callees.size!==p[C].callees.size).length);let h=S.filter(b=>b.callees.size>=t);return o=h.length,a&&(u=h.reduce((b,C)=>b+C.callees.size,0)),h},()=>({candidateCount:c,fingerprintCount:o,retainedCalleeCount:u,minCallees:t,siblingSaturatedFingerprints:d}))}var ge=5;function _e(e){let n=new Map;for(let t of e){let i=n.get(t.file);i||(i=new Map,n.set(t.file,i));for(let r of t.callees)i.set(r,(i.get(r)??0)+1)}return e.map(t=>{let i=n.get(t.file);if(!i)return t;let r=[...t.callees].filter(a=>(i.get(a)??0)>=ge);if(r.length===0)return t;let s=new Set(t.callees);for(let a of r)s.delete(a);return{...t,callees:s}})}function je(e,n){let t=new Map;for(let s of n)if(!(s.file!==e.file||s.symbol===e.symbol))for(let a of s.callees)t.set(a,(t.get(a)??0)+1);let i=[...e.callees].filter(s=>(t.get(s)??0)+1>=ge);if(i.length===0)return e;let r=new Set(e.callees);for(let s of i)r.delete(s);return{...e,callees:r}}function pe(e){return new Set([...e].filter(n=>!Ge(n)))}function Ge(e){return Ee.some(n=>e.includes(n))}function ae(e,n,t){let i=Ve(e,n);if(!i||i.tokens.size<3)return[];let r=t.minSimilarity>=.5?t.minSimilarity:.3,s=[],a=t.candidateMode??"full",l=0,c=0,m=0,g=0;return y("similar.source-shape",()=>{let o=G(e).sourceCandidates(i,{minSimilarity:r,scanLimit:t.scanLimit,candidateMode:a});l=o.length;for(let u of o){if(u.symbol===i.symbol||u.tokens.size<3)continue;c+=1;let d=te(i.tokens,u.tokens);if(d.size<2){m+=1;continue}let p=new Set([...i.tokens,...u.tokens]),S=p.size>0?d.size/p.size:0;if(S<r){g+=1;continue}s.push({symbolA:i.symbol,shortNameA:I(i.symbol),fileA:i.file,symbolB:u.symbol,shortNameB:I(u.symbol),fileB:u.file,similarity:S,similarityBasis:"source-tokens",sharedCallees:[...d].sort(),uniqueToA:[...N(i.tokens,u.tokens)].sort(),uniqueToB:[...N(u.tokens,i.tokens)].sort(),...Se([...d],"source-tokens")})}return s.sort((u,d)=>d.similarity-u.similarity||u.shortNameB.localeCompare(d.shortNameB)),s.slice(0,t.limit)},()=>({symbol:i.symbol,file:i.file,targetTokens:i.tokens.size,candidateMode:a,candidates:l,comparedPairs:c,sharedSkips:m,similaritySkips:g,results:s.length}))}function Se(e,n){let t=e.flatMap(W),i=e.flatMap(S=>oe(S,n)),r=Z(t,be),s=Z(t,ye),a=Z(i,X),l=[...new Set(i.filter(le))],c=e.filter(S=>{let h=oe(S,n);return h.some(b=>X.has(b))&&h.some(le)}).length,m=[];r.length>0&&m.push(`access/query scaffolding: ${r.slice(0,5).join(", ")}`),s.length>0&&m.push(`framework/generic scaffolding: ${s.slice(0,5).join(", ")}`),a.length>0&&m.push(`domain behavior verbs: ${a.slice(0,5).join(", ")}`),a.length>0&&l.length>0&&m.push(`domain-specific terms: ${l.slice(0,5).join(", ")}`);let g=n==="source-tokens"&&t.length>0&&t.every(S=>he.has(S));g&&m.push("shared source tokens are generic scaffolding");let f=a.length>0&&l.length>0,o=r.length+s.length>0,u=n==="callees"&&f&&e.length>=4&&l.length>=4&&c>=2,d=u?"domain-behavior":f?o?"mixed":"domain-behavior":r.length>0?"access-query-scaffolding":s.length>0||g?"framework-scaffolding":"structural-overlap";d==="structural-overlap"&&e.length>0&&m.push(`shared ${n} overlap has no recognized domain or scaffolding category`);let p=d==="domain-behavior"&&(e.length>=3||u)?"direct":"signal";return{evidenceClass:d,actionTier:p,evidenceClassReasons:m,recommendation:Ue(d,p)}}function Ue(e,n){return n==="direct"?"Shared domain behavior looks concrete; review for an extract/reuse opportunity.":e==="mixed"?"Shared evidence mixes domain behavior with scaffolding; review semantics before extracting anything.":e==="access-query-scaffolding"?"Shared evidence is mostly access/query scaffolding; compare product semantics before reusing code.":e==="structural-overlap"?"Shared structure has no domain or scaffolding classification; inspect names and behavior before reusing code.":"Shared evidence is mostly framework or generic scaffolding; treat as a contextual signal."}function Z(e,n){return[...new Set(e.filter(t=>n.has(t)))]}function W(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>1)}function oe(e,n){if(n==="source-tokens")return W(e);let t=K(e);return W(t.length>0?t:He(e))}function He(e){return e.replace(/[()`]/g," ").replace(/\.[a-z][a-z0-9]+(?=\s|$)/gi," ").split(/[:/\\\s]+/).map(i=>i.trim()).filter(i=>/[A-Za-z]/.test(i)).at(-1)?.replace(/\.$/,"")??e}function le(e){return e.length>3&&!X.has(e)&&!be.has(e)&&!ye.has(e)&&!he.has(e)&&!Ke.has(e)}var X=new Set(["archive","assign","book","cancel","create","delete","ensure","export","import","notify","persist","publish","restore","schedule","send","set","submit","sync","update","upload","validate","write"]),be=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),ye=new Set(["bytes","computed","crypto","describe","effect","expect","fetch","filter","hex","hook","json","map","mounted","on","promise","random","react","reduce","ref","render","state","test","token","trim","uuid","vue","watch"]),he=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),Ke=new Set(["best","backend","conflict","database","effect","effects","error","errors","frontend","found","helpers","javascript","module","modules","scip","shared","source","typescript","utils","with","workflow","workflows"]);function Ve(e,n){let t=D(e,n);if(!t||!$(t.symbol))return null;let i=Ze(e,t);return i?{symbol:t.symbol,file:t.relativePath,tokens:i}:null}function Ze(e,n){let t=K(n.symbol),i=sn(e,n.relativePath,n.startLine,n.endLine,t),r=Ie(i,t);return r.size>0?r:null}var We=z("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),Xe=z("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function Ce(e){return`${e.scanLimit??""}`}function Fe(e,n={}){let t=We.get(e,()=>new Map),i=Ce(n),r=t.get(i);return r||(r=rn(e,n),t.set(i,r)),r}function ce(e,n={}){let t=Xe.get(e,()=>new Map),i=Ce(n),r=t.get(i);return r||(r=Je(Fe(e,n)),t.set(i,r)),r}function Je(e){let n=new Map;for(let r of e)for(let s of r.tokens)n.set(s,(n.get(s)??0)+1);let t=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=new Map;for(let r of e)for(let s of r.tokens){if((n.get(s)??0)>t)continue;let a=i.get(s);a||(a=[],i.set(s,a)),a.push(r)}return{corpus:e,candidateByToken:i,docFreq:n,ubiquityThreshold:t}}function Ye(e,n){let t=new Map;for(let i of e.tokens)for(let r of n.candidateByToken.get(i)??[])r.symbol!==e.symbol&&t.set(r.symbol,r);return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function Qe(e,n,t){let i=A(),r=new q(e),s=en(n.tokens.size,t.minSimilarity),a=0,l=0,c=0,m=y("similar.source-shape.target-files",()=>{let d=[...n.tokens],p=[];for(let S of Y(e,{includeIgnored:!1})){a+=1;let h=U(e,S);h&&(l+=1,nn(h,d,s)&&p.push(S))}return c=p.length,p},()=>({symbol:n.symbol,targetTokens:n.tokens.size,requiredSharedTokens:s,scannedFiles:a,readableFiles:l,candidateFiles:c})),g=0,f=y("similar.source-shape.target-definitions",()=>{let d=_(r.productionCallableDefinitions({files:m,sortByLocDesc:typeof t.scanLimit=="number"&&t.scanLimit>0}),t.scanLimit);return g=d.length,d},()=>({symbol:n.symbol,candidateFiles:c,scanLimit:t.scanLimit,definitionCount:g})),o=0;return y("similar.source-shape.target-fingerprints",()=>{let d=xe(e,f);return i&&(o=d.length),d},()=>({symbol:n.symbol,definitionCount:g,fingerprintCount:o})).filter(d=>d.symbol!==n.symbol)}function en(e,n){return Math.max(2,Math.ceil(e*n))}function nn(e,n,t){if(n.length<t)return!1;let i=e.toLowerCase(),r=0;for(let s of n)if(tn(i,s)&&(r+=1,r>=t))return!0;return!1}function tn(e,n){return n==="num"?/\b\d+\b/.test(e):e.includes(n)}function rn(e,n={}){let t=new q(e),{scanLimit:i}=n,r=_(t.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return xe(e,r)}function xe(e,n){let t=new Map;for(let r of n){let s=t.get(r.relativePath)??[];s.push(r),t.set(r.relativePath,s)}let i=new Map;for(let[r,s]of t){let a=U(e,r);if(!a)continue;let l=J(e,r,a),c=on(e,r,l),m=!1,g=null;for(let f of s){let o=an(f),u=c.get(o),d=u?new Set(u.tokens):null;d||(g??=H(e,r),d=Ie(ke(g,f.startLine,f.endLine,f.leaf),f.leaf),c.set(o,{key:o,symbol:f.symbol,startLine:f.startLine,endLine:f.endLine,leaf:f.leaf,tokens:[...d].sort()}),m=!0),d.size>0&&i.set(f.symbol,{symbol:f.symbol,file:f.relativePath,tokens:d})}m&&un(e,r,l,c)}return n.map(r=>i.get(r.symbol)).filter(r=>!!r)}function sn(e,n,t,i,r){let s=H(e,n);return s.length===0?"":ke(s,t,i,r)}function ke(e,n,t,i){if(t>=n&&t-n<=12)return e.slice(n,t+1).join(`
|
|
1
|
+
import{a as te,b as N,e as V,f as j,g as E,h as re,i as se}from"./chunk-KMVGRIO2.js";import{a as q}from"./chunk-7TJJY2C3.js";import{b as _}from"./chunk-B75HZHUP.js";import{a as ne}from"./chunk-EMIIOOTM.js";import{n as ie}from"./chunk-DZXFZAZO.js";import{a as D}from"./chunk-HFBNIIZX.js";import{d as I,e as K,h as $}from"./chunk-AYRHVJXW.js";import{a as B}from"./chunk-GAE7WCBK.js";import{d as z,h as J,q as A,s as y,v as Q,x as ee,y as U,z as H}from"./chunk-FC5K7T35.js";import{a as Y}from"./chunk-64MNV6AB.js";function ve(e,n,t={}){let{minSimilarity:i=.4,limit:r=20}=t,s=ze(e,n,{semantic:t.semantic!==!1});if(!s)return[];if(!$(s.symbol))return[];if(s.callees.size===0)return ae(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"});let a=Me(e,s,i,{scanLimit:t.scanLimit,semantic:t.semantic!==!1});return a.length>0?a.slice(0,r):ae(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"})}function Mn(e,n,t,i={}){let r=D(e,n),s=D(e,t);if(!r||!s)return null;let a=ve(e,r.symbol,{minSimilarity:0,limit:Number.POSITIVE_INFINITY,semantic:i.semantic,scanLimit:i.scanLimit}).find(m=>m.symbolB===s.symbol||m.symbolA===s.symbol);if(!a)return null;let l=r.endLine-r.startLine+1,c=s.endLine-s.startLine+1;return{symbolA:{symbol:r.symbol,shortName:I(r.symbol),file:r.relativePath,loc:l},symbolB:{symbol:s.symbol,shortName:I(s.symbol),file:s.relativePath,loc:c},similarity:a.similarity,similarityBasis:a.similarityBasis??"callees",sharedEvidence:a.sharedCallees,uniqueToA:a.uniqueToA,uniqueToB:a.uniqueToB,evidenceClass:a.evidenceClass,actionTier:a.actionTier,recommendation:a.recommendation,consolidationStrategy:we(a)}}function we(e){let n=e.similarityBasis==="source-tokens"?"source-token":"tracked callee";return e.sharedCallees.length===0?`No shared ${n} evidence survived similar's weighting. Inspect the source before attempting consolidation.`:e.uniqueToA.length===0&&e.uniqueToB.length===0?`The functions have identical ${n} evidence under similar's weighting. Verify signatures, guards, and return values before consolidating.`:e.uniqueToA.length===0?`A's ${n} evidence is a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToB.length===0?`B's ${n} evidence is a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToA.length<=2&&e.uniqueToB.length<=2?`Create a shared helper around the ${e.sharedCallees.length} shared ${n}(s). Pass the ${e.uniqueToA.length+e.uniqueToB.length} divergent point(s) as parameters or callbacks.`:`Extract the ${e.sharedCallees.length} shared ${n}(s) into a common helper. Keep each function's unique logic outside that helper (${e.uniqueToA.length} item(s) in A, ${e.uniqueToB.length} in B).`}function Me(e,n,t,i){let r=G(e).calleeIndex({minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),s=je(n,r.corpus),a=Oe(s,r),l=Te(s,r),c=j(l),m=E(s.callees,l),g=[];for(let f of a){if(f.callees.size<3)continue;let o=E(f.callees,l),u=ue(s,f,l,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0,medianIdf:c,magnitudeA:m,magnitudeB:o});u&&g.push(u)}return g.sort((f,o)=>o.similarity-f.similarity),g}function Te(e,n){let t=new Map(n.docFreq);for(let i of e.callees)t.set(i,(t.get(i)??0)+1);return V(t,n.corpus.length+1)}function ue(e,n,t,i){let r=Re(e,n,t,i);if(!Ae(r,i))return null;let{similarity:s,significantShared:a,trivialShared:l}=r,c=a.length>0?a:l,m=Se(c,"callees");return{symbolA:e.symbol,shortNameA:I(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:I(n.symbol),fileB:n.file,similarity:s,similarityBasis:"callees",sharedCallees:c.map(I),uniqueToA:[...N(e.callees,n.callees)].map(I),uniqueToB:[...N(n.callees,e.callees)].map(I),...m}}function Le(e,n,t,i){let r=i.magnitudeA??E(e.callees,t),s=i.magnitudeB??E(n.callees,t),a=0,l=0,c=0,m=i.medianIdf??j(t);for(let o of e.callees){if(!n.callees.has(o))continue;let u=t.get(o)??0;a+=u*u,c+=1,u>=m&&(l+=1)}if(c===0)return!1;let g=r*s;return(g>0?a/g:0)<i.minSimilarity?!1:l>=i.requireSignificantShared||c>=i.requireSharedCount}function Re(e,n,t,i){return i.magnitudeA===void 0||i.magnitudeB===void 0?re(e.callees,n.callees,t,{medianIdf:i.medianIdf}):se(e.callees,n.callees,t,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB})}function Ae(e,n){if(e.similarity<n.minSimilarity)return!1;let t=e.significantShared.length+e.trivialShared.length;return e.significantShared.length>=n.requireSignificantShared||t>=n.requireSharedCount}function Tn(e,n={}){let{minSimilarity:t=.5,limit:i=20,scope:r,minCallees:s=4,crossFileOnly:a=!1,scanLimit:l}=n,c=n.semantic!==!1,m=A(),g=0,f=0,o=0,u=0,d=0,p=0,S=0;return y("similar.all",()=>{let b=G(e).calleeIndex({minCallees:s,scope:r,scanLimit:l,semantic:c}),C=b.corpus;g=C.length;let v=n.focusFiles,k=[],P=0;return y("similar.all.pair-scan",()=>{for(let x=0;x<C.length;x+=1){let F=C[x],T=v?.has(F.file)??!1,w=b.weightedMagnitudes[x],M=new Set;for(let O of F.callees){let L=b.candidateIndexesByCallee.get(O);if(L)for(let R of L)R<=x||v&&!T&&!v.has(C[R].file)||M.add(R)}m&&(o+=M.size,M.size>0&&(f+=1));for(let O of M){let L=C[O];if(a&&F.file===L.file){m&&(d+=1);continue}if(me(F,L)){m&&(p+=1);continue}m&&(u+=1);let R=ue(F,L,b.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:b.medianIdf,magnitudeA:w,magnitudeB:b.weightedMagnitudes[O]});R&&(Be(k,R,i,P),m&&(S+=1),P+=1)}}},()=>({corpusSize:g,candidateSets:f,candidatePairs:o,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:S,topResults:k.length})),y("similar.all.sort-project",()=>(k.sort((x,F)=>F.result.similarity-x.result.similarity||x.order-F.order),k.map(x=>x.result)),()=>({topResults:k.length}))},()=>({minSimilarity:t,limit:i,scope:r,minCallees:s,crossFileOnly:a,scanLimit:l,semantic:c,corpusSize:g,candidateSets:f,candidatePairs:o,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:S}))}function Ln(e,n={}){let{minSimilarity:t=.5,scope:i,minCallees:r=4,crossFileOnly:s=!1,scanLimit:a}=n,l=n.semantic!==!1,c=A(),m=0,g=0,f=0,o=0,u=0,d=0,p=0;return y("similar.all-count",()=>{let h=G(e).calleeIndex({minCallees:r,scope:i,scanLimit:a,semantic:l}),b=h.corpus;m=b.length;let C=n.focusFiles;return y("similar.all-count.pair-scan",()=>{for(let v=0;v<b.length;v+=1){let k=b[v],P=C?.has(k.file)??!1,x=h.weightedMagnitudes[v],F=new Set;for(let T of k.callees){let w=h.candidateIndexesByCallee.get(T);if(w)for(let M of w)M<=v||C&&!P&&!C.has(b[M].file)||F.add(M)}c&&(f+=F.size,F.size>0&&(g+=1));for(let T of F){let w=b[T];if(s&&k.file===w.file){c&&(u+=1);continue}if(me(k,w)){c&&(d+=1);continue}c&&(o+=1),Le(k,w,h.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:h.medianIdf,magnitudeA:x,magnitudeB:h.weightedMagnitudes[T]})&&(p+=1)}}},()=>({corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:o,crossFileSkips:u,signatureSkips:d,insertedResults:p})),p},()=>({minSimilarity:t,scope:i,minCallees:r,crossFileOnly:s,scanLimit:a,semantic:l,corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:o,crossFileSkips:u,signatureSkips:d,insertedResults:p}))}function me(e,n){if(e.paramCount<0||n.paramCount<0)return!1;let t=Math.abs(e.paramCount-n.paramCount),i=Math.max(2,Math.ceil(Math.max(e.paramCount,n.paramCount)*.5));return t>i}var de=Q({kind:"source-fingerprints",invalidation:ee("source-fingerprints"),serialize:cn,deserialize:ln});function Be(e,n,t,i){if(t<=0)return;if(e.length<t){e.push({result:n,order:i});return}let r=0;for(let a=1;a<e.length;a+=1){let l=e[a],c=e[r];(l.result.similarity<c.result.similarity||l.result.similarity===c.result.similarity&&l.order>c.order)&&(r=a)}let s=e[r];n.similarity<=s.result.similarity||(e[r]={result:n,order:i})}var Ee=["ScipDatabase#all","ScipDatabase#get","ScipDatabase#prepare","ScipDatabase#pathExclusionsFor","ScipDatabase#isIgnored","ScipDatabase#symbolNoiseFor","PerDbValue#get","PerDbValue#has",":storage:db:ScipDatabase:all",":storage:db:ScipDatabase:get",":storage:db:ScipDatabase:prepare",":storage:db:ScipDatabase:pathExclusionsFor",":storage:db:ScipDatabase:isIgnored",":storage:db:ScipDatabase:symbolNoiseFor",":storage:per-db-cache:PerDbValue:get",":storage:per-db-cache:PerDbValue:has"];function ze(e,n,t){let i=D(e,n);if(!i||!$(i.symbol))return null;let r=new q(e),s=ne(e,i,{semantic:t.semantic,semanticEvidence:ie});return{symbol:i.symbol,file:i.relativePath,callees:pe(s.map(a=>a.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}var De=z("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),qe=z("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function fe(e,n){let{minCallees:t,scope:i,excludeSymbol:r,scanLimit:s}=n,a=n.semantic!==!1,l=De.get(e,()=>new Map),c=`${t}|${i??""}|${s??""}|${a}`,m=!0,g=0,f=0;return y("similar.callee-fingerprints.resolve",()=>{let o=l.get(c);if(m=o!==void 0,o||(o=$e(e,{minCallees:t,scope:i,scanLimit:s,semantic:a}),l.set(c,o)),g=o.length,r===void 0)return o;let u=o.filter(d=>d.symbol!==r);return f=o.length-u.length,u},()=>({minCallees:t,scope:i,scanLimit:s,semantic:a,cacheHit:m,corpusSize:g,excludeSymbol:r!==void 0,excludedSymbols:f}))}function Ne(e,n){let{minCallees:t,scope:i,scanLimit:r}=n,s=n.semantic!==!1,a=qe.get(e,()=>new Map),l=`${t}|${i??""}|${r??""}|${s}`,c=!0,m=0,g=0,f=0;return y("similar.callee-index.resolve",()=>{let o=a.get(l);return c=o!==void 0,o||(o=Pe(fe(e,{minCallees:t,scope:i,scanLimit:r,semantic:s})),a.set(l,o)),m=o.corpus.length,g=o.docFreq.size,f=o.candidateIndexesByCallee.size,o},()=>({minCallees:t,scope:i,scanLimit:r,semantic:s,cacheHit:c,corpusSize:m,indexedCallees:g,candidateBuckets:f}))}function G(e){return{calleeCorpus:n=>fe(e,n),calleeIndex:n=>Ne(e,n),sourceCorpus:(n={})=>Fe(e,n),sourceIndex:(n={})=>ce(e,n),sourceCandidates:(n,t)=>(t.candidateMode??"full")==="target-pruned"?Qe(e,n,{minSimilarity:t.minSimilarity,scanLimit:t.scanLimit}):Ye(n,ce(e,{scanLimit:t.scanLimit}))}}function Pe(e){let n=A(),t=0,i=y("similar.callee-index.doc-frequency",()=>{let o=new Map;for(let u of e)for(let d of u.callees)o.set(d,(o.get(d)??0)+1);return t=o.size,o},()=>({corpusSize:e.length,uniqueCallees:t})),r=Math.max(8,Math.ceil(Math.sqrt(e.length))),s=y("similar.callee-index.idf-weights",()=>V(i,e.length),()=>({corpusSize:e.length,uniqueCallees:i.size})),a=y("similar.callee-index.weighted-magnitudes",()=>e.map(o=>E(o.callees,s)),()=>({corpusSize:e.length})),l=0,c=0,m=0,g=y("similar.callee-index.candidate-buckets",()=>{let o=new Map;for(let u=0;u<e.length;u+=1){let d=e[u];for(let p of d.callees){if((i.get(p)??0)>r){n&&(c+=1);continue}let S=o.get(p);S||(S=[],o.set(p,S)),S.push(u),n&&(l+=1)}}return n&&(m=o.size),o},()=>({corpusSize:e.length,buckets:m,candidateRefs:l,ubiquitousSkips:c,ubiquityThreshold:r})),f=y("similar.callee-index.median-idf",()=>j(s),()=>({uniqueCallees:s.size}));return{corpus:e,candidateIndexesByCallee:g,docFreq:i,idfWeights:s,weightedMagnitudes:a,medianIdf:f,ubiquityThreshold:r}}function Oe(e,n){let t=new Map;for(let i of e.callees)for(let r of n.candidateIndexesByCallee.get(i)??[]){let s=n.corpus[r];s.symbol!==e.symbol&&t.set(s.symbol,s)}return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function $e(e,n){let{minCallees:t,scope:i,scanLimit:r,semantic:s}=n,a=A(),l=new q(e),c=0,m=y("similar.callee-fingerprints.candidates",()=>{let p=_(l.productionCallableDefinitions({scope:i,minLoc:5,sortByLocDesc:typeof r=="number"&&r>0}),r);return c=p.length,p},()=>({scope:i,scanLimit:r,candidateCount:c})),g=0,f=y("similar.callee-fingerprints.callee-map",()=>{let p=l.calleeMap(m,{semantic:s});if(a)for(let S of p.values())g+=S.length;return p},()=>({candidateCount:c,semantic:s,calleeEdges:g})),o=0,u=0,d=0;return y("similar.callee-fingerprints.shape",()=>{let p=m.map(b=>({symbol:b.symbol,file:b.relativePath,callees:pe((f.get(b.symbolId)??[]).map(C=>C.symbol)),paramCount:l.callableSignature(b)?.paramCount??-1})),S=_e(p);a&&(d=S.filter((b,C)=>b.callees.size!==p[C].callees.size).length);let h=S.filter(b=>b.callees.size>=t);return o=h.length,a&&(u=h.reduce((b,C)=>b+C.callees.size,0)),h},()=>({candidateCount:c,fingerprintCount:o,retainedCalleeCount:u,minCallees:t,siblingSaturatedFingerprints:d}))}var ge=5;function _e(e){let n=new Map;for(let t of e){let i=n.get(t.file);i||(i=new Map,n.set(t.file,i));for(let r of t.callees)i.set(r,(i.get(r)??0)+1)}return e.map(t=>{let i=n.get(t.file);if(!i)return t;let r=[...t.callees].filter(a=>(i.get(a)??0)>=ge);if(r.length===0)return t;let s=new Set(t.callees);for(let a of r)s.delete(a);return{...t,callees:s}})}function je(e,n){let t=new Map;for(let s of n)if(!(s.file!==e.file||s.symbol===e.symbol))for(let a of s.callees)t.set(a,(t.get(a)??0)+1);let i=[...e.callees].filter(s=>(t.get(s)??0)+1>=ge);if(i.length===0)return e;let r=new Set(e.callees);for(let s of i)r.delete(s);return{...e,callees:r}}function pe(e){return new Set([...e].filter(n=>!Ge(n)))}function Ge(e){return Ee.some(n=>e.includes(n))}function ae(e,n,t){let i=Ve(e,n);if(!i||i.tokens.size<3)return[];let r=t.minSimilarity>=.5?t.minSimilarity:.3,s=[],a=t.candidateMode??"full",l=0,c=0,m=0,g=0;return y("similar.source-shape",()=>{let o=G(e).sourceCandidates(i,{minSimilarity:r,scanLimit:t.scanLimit,candidateMode:a});l=o.length;for(let u of o){if(u.symbol===i.symbol||u.tokens.size<3)continue;c+=1;let d=te(i.tokens,u.tokens);if(d.size<2){m+=1;continue}let p=new Set([...i.tokens,...u.tokens]),S=p.size>0?d.size/p.size:0;if(S<r){g+=1;continue}s.push({symbolA:i.symbol,shortNameA:I(i.symbol),fileA:i.file,symbolB:u.symbol,shortNameB:I(u.symbol),fileB:u.file,similarity:S,similarityBasis:"source-tokens",sharedCallees:[...d].sort(),uniqueToA:[...N(i.tokens,u.tokens)].sort(),uniqueToB:[...N(u.tokens,i.tokens)].sort(),...Se([...d],"source-tokens")})}return s.sort((u,d)=>d.similarity-u.similarity||u.shortNameB.localeCompare(d.shortNameB)),s.slice(0,t.limit)},()=>({symbol:i.symbol,file:i.file,targetTokens:i.tokens.size,candidateMode:a,candidates:l,comparedPairs:c,sharedSkips:m,similaritySkips:g,results:s.length}))}function Se(e,n){let t=e.flatMap(W),i=e.flatMap(S=>oe(S,n)),r=Z(t,be),s=Z(t,ye),a=Z(i,X),l=[...new Set(i.filter(le))],c=e.filter(S=>{let h=oe(S,n);return h.some(b=>X.has(b))&&h.some(le)}).length,m=[];r.length>0&&m.push(`access/query scaffolding: ${r.slice(0,5).join(", ")}`),s.length>0&&m.push(`framework/generic scaffolding: ${s.slice(0,5).join(", ")}`),a.length>0&&m.push(`domain behavior verbs: ${a.slice(0,5).join(", ")}`),a.length>0&&l.length>0&&m.push(`domain-specific terms: ${l.slice(0,5).join(", ")}`);let g=n==="source-tokens"&&t.length>0&&t.every(S=>he.has(S));g&&m.push("shared source tokens are generic scaffolding");let f=a.length>0&&l.length>0,o=r.length+s.length>0,u=n==="callees"&&f&&e.length>=4&&l.length>=4&&c>=2,d=u?"domain-behavior":f?o?"mixed":"domain-behavior":r.length>0?"access-query-scaffolding":s.length>0||g?"framework-scaffolding":"structural-overlap";d==="structural-overlap"&&e.length>0&&m.push(`shared ${n} overlap has no recognized domain or scaffolding category`);let p=d==="domain-behavior"&&(e.length>=3||u)?"direct":"signal";return{evidenceClass:d,actionTier:p,evidenceClassReasons:m,recommendation:Ue(d,p)}}function Ue(e,n){return n==="direct"?"Shared domain behavior looks concrete; review for an extract/reuse opportunity.":e==="mixed"?"Shared evidence mixes domain behavior with scaffolding; review semantics before extracting anything.":e==="access-query-scaffolding"?"Shared evidence is mostly access/query scaffolding; compare product semantics before reusing code.":e==="structural-overlap"?"Shared structure has no domain or scaffolding classification; inspect names and behavior before reusing code.":"Shared evidence is mostly framework or generic scaffolding; treat as a contextual signal."}function Z(e,n){return[...new Set(e.filter(t=>n.has(t)))]}function W(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>1)}function oe(e,n){if(n==="source-tokens")return W(e);let t=K(e);return W(t.length>0?t:He(e))}function He(e){return e.replace(/[()`]/g," ").replace(/\.[a-z][a-z0-9]+(?=\s|$)/gi," ").split(/[:/\\\s]+/).map(i=>i.trim()).filter(i=>/[A-Za-z]/.test(i)).at(-1)?.replace(/\.$/,"")??e}function le(e){return e.length>3&&!X.has(e)&&!be.has(e)&&!ye.has(e)&&!he.has(e)&&!Ke.has(e)}var X=new Set(["archive","assign","book","cancel","create","delete","ensure","export","import","notify","persist","publish","restore","schedule","send","set","submit","sync","update","upload","validate","write"]),be=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),ye=new Set(["bytes","computed","crypto","describe","effect","expect","fetch","filter","hex","hook","json","map","mounted","on","promise","random","react","reduce","ref","render","state","test","token","trim","uuid","vue","watch"]),he=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),Ke=new Set(["best","backend","conflict","database","effect","effects","error","errors","frontend","found","helpers","javascript","module","modules","scip","shared","source","typescript","utils","with","workflow","workflows"]);function Ve(e,n){let t=D(e,n);if(!t||!$(t.symbol))return null;let i=Ze(e,t);return i?{symbol:t.symbol,file:t.relativePath,tokens:i}:null}function Ze(e,n){let t=K(n.symbol),i=sn(e,n.relativePath,n.startLine,n.endLine,t),r=Ie(i,t);return r.size>0?r:null}var We=z("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),Xe=z("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function Ce(e){return`${e.scanLimit??""}`}function Fe(e,n={}){let t=We.get(e,()=>new Map),i=Ce(n),r=t.get(i);return r||(r=rn(e,n),t.set(i,r)),r}function ce(e,n={}){let t=Xe.get(e,()=>new Map),i=Ce(n),r=t.get(i);return r||(r=Je(Fe(e,n)),t.set(i,r)),r}function Je(e){let n=new Map;for(let r of e)for(let s of r.tokens)n.set(s,(n.get(s)??0)+1);let t=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=new Map;for(let r of e)for(let s of r.tokens){if((n.get(s)??0)>t)continue;let a=i.get(s);a||(a=[],i.set(s,a)),a.push(r)}return{corpus:e,candidateByToken:i,docFreq:n,ubiquityThreshold:t}}function Ye(e,n){let t=new Map;for(let i of e.tokens)for(let r of n.candidateByToken.get(i)??[])r.symbol!==e.symbol&&t.set(r.symbol,r);return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function Qe(e,n,t){let i=A(),r=new q(e),s=en(n.tokens.size,t.minSimilarity),a=0,l=0,c=0,m=y("similar.source-shape.target-files",()=>{let d=[...n.tokens],p=[];for(let S of Y(e,{includeIgnored:!1})){a+=1;let h=U(e,S);h&&(l+=1,nn(h,d,s)&&p.push(S))}return c=p.length,p},()=>({symbol:n.symbol,targetTokens:n.tokens.size,requiredSharedTokens:s,scannedFiles:a,readableFiles:l,candidateFiles:c})),g=0,f=y("similar.source-shape.target-definitions",()=>{let d=_(r.productionCallableDefinitions({files:m,sortByLocDesc:typeof t.scanLimit=="number"&&t.scanLimit>0}),t.scanLimit);return g=d.length,d},()=>({symbol:n.symbol,candidateFiles:c,scanLimit:t.scanLimit,definitionCount:g})),o=0;return y("similar.source-shape.target-fingerprints",()=>{let d=xe(e,f);return i&&(o=d.length),d},()=>({symbol:n.symbol,definitionCount:g,fingerprintCount:o})).filter(d=>d.symbol!==n.symbol)}function en(e,n){return Math.max(2,Math.ceil(e*n))}function nn(e,n,t){if(n.length<t)return!1;let i=e.toLowerCase(),r=0;for(let s of n)if(tn(i,s)&&(r+=1,r>=t))return!0;return!1}function tn(e,n){return n==="num"?/\b\d+\b/.test(e):e.includes(n)}function rn(e,n={}){let t=new q(e),{scanLimit:i}=n,r=_(t.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return xe(e,r)}function xe(e,n){let t=new Map;for(let r of n){let s=t.get(r.relativePath)??[];s.push(r),t.set(r.relativePath,s)}let i=new Map;for(let[r,s]of t){let a=U(e,r);if(!a)continue;let l=J(e,r,a),c=on(e,r,l),m=!1,g=null;for(let f of s){let o=an(f),u=c.get(o),d=u?new Set(u.tokens):null;d||(g??=H(e,r),d=Ie(ke(g,f.startLine,f.endLine,f.leaf),f.leaf),c.set(o,{key:o,symbol:f.symbol,startLine:f.startLine,endLine:f.endLine,leaf:f.leaf,tokens:[...d].sort()}),m=!0),d.size>0&&i.set(f.symbol,{symbol:f.symbol,file:f.relativePath,tokens:d})}m&&un(e,r,l,c)}return n.map(r=>i.get(r.symbol)).filter(r=>!!r)}function sn(e,n,t,i,r){let s=H(e,n);return s.length===0?"":ke(s,t,i,r)}function ke(e,n,t,i){if(t>=n&&t-n<=12)return e.slice(n,t+1).join(`
|
|
2
2
|
`);let r=[new RegExp(`\\bdef\\s+${B(i)}\\b`),new RegExp(`\\bfun\\s+${B(i)}\\b`),new RegExp(`\\bfn\\s+${B(i)}\\b`),new RegExp(`\\bfunction\\s+${B(i)}\\b`),new RegExp(`\\b${B(i)}\\s*\\(`)],s=e.findIndex(a=>r.some(l=>l.test(a)));if(s>=0){let a=s;for(let l=s+1;l<e.length&&l<=s+8;l++){let c=e[l]??"";if(l>s&&dn(c)||(a=l,c.trim()===""&&l>s+1))break}return e.slice(s,a+1).join(`
|
|
3
3
|
`)}return e.slice(n,Math.min(e.length,n+8)).join(`
|
|
4
4
|
`)}function an(e){return`${e.symbol}\0${e.startLine}\0${e.endLine}\0${e.leaf}`}function on(e,n,t){return de.read(e,n,t)??new Map}function ln(e){try{let n=JSON.parse(e);if(!Array.isArray(n.entries))return null;let t=new Map;for(let i of n.entries){if(!i||typeof i.key!="string"||typeof i.symbol!="string"||typeof i.startLine!="number"||typeof i.endLine!="number"||typeof i.leaf!="string"||!Array.isArray(i.tokens)||!i.tokens.every(r=>typeof r=="string"))return null;t.set(i.key,i)}return t}catch{return null}}function cn(e){let n={entries:[...e.values()].sort((t,i)=>t.key.localeCompare(i.key))};return JSON.stringify(n)}function un(e,n,t,i){de.write(e,n,t,new Map(i))}function Ie(e,n){if(!e)return new Set;let t=new Set(["public","private","protected","final","static","class","def","fun","fn","function","return","string","bool","boolean","void","unit","self","this","new","const","let","var","end","pub"]),i=mn(n),s=e.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(a=>a.trim()).filter(a=>a.length>1).filter(a=>!t.has(a)).filter(a=>!i.has(a));return new Set(s)}function mn(e){return new Set(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(n=>n.toLowerCase()).filter(n=>n.length>1))}function dn(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}export{ve as a,Mn as b,Te as c,ue as d,Tn as e,Ln as f,Be as g,fe as h,Ne as i,G as j,Pe as k,Oe as l,ge as m,_e as n,pe as o,Se as p};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-JJZRS2OP.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as Ae}from"./chunk-WFRET75Z.js";import{a as Te}from"./chunk-CKFMZE77.js";import{a as ce,b as F,e as le}from"./chunk-FRXB74RQ.js";import{a as he,c as ge,d as pe,e as v}from"./chunk-24ET4VLC.js";import{a as Re}from"./chunk-XZXUMGAA.js";import{a as De}from"./chunk-5W2VAEVR.js";import{a as Fe}from"./chunk-C2QSK7E7.js";import{a as we}from"./chunk-7SGOWD2Y.js";import{a as $e}from"./chunk-OOUJBAKJ.js";import{a as Ce}from"./chunk-GIHVWNKQ.js";import{a as Se}from"./chunk-YCSTKIYU.js";import{a as me}from"./chunk-5GOBZI34.js";import{b as ue}from"./chunk-53SUJOJA.js";import{a as de,b as fe}from"./chunk-WWCZCH7W.js";import{a as oe,b as se,c as ae,g as _,h as H}from"./chunk-3WLRW5TC.js";import{b as be}from"./chunk-B2WQKQKP.js";import{a as L,c as ie,d as ne,e as re}from"./chunk-FB6IKAKZ.js";import{a as te}from"./chunk-KMOMNTB4.js";import{a as ke,e as ve}from"./chunk-JJZRS2OP.js";import{a as I,c as z,d as O,e as ye}from"./chunk-DO775SYA.js";import{a as ee}from"./chunk-7TJJY2C3.js";import{f as x,g as G}from"./chunk-CAKPEQZB.js";import{e as Q}from"./chunk-DZXFZAZO.js";import{d as M,e as R,f as Z,g as P}from"./chunk-AYRHVJXW.js";import{a as X}from"./chunk-GAE7WCBK.js";import{e as V}from"./chunk-WAU7HVDI.js";import{s as Y}from"./chunk-FC5K7T35.js";import{createHash as ct}from"crypto";import{existsSync as K}from"fs";function U(e){let[t,i]=T(e,":"),r=t||"unknown",n=(a={})=>{let s=a.actionTier??We(r);return{sourceAnalyzer:r,actionTier:s,rootCauseKey:a.rootCauseKey??(i||e),label:a.label??`${r} finding`,relatedFiles:a.relatedFiles??[],why:a.why??[],remediation:a.remediation??Je(s,r),file:a.file}};if(!i)return n({rootCauseKey:e,why:["Baseline identity did not include analyzer payload."]});if(["dead","isolated","extract","wrapper","passthrough","stale"].includes(r)){let[a,s]=T(i,":");return n({file:a,relatedFiles:a?[a]:[],rootCauseKey:s?`${a}:${s}`:i,label:`${r} finding`,why:s?[`Baseline subject: ${s}.`]:[]})}if(r==="cycle"){let a=i.split(">").filter(Boolean);return n({relatedFiles:a,rootCauseKey:i,label:"cycle finding",why:a.length>0?[`Cycle path: ${a.join(" > ")}.`]:[]})}if(r==="similar"){let a=i.split("|").filter(Boolean);return n({relatedFiles:[],rootCauseKey:i,label:"similarity finding",why:a.length>0?[`Similar symbols: ${a.join(" | ")}.`]:[]})}if(r==="architecture"){let[a,s]=T(i,":");if(a==="forbidden-edge"){let[c,l]=T(s,":"),o=N(c),f=N(l);return n({actionTier:"direct",rootCauseKey:i,label:"architecture boundary violation",why:[`Declared boundary rule rejects ${o} -> ${f}.`],remediation:`Move the dependency behind an allowed boundary, or deliberately update the ${o} dependency rule and baseline.`})}if(a==="cycle"){let c=s.split("|").filter(Boolean).map(N);return n({actionTier:"direct",rootCauseKey:i,label:"forbidden architecture cycle",why:[`requireAcyclic rejects the connected boundary group: ${c.join(", ")}.`],remediation:"Break the boundary cycle, or deliberately revise the acyclicity rule and baseline."})}if(a==="missing-policy-row"){let c=N(s);return n({actionTier:"direct",rootCauseKey:i,label:"incomplete architecture policy",why:[`requireCompletePolicy rejects the missing outgoing dependency row for ${c}.`],remediation:`Declare the allowed outgoing dependencies for ${c}, including an empty row when it must depend on nothing.`})}}if(r==="drift"){let[a,s]=T(i,":"),[c,l]=T(s,":");return n({actionTier:a==="unused-import"?"direct":"signal",file:c,relatedFiles:[...new Set([c,l].filter(Boolean))],rootCauseKey:i,label:`${a||"drift"} finding`,why:[...a?[`Drift kind: ${a}.`]:[],...l?[`Related dependency: ${l}.`]:[]]})}return n({why:["Baseline analyzer prefix is not recognized by this diff-gate version."]})}function We(e){switch(e){case"dead":case"isolated":case"cycle":case"passthrough":case"architecture":return"direct";case"similar":case"extract":case"wrapper":case"stale":return"signal";default:return"signal"}}function Je(e,t){return e==="direct"?`Fix the new ${t} baseline finding, or knowingly accept it via health --write-baseline.`:`Review the new ${t} baseline signal; fix it if it reflects real debt, or knowingly accept it via health --write-baseline.`}function T(e,t){let i=e.indexOf(t);return i<0?[e,""]:[e.slice(0,i),e.slice(i+t.length)]}function N(e){try{return decodeURIComponent(e)}catch{return e}}import{existsSync as xe,readFileSync as Ge,writeFileSync as Ve}from"fs";import{isAbsolute as Ye,join as Xe}from"path";var Ze=25e3,Qe=2500,et=2500;function tt(e){let t=Fe(e);return t.symbols>=Ze||t.documents>=Qe?et:void 0}var it=".scipquery-baseline.json";function q(e){if(e.startsWith("similar:")){let t=e.slice(8).split("|");return t.length!==2?e:`similar:${t.map(M).sort().join("|")}`}if(e.startsWith("duplicate-bodies:")){let t=e.slice(17),i=t.indexOf(":");if(i<0)return e;let r=t.slice(0,i),n=t.slice(i+1).split("|");return n.length<2?e:`duplicate-bodies:${r}:${n.map(M).sort().join("|")}`}return e}function A(e,t){return t&&Ye(t)?t:Xe(e.config.projectRoot,t??it)}function Ee(e,t={}){let{scope:i}=t,r=tt(e),n=[],a=be(e,{scope:i,...v.dead,scanLimit:r});for(let s of a.symbols)x(e,s.relativePath)||G(e,s.symbol,s.relativePath)||s.kind==="dead-code"&&n.push(`dead:${s.relativePath}:${s.shortName}`);for(let s of $e(e,{scope:i,...v.isolated,scanLimit:r}))x(e,s.relativePath)||G(e,s.symbol,s.relativePath)||n.push(`isolated:${s.relativePath}:${s.shortName}`);for(let s of me(e,{scope:i}))s.kind==="real"&&n.push(`cycle:${nt(s.path)}`);for(let s of ve(e,{scope:i,...v.similar,scanLimit:r}))n.push(`similar:${[s.symbolA,s.symbolB].sort().join("|")}`);for(let s of de(e,{scope:i,...v.duplicateBodies,scanLimit:r}))n.push(`duplicate-bodies:${s.hash}:${s.functions.map(c=>c.symbol).sort().join("|")}`);for(let s of Se(e,{scope:i,...v.extract,scanLimit:r}))n.push(`extract:${s.relativePath}:${s.shortName}`);for(let s of Re(e,{scope:i,...v.wrappers,scanLimit:r}))n.push(`wrapper:${s.file}:${s.shortName}`);for(let s of we(e,{scope:i,...v.passthroughs,scanLimit:r}))n.push(`passthrough:${s.file}:${s.shortName}`);for(let s of De(e,{scope:i,...v.stale,scanLimit:r}))n.push(`stale:${s.file}:${s.shortName}`);for(let s of Ce(e,{scope:i,...v.drift,includePatternDeviations:!1,limit:Number.POSITIVE_INFINITY}).results)s.kind!=="architecture-violation"&&n.push(`drift:${s.kind}:${s.file}:${s.dep}`);return n.push(...O(z(e,{scope:i}))),[...new Set(n.map(q))].sort()}function nt(e){if(e.length===0)return"";let t=0;for(let i=1;i<e.length;i++)e[i]<e[t]&&(t=i);return[...e.slice(t),...e.slice(0,t)].join(">")}function ni(e,t={}){let i=Ee(e,{scope:t.scope}),r=A(e,t.path);return Ve(r,JSON.stringify({version:1,findings:i},null,2)+`
|
|
2
|
+
`),{path:r,findingCount:i.length}}function je(e,t={}){let i=A(e,t.path);if(!xe(i))throw new Error(`No baseline found at ${i}. Create one with: scip-query health --write-baseline`);let r=JSON.parse(Ge(i,"utf-8")),n=new Set((r.findings??[]).map(q)),a=Ee(e,{scope:t.scope}),s=new Set(a);return{baselinePath:i,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}function Ie(e,t={}){let i=A(e,t.path);if(!xe(i))throw new Error(`No baseline found at ${i}. Create one with: scip-query health --write-baseline`);let r=JSON.parse(Ge(i,"utf-8")),n=new Set((r.findings??[]).map(q).filter(c=>c.startsWith(I))),a=O(z(e,{scope:t.scope})),s=new Set(a);return{baselinePath:i,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}import{existsSync as rt,mkdirSync as si,readdirSync as ot,readFileSync as st,writeFileSync as ai}from"fs";import{createHash as li}from"crypto";import{join as W}from"path";var E=W(".scipquery","suppressions");function at(e){return W(e,E)}function Ne(e){let t=at(e);if(!rt(t))return{suppressions:[],warnings:[]};let i=[],r=[];for(let n of ot(t).sort()){if(!n.endsWith(".json"))continue;let a=W(t,n),s;try{s=JSON.parse(st(a,"utf-8"))}catch{r.push(`${E}/${n}: malformed JSON \u2014 ignored`);continue}if(typeof s!="object"||s===null||Array.isArray(s)){r.push(`${E}/${n}: not a suppression object \u2014 ignored`);continue}let c=s;if(typeof c.reason!="string"||c.reason.trim()===""){r.push(`${E}/${n}: missing reason \u2014 ignored`);continue}if(!c.id&&!c.check){r.push(`${E}/${n}: needs an id or a check \u2014 ignored`);continue}i.push(c)}return{suppressions:i,warnings:r}}var Bi=["echo","incomplete-migration","co-change-partner","twin-partner","coverage-contract","architecture","doc-reference","unused-params","new-dead","baseline"];function Ki(e,t={}){let i=t.base??"HEAD",{minTogether:r=6,minConfidence:n=.6,maxEchoChecks:a=Number.POSITIVE_INFINITY,maxHelpers:s=Number.POSITIVE_INFINITY,minSimilarity:c=.8,includeBaseline:l=!1,scanLimit:o}=t,f=t.semantic!==!1,p=t.historyMode??"bounded",u=new Set(t.skip??[]),h=ae(e,{base:i}),m=se(e,{base:i,plan:h}),y=m.changedFiles,S=new Set(y),d=new Set(h.changedFileLines),w=new Set([...S,...d]),$=_(e.config.projectRoot,i,H(h,y)),C=Nt(e.config.projectRoot,i,h,$),g={base:i,changedFiles:y,changedSymbols:m.changedSymbols.length,checksRun:[],skipped:[],suppressed:[],findings:[],attributionNotes:m.attributionNotes,rootCauseGroups:[],note:m.summary.note};if(y.length===0)return g;let k=(j,ze)=>{if(u.has(j)){g.skipped.push({check:j,reason:"skipped via --skip"});return}let Oe=g.findings.length,Ue=g.skipped.length,qe=g.checksRun.length;Y(`diff-gate.check.${j}`,ze,()=>({check:j,changedFiles:y.length,changedSymbols:m.changedSymbols.length,findingsAdded:g.findings.length-Oe,skippedAdded:g.skipped.length-Ue,checksRunAdded:g.checksRun.length-qe}))};return k("echo",()=>ut(e,m.changedSymbols,S,C,a,c,o,f,g)),k("incomplete-migration",()=>bt(e,i,h,s,o,f,$,g)),k("co-change-partner",()=>Ct(e,w,r,n,p,g)),k("twin-partner",()=>St(e,m.changedSymbols,S,o,g)),k("coverage-contract",()=>$t(e,w,g)),k("architecture",()=>Mt(e,g)),k("doc-reference",()=>Ft(e,S,d,h.changedRanges,h.renamedFiles,g)),k("unused-params",()=>xt(e,y,g)),k("new-dead",()=>Gt(e,m.changedSymbols,C,g)),l&&k("baseline",()=>Kt(e,g)),dt(g,[...e.config.suppressions??[],...Ne(e.config.projectRoot).suppressions]),g.rootCauseGroups=lt(g.findings),g}function Mi(e){return e.checksRun.length===0&&e.note===oe}function Pi(e){return e.filter(t=>!t.advisory)}function lt(e){let t=new Map;for(let i of e){let r=i.groupKey??`${i.check}:${i.id}`,n=t.get(r);n||(n={groupKey:r,check:i.check,severity:i.severity,actionTier:i.actionTier,sourceAnalyzer:i.sourceAnalyzer,rootCauseKey:i.rootCauseKey,count:0,findingIds:[],files:new Set,relatedFiles:new Set,message:i.message,remediation:i.remediation},t.set(r,n)),n.count+=1,n.findingIds.push(i.id),n.severity=_e(n.severity,i.severity),n.actionTier=He(n.actionTier,i.actionTier),i.file&&n.files.add(i.file);for(let a of i.relatedFiles??[])n.relatedFiles.add(a)}return[...t.values()].map(i=>({...i,files:[...i.files].sort(),relatedFiles:[...i.relatedFiles].sort()})).sort((i,r)=>r.count-i.count||B(r.severity)-B(i.severity)||i.groupKey.localeCompare(r.groupKey))}function _e(e,t){return B(t)>B(e)?t:e}function B(e){return e==="error"?2:e==="warning"?1:0}function He(e,t){return e?t&&Be(t)>Be(e)?t:e:t}function Be(e){return e==="direct"?2:e==="signal"?1:0}function dt(e,t){if(t.length===0||e.findings.length===0)return;let i=[];for(let r of e.findings){let n=t.find(a=>ft(a,r));n?e.suppressed.push({finding:r,suppression:n}):i.push(r)}e.findings=i}function ft(e,t){return!e.reason||e.reason.trim()===""||e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()||e.id&&e.id!==t.id&&!t.legacySuppressionIds?.includes(e.id)||e.check&&e.check!==t.check||e.file&&e.file!==t.file?!1:!!(e.id||e.check)}function D(e,t){e.findings.push({...t,suppressionHint:`scip-query: ignore ${t.check} ${t.id} -- <reason>`})}function ut(e,t,i,r,n,a,s,c,l){l.checksRun.push("echo");for(let o of t.slice(0,n)){if(!P(o.symbol)||r(o))continue;let f=fe(e,o.symbol,{maxLoc:15,scanLimit:s}).filter(d=>!i.has(d.file)).slice(0,5).map(d=>({otherFile:d.file,otherShort:d.shortName,otherSymbol:d.symbol,similarity:1,similarityBasis:"exact-body",sharedEvidence:[`exact normalized body (${d.loc} LOC)`]}));if(f.length>0){let d=b("echo",o.symbol,o.file),w=b("echo",o.symbol,o.file,...f.map(C=>`${C.otherSymbol}|${C.otherFile}`).sort()),$=f[0];D(l,{id:d,legacySuppressionIds:w===d?void 0:[w],groupKey:d,actionTier:"direct",check:"echo",severity:"warning",evidence:"heuristic",confidence:1,file:o.file,symbol:o.symbol,relatedFiles:[...new Set(f.map(C=>C.otherFile))].sort(),sourceAnalyzer:"duplicate-bodies",rootCauseKey:`${o.symbol}:${$.otherSymbol}`,message:Me(o,f),why:Pe(o,f),remediation:Le("direct",o.shortName,$.otherShort)});continue}let p=ke(e,o.symbol,{minSimilarity:a,limit:5,scanLimit:s,semantic:c,sourceCandidateMode:"target-pruned"}),u=[];for(let d of p){let w=d.fileA===o.file?d.fileB:d.fileA,$=d.fileA===o.file?d.shortNameB:d.shortNameA,C=d.fileA===o.file?d.symbolB:d.symbolA;i.has(w)||u.push({otherFile:w,otherShort:$,otherSymbol:C,similarity:d.similarity,similarityBasis:d.similarityBasis??"callees",sharedEvidence:d.sharedCallees})}if(u.length===0)continue;let h=u[0],m=b("echo",o.symbol,o.file,...u.map(d=>`${d.otherSymbol}|${d.otherFile}`).sort()),y=b("echo",o.symbol,o.file),S=ht(o,u);D(l,{id:y,legacySuppressionIds:m===y?void 0:[m],groupKey:y,actionTier:S,check:"echo",severity:"warning",evidence:"heuristic",confidence:h.similarity,file:o.file,symbol:o.symbol,relatedFiles:[...new Set(u.map(d=>d.otherFile))].sort(),message:Me(o,u),why:Pe(o,u),remediation:Le(S,o.shortName,h.otherShort)})}t.length>n&&l.skipped.push({check:"echo",reason:`echo check capped at ${n} of ${t.length} changed symbols`})}function ht(e,t){return t.some(r=>gt(e.symbol,r))?"direct":"signal"}function gt(e,t){if(t.similarityBasis==="exact-body")return!0;if(t.similarityBasis!=="source-tokens"||t.similarity<.98||t.sharedEvidence.length>8)return!1;let i=R(e),r=R(t.otherSymbol);return!i||!r?!1:i===r?!0:yt(t.sharedEvidence)?!1:pt(i,r)}function pt(e,t){let i=Ke(e),r=Ke(t);if(i.length===0||r.length===0)return!1;let n=new Set(r),a=i.filter(s=>n.has(s)).length;return a>=2&&a/Math.min(i.length,r.length)>=.5}function Ke(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(t=>t.toLowerCase()).filter(t=>t.length>=2)}var mt=new Set(["bytes","crypto","hex","num","random","secret","to","token"]);function yt(e){return e.length>=3&&e.every(t=>mt.has(t.toLowerCase()))}function Me(e,t){let i=t[0],r=Math.round(i.similarity*100);return t.length===1?`${e.shortName} (${e.file}) is ${r}% similar to established ${i.otherShort} (${i.otherFile})`:`${e.shortName} (${e.file}) resembles ${t.length} established symbol(s); strongest is ${r}% similar to ${i.otherShort} (${i.otherFile})`}function Pe(e,t){let i=[`${e.shortName} was changed in this diff.`];for(let r of t.slice(0,3))i.push(`${r.otherShort} is outside this diff and scored ${Math.round(r.similarity*100)}% similar by ${r.similarityBasis} evidence.`),i.push(`Shared evidence: ${r.sharedEvidence.slice(0,5).join(", ")||"(none listed)"}.`);return t.length>3&&i.push(`${t.length-3} additional similar match(es) grouped into this finding.`),i}function Le(e,t,i){return e==="direct"?`Extract or reuse the shared behavior with ${i}, or keep the duplicate with a suppression reason.`:`Review whether ${t} is intentionally parallel to the established implementation(s); extract shared behavior only if the product semantics match.`}function bt(e,t,i,r,n,a,s,c){let l=Te(e,{base:t,maxHelpers:r,diffPlan:i,scanLimit:n,semantic:a,baseContentAt:s});if(!l.available){c.skipped.push({check:"incomplete-migration",reason:"no git history"});return}c.checksRun.push("incomplete-migration"),l.note&&c.skipped.push({check:"incomplete-migration",reason:l.note});for(let o of l.findings){let f=o.leftovers.map(d=>`${d.shortName} (${d.file}, ${Math.round(d.containment*100)}% helper / ${Math.round(d.siteCoverage*100)}% site, ${d.migrationScope})`).join(", "),p=o.leftovers.map(d=>`${d.shortName}: ${d.migrationScope} (${d.migrationScopeReasons[0]})`).join("; "),u=[...o.migratedFiles,...o.leftovers.map(d=>d.file)],h=o.leftovers.length===0?void 0:Math.max(...o.leftovers.map(d=>Math.min(d.containment,d.siteCoverage))),m=o.leftovers.some(d=>d.migrationScope==="possible-subtype"),y=b("incomplete-migration",o.helperSymbol,o.helperFile,u.join("|")),S=b("incomplete-migration",o.helperSymbol,o.helperFile);D(c,{id:S,legacySuppressionIds:y===S?void 0:[y],check:"incomplete-migration",severity:"warning",evidence:"heuristic",confidence:h,file:o.helperFile,symbol:o.helperSymbol,relatedFiles:u,message:`new helper ${o.helperShortName} (${o.helperFile}) is wired into ${o.migratedFiles.length} file(s), but ${o.leftovers.length} similar un-migrated site(s) remain: ${f}`,why:[`${o.helperShortName} is new in this diff and already referenced by ${o.migratedFiles.join(", ")}.`,`Helper shape: ${o.helperShape}; ${o.specificHelperCalleeCount}/${o.helperCalleeCount} helper callees are specific enough to score.`,`Unchanged site(s) still contain the helper's callee pattern: ${f}.`,`Migration scope hints: ${p}.`],remediation:m?`Migrate same-scope sites to ${o.helperShortName}; review possible subtype/variant sites before applying the helper.`:`Migrate the remaining sites to ${o.helperShortName}, or confirm they are intentionally different.`})}}function Ct(e,t,i,r,n,a){let s=te(e,{historyMode:n}).directionalCoChangePairsForFiles(t,{minTogether:i,minConfidence:0,maxFilesPerCommit:20});if(!s){a.skipped.push({check:"co-change-partner",reason:"no git history"});return}a.checksRun.push("co-change-partner");let c=new Set,l;for(let o of s){let f=t.has(o.fileA),p=t.has(o.fileB);if(f===p)continue;let u=f?o.fileA:o.fileB,h=f?o.fileB:o.fileA,m=f?o.changesA:o.changesB,y=m>0?o.together/m:0;if(y<r||L(h)||L(u)||!K(`${e.config.projectRoot}/${h}`))continue;let S=`${u}|${h}`;if(c.has(S))continue;c.add(S);let d=b("co-change-partner",u,h,String(o.together)),w=b("co-change-partner",u,h),$=ie(u,h),C=ne({fileA:u,fileB:h,together:o.together,confidence:y,commitScope:o.commitScope,recency:o.recency,subjectContext:o.subjectContext},$,(l??=re(e))(u,h)),g=[u,h].sort().join("|");a.findings.push({id:w,legacySuppressionIds:d===w?void 0:[d],check:"co-change-partner",severity:"warning",evidence:"change-graph",actionTier:"signal",groupKey:`co-change-partner:${g}`,confidence:y,file:u,relatedFiles:[h],sourceAnalyzer:"co-change",rootCauseKey:g,partnerClass:$.partnerClass,partnerClassReasons:$.reasons,commitScope:o.commitScope,recency:o.recency,focusedTogether:o.focusedTogether,broadTogether:o.broadTogether,broadCommitRatio:o.broadCommitRatio,lastTogetherAt:o.lastTogetherAt,recentTogether:o.recentTogether,subjectContext:o.subjectContext,...C?{declaredCouplingSuggestion:C}:{},message:`${u} changed, but ${h} did not \u2014 they change together ${o.together}x (${Math.round(y*100)}% of the time)`,why:[`${u} is in this diff and ${h} is not.`,`Git history shows ${o.together} co-change(s), which is ${Math.round(y*100)}% of changes to the edited side.`,`History context: ${wt(o)}.`,`Subject context: ${kt(o.subjectContext)}.`,...vt(o),`Partner class: ${$.partnerClass} (${$.reasons.join("; ")}).`],remediation:C?`Update ${h} alongside this change, declare the coupling "${C.name}", or confirm the coupling no longer holds.`:`Update ${h} alongside this change, or confirm the coupling no longer holds.`})}}function St(e,t,i,r,n){n.checksRun.push("twin-partner");let a=ue(e,{scanLimit:r}).filter(l=>l.relationship==="divergent"||l.relationship==="identical");if(a.length===0)return;let s=new Map;for(let l of a)for(let o of l.members)s.set(o.symbol,l);let c=new Set;for(let l of t){if(!P(l.symbol))continue;let o=s.get(l.symbol);if(!o)continue;let f=o.members.filter(m=>m.symbol!==l.symbol&&!i.has(m.file));if(f.length===0)continue;let p=[l.symbol,...f.map(m=>m.symbol)].sort().join("|");if(c.has(p))continue;c.add(p);let u=f[0],h=b("twin-partner",l.symbol,l.file,u.symbol);D(n,{id:h,groupKey:`twin-partner:${p}`,check:"twin-partner",severity:"warning",evidence:"heuristic",actionTier:"signal",advisory:!0,confidence:o.relationship==="identical"?1:Math.max(0,1-o.maxDivergence),file:l.file,symbol:l.symbol,relatedFiles:f.map(m=>m.file).sort(),sourceAnalyzer:"twin-drift",rootCauseKey:p,message:`${l.shortName} (${l.file}) changed but its same-name twin ${u.shortName} (${u.file}) did not \u2014 verify the change shouldn't apply to both, or consolidate them.`,why:[`${l.symbol} is in this diff.`,`${u.symbol} shares its (near-)name and is classified '${o.relationship}' with it, but ${u.file} is not in this diff.`,o.relationship==="divergent"?`The two bodies already diverge (~${Math.round(o.maxDivergence*100)}% token difference) \u2014 this diff may widen or narrow that drift.`:"The two bodies were byte-identical before this diff.","Advisory: twin-partner never fails the gate by itself \u2014 see the twin-partner entry in the diff-gate checks table."],remediation:`Update ${u.file} alongside this change, consolidate ${l.shortName}/${u.shortName} into one helper, or confirm the twin should diverge on purpose.`})}}function $t(e,t,i){i.checksRun.push("coverage-contract");let r=e.config.coverageContracts??[];for(let n of r){if(!ge(n,t))continue;let a=he(e,n);if(a.status==="ok")continue;let s=b("coverage-contract",n.name,n.file);D(i,{id:s,groupKey:`coverage-contract:${n.name}`,check:"coverage-contract",severity:a.status==="unavailable"?"warning":"error",evidence:"graph-fact",actionTier:"direct",file:n.file,sourceAnalyzer:"coverage-contracts",rootCauseKey:n.name,message:pe(a),why:[`Contract "${n.name}" declares that ${n.file} (${n.keys.type}) must track ${n.mustEqual.type}.`,a.status==="unavailable"?`The declared side could not be evaluated: ${a.unavailableReason}.`:`Missing: ${a.missing.join(", ")||"none"}. Extra: ${a.extra.join(", ")||"none"}.`,"Either side of this contract changed in this diff."],remediation:a.status==="unavailable"?"Investigate why the declared key set could not be parsed (see the reason above) \u2014 do not treat this as a pass.":`Update ${n.file} so its ${n.keys.type==="object-literal-keys"||n.keys.type==="string-array"?n.keys.identifier:n.keys.marker} matches ${n.mustEqual.type}, or fix the ground-truth source if the declared set is right.`})}}function wt(e){return`${e.commitScope}/${e.recency}; ${e.focusedTogether} focused, ${e.broadTogether} broad-sweep (${Math.round(e.broadCommitRatio*100)}% broad), ${e.recentTogether} recent, last ${Dt(e.lastTogetherAt)}`}function kt(e){let t=e.subjectLabels.length>0?e.subjectLabels.slice(0,5).join(", "):"none inferred",i=e.issueRefs.length>0?e.issueRefs.slice(0,5).join(", "):"none",r=e.sampleSubjects.length>0?e.sampleSubjects.slice(0,3).map(n=>`"${n}"`).join("; "):"none";return`labels ${t}; refs ${i}; samples ${r}; external issue/PR labels ${e.externalIssueLabelStatus}`}function vt(e){let t=[];return e.commitScope==="broad-sweep"&&t.push("Broad-sweep history is weaker than focused co-edits; confirm this is a real coordination contract."),e.recency==="stale"&&t.push("The pair has no co-change in the recent history window; confirm the coupling still holds."),t}function Dt(e){return e<=0?"unknown":new Date(e*1e3).toISOString().slice(0,10)}var J=3;function Ft(e,t,i,r,n,a){a.checksRun.push("doc-reference");let s=F.referenceTargets(e,t,r);if(s.size===0)return;let c=new Set(n.map(o=>o.from)),l=[];for(let o of le(e,s))i.has(o.doc)||ce(e,o.doc)||l.push(Rt(e,o,c));for(let o of Tt(l))D(a,o)}function Rt(e,t,i){let r=t.citedClaims.length>0?t.citedClaims:F.citationContexts(e,t.doc,t.cited),n=F.classifyCitation(r),a=F.hasLineAnchoredCitation(t.citations),s=t.cited.some(p=>i.has(p)||!K(`${e.config.projectRoot}/${p}`)),c=!(a||s),l=t.cited[0]??"",o=b("doc-reference",t.doc,t.cited.join("|")),f=b("doc-reference",t.doc,l);return{id:f,legacySuppressionIds:o===f?void 0:[o],check:"doc-reference",severity:"warning",evidence:"change-graph",actionTier:n.actionTier,groupKey:`doc-reference:${l}`,rootCauseKey:l,confidence:1,file:t.doc,relatedFiles:t.cited,citationKind:n.citationKind,citationKindReasons:n.reasons,citedClaims:r,...c?{advisory:!0}:{},message:`${t.doc} cites ${t.cited.join(", ")} as ${F.citationKindLabel(n.citationKind)} \u2014 changed in this diff, doc untouched`,why:[`${t.cited.join(", ")} changed in this diff.`,`${t.doc} cites the changed file(s) but was not updated in the same diff.`,...n.reasons.map(p=>`Citation kind evidence: ${p}`),c?"Advisory: bare file-mention citation (no line anchor, cited file still present under the same path) \u2014 21.2 calibration found this citation shape low-precision; verify at your leisure.":a?"Blocking: citation includes a line anchor that may now point at the wrong lines.":"Blocking: the cited file was deleted or renamed in this diff \u2014 the citation almost certainly needs an update."],remediation:F.citationRemediation(n.citationKind,t.doc)}}function Tt(e){let t=new Map;for(let r of e){let n=r.rootCauseKey??"",a=t.get(n);a?a.push(r):t.set(n,[r])}let i=[];for(let[r,n]of t)n.length<=J?i.push(...n):i.push(At(r,n));return i}function At(e,t){let i=[...t].sort((f,p)=>(f.file??"").localeCompare(p.file??"")),r=i.slice(0,J).map(f=>({doc:f.file??"",citedClaims:f.citedClaims??[]})),n=i.length-r.length,a=i.every(f=>f.advisory===!0),s=i.reduce((f,p)=>_e(f,p.severity),"info"),c=i.reduce((f,p)=>He(f,p.actionTier),void 0),l=i.map(f=>f.file??"").filter(f=>f.length>0),o=[...new Set(i.flatMap(f=>[f.id,...f.legacySuppressionIds??[]]))];return{id:b("doc-reference","hub-cluster",e),memberFindingIds:o,check:"doc-reference",severity:s,evidence:"change-graph",actionTier:c,groupKey:`doc-reference:${e}`,rootCauseKey:e,confidence:1,file:r[0]?.doc,relatedFiles:[e],citationCount:i.length,citationExemplars:r,suppressedCount:n,...a?{advisory:!0}:{},message:`${e} is cited by ${i.length} doc(s) changed in this diff, doc(s) untouched \u2014 showing ${r.length} example(s), ${n} more damped`,why:[`${e} changed in this diff.`,`${i.length} doc(s) cite it but were not updated in the same diff: ${l.join(", ")}.`,...r.map(f=>`Example \u2014 ${f.doc}: ${f.citedClaims[0]??"(no captured citation text)"}`),`${n} additional doc(s) also cite this file, past the per-hub-file cascade cap (${J}) \u2014 not silently dropped: counted in citationCount/suppressedCount and individually addressable via memberFindingIds.`,a?"Advisory: every citation in this cluster is a bare file-mention (no line anchor, cited file still present).":"Blocking: at least one citation in this cluster is line-anchored or cites a deleted/renamed file."],remediation:`Review the ${r.length} example doc(s) above; ${i.length} total doc(s) cite ${e} the same way \u2014 see citationExemplars and memberFindingIds in --json for the complete list.`}}function xt(e,t,i){i.checksRun.push("unused-params");for(let r of Ae(e,{files:t,limit:50})){let n=b("unused-params",r.symbol,r.file,r.unusedTrailing.join("|")),a=b("unused-params",r.symbol,r.file);D(i,{id:a,legacySuppressionIds:n===a?void 0:[n],check:"unused-params",severity:"warning",evidence:"heuristic",confidence:.85,file:r.file,startLine:r.startLine,endLine:r.endLine,symbol:r.symbol,message:`${r.shortName} (${r.file}) has trailing unused parameter(s): ${r.unusedTrailing.join(", ")}`,why:[`${r.shortName} is in a changed file.`,`The trailing parameter(s) ${r.unusedTrailing.join(", ")} are not referenced in the function body.`],remediation:"Drop the unused trailing parameters and their call-site arguments."})}}function Gt(e,t,i,r){r.checksRun.push("new-dead");let n=new ee(e),a=V(e.config.projectRoot),s=a.length>1;for(let c of t){if(i(c)||c.fanIn>0||n.fileKind(c.file)==="test"||x(e,c.file)||G(e,c.symbol,c.file)||It(c.symbol))continue;let l=b("new-dead",c.symbol,c.file),o=s&&Et(a,c.file)&&jt(e,c.symbol);D(r,{id:l,check:"new-dead",severity:"warning",evidence:o?"heuristic":"graph-fact",confidence:o?.4:.9,file:c.file,symbol:c.symbol,message:o?`${c.shortName} (${c.file}) unconfirmed (cross-package ambiguous-name resolution gap): zero indexed consumers found, but this name is ambiguous project-wide and lives in a workspace package \u2014 verify manually before treating as dead`:`${c.shortName} (${c.file}) was changed but has zero indexed consumers`,why:o?[`${c.shortName} is a changed production symbol in a workspace package.`,"The index, semantic, and source-fallback layers all report zero consumers for this symbol.","Its leaf name is ambiguous project-wide (a same-named definition exists elsewhere), and cross-package consumers reached only through a re-exporting barrel are a known unresolvable shape for this tool \u2014 see docs/plans/2026-07-02-followups.md item 2."]:[`${c.shortName} is a changed production symbol.`,"The index reports zero consumers for this symbol.","The symbol is not in a detected entry surface or configured live root."],remediation:o?"Verify with a direct code search before deleting; this tool cannot confidently resolve this symbol.":"Wire it up, or remove it before it becomes permanent dead code."})}}function Et(e,t){return e.some(i=>t===i.relativeDir||t.startsWith(`${i.relativeDir}/`))}function jt(e,t){let i=R(t);return i?(Q(e).get(i)?.length??0)>1:!1}function It(e){if(Z(e)!=="type")return!1;let t=R(e);return t.startsWith("_Assert")||t.startsWith("Assert")}function Nt(e,t,i,r){let n=new Map(i.renamedFiles.map(s=>[s.to,s.from])),a=r??_(e,t,H(i));return s=>{let c=n.get(s.file)??s.file,l=R(s.symbol);if(!l)return!1;let o=a(c);return o!==null&&Bt(o,l)}}function Bt(e,t){return new RegExp(`\\b${X(t)}\\b`).test(e)}function Kt(e,t){if(!K(A(e))){t.skipped.push({check:"baseline",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}t.checksRun.push("baseline");let i=je(e);for(let r of i.newFindings.filter(n=>!n.startsWith(I))){let n=U(r),a=b("baseline",r);D(t,{id:a,groupKey:`baseline:${n.sourceAnalyzer}:${n.rootCauseKey}`,check:"baseline",severity:"error",evidence:"baseline",actionTier:n.actionTier,confidence:1,file:n.file,relatedFiles:n.relatedFiles.length>0?n.relatedFiles:void 0,sourceAnalyzer:n.sourceAnalyzer,rootCauseKey:n.rootCauseKey,message:`new ${n.label} vs committed baseline: ${r}`,why:["A committed health baseline exists.","The current health result contains a finding not present in that baseline.",`Underlying analyzer: ${n.sourceAnalyzer}.`,`Inherited action tier: ${n.actionTier}.`,`Root cause key: ${n.rootCauseKey}.`,...n.why],remediation:n.remediation})}}function Mt(e,t){if(!ye(e.config.architecture)){t.skipped.push({check:"architecture",reason:"no closed architecture dependency rows, requireCompletePolicy rule, or requireAcyclic rule configured"});return}if(!K(A(e))){t.skipped.push({check:"architecture",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}t.checksRun.push("architecture");let i=Ie(e);for(let r of i.newFindings){let n=U(r),a=b("architecture",r);D(t,{id:a,groupKey:`architecture:${n.rootCauseKey}`,check:"architecture",severity:"error",evidence:"baseline",actionTier:"direct",confidence:1,sourceAnalyzer:"architecture",rootCauseKey:n.rootCauseKey,message:`new ${n.label} vs committed baseline: ${r}`,why:["The project declares an enforceable architecture rule.","The current boundary graph contains a violation not present in the committed baseline.",...n.why],remediation:n.remediation})}}function b(e,...t){return`SQ${ct("sha256").update([e,...t].join("\0")).digest("hex").slice(0,12).toUpperCase()}`}export{Ee as a,ni as b,je as c,Bi as d,Ki as e,Mi as f,Pi as g,Nt as h};
|
|
3
|
+
//# sourceMappingURL=chunk-KC2IFAAU.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as O}from"./chunk-P5XHIJHI.js";import{d as P,v as E,x as M}from"./chunk-
|
|
1
|
+
import{a as O}from"./chunk-P5XHIJHI.js";import{d as P,v as E,x as M}from"./chunk-FC5K7T35.js";import{execFileSync as U}from"child_process";var j=2e3,S=50,J=64,Y=8,V=3,W=2160*60*60,X=/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i,Z=3,Q=/#\d+|\b[A-Z][A-Z0-9]+-\d+\b/g,q=/^([a-z][a-z0-9-]+)(?:\([^)]+\))?!?:/i;function tt(t){let e=P(t,{clearGroups:["whole-project"]});return(i,n,r)=>{let o=r??H(i.config.projectRoot);if(!o)return null;let s=e.has(i)?e.get(i,()=>({head:"",value:null})):null;return s&&s.head===o?s.value:(e.invalidate(i),e.get(i,()=>({head:o,value:n(i.config.projectRoot,o)})).value)}}function F(t){let e=P(t,{clearGroups:["whole-project"]});return(i,n,r,o)=>{let s=o??H(i.config.projectRoot);if(!s)return null;let c=e.has(i)?e.get(i,()=>({head:"",values:new Map})):null;(!c||c.head!==s)&&e.invalidate(i);let l=e.get(i,()=>({head:s,values:new Map}));if(l.values.has(n))return l.values.get(n)??null;let d=r(i.config.projectRoot,s);return l.values.set(n,d),d}}var et=F("git-commit-history");function nt(t,e={}){let i=e.historyMode??"bounded",n=e.head;return{capability:r=>it(t,r,n),commitHistory:()=>x(t,i,n),fileChurn:()=>st(t,i,n),changeAmplification:()=>at(t,i,n),trackedFiles:()=>lt(t,n),fileAddRecords:()=>dt(t,i,n),coChangePairs:(r={})=>bt(t,r,i,n),coChangePairsForFiles:(r,o={})=>L(t,r,o,i,n),directionalCoChangePairsForFiles:(r,o={})=>yt(t,r,o,i,n)}}function x(t,e="bounded",i){return et(t,y(e),(n,r)=>rt(n,r,e),i)}function it(t,e,i){let n=i??H(t.config.projectRoot);return n?{slot:e,available:!0,head:n}:{slot:e,available:!1,head:null,reason:"git history is unavailable for this project"}}function H(t){try{return C(t,["rev-parse","HEAD"]).trim()||null}catch{return null}}function C(t,e){return U("git",["-C",t,...e],{encoding:"utf-8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"]})}function rt(t,e,i){let n;try{n=C(t,["log","--no-merges","--name-only",...R(i),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}return{head:e,...w(n,S)}}function ot(t){return X.test(t.subject)}function st(t,e,i){let n=x(t,e,i);if(!n)return null;let r=new Map;for(let o of n.commits){let s=ot(o);for(let c of o.files){let l=r.get(c)??{changes:0,fixChanges:0,lastChangedAt:0};l.changes+=1,s&&(l.fixChanges+=1),o.timestamp>l.lastChangedAt&&(l.lastChangedAt=o.timestamp),r.set(c,l)}}return r}function at(t,e,i){let n=x(t,e,i);if(!n||n.commits.length===0)return null;let r=n.commits.map(o=>o.files.length).filter(o=>o>0).sort((o,s)=>o-s);return r.length===0?null:{medianFilesPerCommit:_(r,.5),p90FilesPerCommit:_(r,.9),commitsAnalyzed:r.length}}function _(t,e){let i=Math.min(t.length-1,Math.floor(t.length*e));return t[i]}var ct=tt("git-tracked-files");function lt(t,e){return ct(t,i=>{try{let n=C(i,["ls-files"]);return new Set(n.split(`
|
|
2
2
|
`).map(r=>r.trim()).filter(r=>r!==""))}catch{return null}},e)}var ut=F("git-file-adds"),D="__git__/file-adds",k=E({kind:"git-file-adds",invalidation:M("git-file-adds"),serialize:gt,deserialize:ft});function Ot(t){return nt(t).fileAddRecords()}function dt(t,e,i){let n=y(e);return ut(t,n,(r,o)=>mt(t,r,o,e),i)}function mt(t,e,i,n){let r=k.read(t,I(n),i);if(r)return r;let o=ht(e,n);return o&&k.write(t,I(n),i,o),o}function gt(t){return JSON.stringify([...t.entries()])}function ft(t){if(!t)return null;try{let e=JSON.parse(t);if(!Array.isArray(e))return null;let i=new Map;for(let n of e){if(!Array.isArray(n)||n.length!==2||typeof n[0]!="string")return null;let r=n[1];if(!r||typeof r.commitsAgo!="number"||!Number.isFinite(r.commitsAgo)||typeof r.addedAt!="number"||!Number.isFinite(r.addedAt))return null;i.set(n[0],{commitsAgo:r.commitsAgo,addedAt:r.addedAt})}return i}catch{return null}}function ht(t,e){let i;try{i=C(t,["log","--no-merges","--find-renames","--name-status",...R(e),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}let n=new Map,r=new Map,o=-1;for(let s of i.split("")){if(s.trim()==="")continue;o+=1;let c=s.indexOf(`
|
|
3
3
|
`),l=c>=0?s.slice(0,c):s,[,d]=l.split("\0"),f=Number(d)||0;if(!(c<0))for(let u of s.slice(c+1).split(`
|
|
4
4
|
`)){let a=pt(u);if(!a)continue;if(a.status==="R"&&a.from&&a.to){let p=r.get(a.to)??new Set([a.to]);r.set(a.from,p);continue}if(a.status!=="A"||!a.to)continue;let m={commitsAgo:o,addedAt:f};n.set(a.to,m);for(let p of r.get(a.to)??[])n.set(p,m)}}return n}function pt(t){let e=t.trim().split(" "),i=e[0]??"";if(!i)return null;let n=i[0]??"";if(n==="R"){let o=e[1],s=e[2];return o&&s?{status:n,from:o,to:s}:null}let r=e[1];return r?{status:n,to:r}:null}var z=F("git-co-change-pairs"),Ct=F("git-directional-co-change-pairs");function bt(t,e,i,n){let r=`all\0${y(i)}\0${T(e)}`,o=z(t,r,()=>{let s=x(t,i,n);return s?G(s,e):null},n);return o&&[...o]}function L(t,e,i,n,r){if(e.size===0)return[];let o=`files\0${y(n)}\0${N(e)}\0${T(i)}`,s=z(t,o,()=>{let c=x(t,n,r);return c?G(c,i,e):null},r);return s&&[...s]}function yt(t,e,i,n,r){if(e.size===0)return[];let o=i.maxFilesPerCommit??S;if(e.size>J)return L(t,e,i,n,r);let s=`directional\0${y(n)}\0${N(e)}\0${T({...i,maxFilesPerCommit:o})}`,c=Ct(t,s,(l,d)=>{let f=At(l,d,e,o,n);return f?G(f,i,e):null},r);return c&&[...c]}function T(t){let e=t.minTogether??4,i=t.minConfidence??.6,n=t.maxFilesPerCommit??S;return`${e}\0${i}\0${n}`}function N(t){return[...t].sort().join("\0")}function G(t,e,i){let{minTogether:n=4,minConfidence:r=.6,maxFilesPerCommit:o=S}=e,s=new Map,c=new Map,l=t.newestAnalyzedAt??0;for(let u of t.commits){let a=[...new Set(u.files)].sort();if(a.length>o)continue;t.newestAnalyzedAt===void 0&&u.timestamp>l&&(l=u.timestamp);let m=Ft(a),p=i===void 0||a.some(g=>i.has(g));for(let g of a)s.set(g,(s.get(g)??0)+1);if(p)for(let g=0;g<a.length;g++)for(let b=g+1;b<a.length;b++){if(i&&!i.has(a[g])&&!i.has(a[b]))continue;let A=`${a[g]}\0${a[b]}`,h=c.get(A)??{together:0,focusedTogether:0,broadTogether:0,lastTogetherAt:0,timestamps:[],subjects:[]};h.together+=1,m?h.broadTogether+=1:h.focusedTogether+=1,u.timestamp>h.lastTogetherAt&&(h.lastTogetherAt=u.timestamp),h.timestamps.push(u.timestamp),h.subjects.push(u.subject),c.set(A,h)}}let d=[],f=l-W;for(let[u,a]of c){let m=a.together;if(m<n)continue;let[p,g]=u.split("\0"),b=s.get(p)??m,A=s.get(g)??m,h=Math.max(m/b,m/A);if(h<r)continue;let $=a.broadTogether/m,v=a.timestamps.filter(K=>K>=f).length;d.push({fileA:p,fileB:g,together:m,confidence:h,changesA:b,changesB:A,focusedTogether:a.focusedTogether,broadTogether:a.broadTogether,broadCommitRatio:$,lastTogetherAt:a.lastTogetherAt,recentTogether:v,commitScope:Pt(a.broadTogether,m),recency:v>0?"recent":"stale",subjectContext:Ht(a.subjects)})}return d.sort((u,a)=>a.together-u.together||a.confidence-u.confidence||u.fileA.localeCompare(a.fileA)),d}function At(t,e,i,n,r){let o;try{o=xt(t,r)}catch{return null}if(o.length===0)return{head:e,commits:[],skippedBulkCommits:0,newestAnalyzedAt:0};let s;try{s=C(t,["log","--no-merges","--format=%H",...R(r),"--",...[...i].sort()])}catch{return null}let c=new Set(o.map(a=>a.hash)),l=s.split(`
|
|
@@ -6,4 +6,4 @@ import{a as O}from"./chunk-P5XHIJHI.js";import{d as P,v as E,x as M}from"./chunk
|
|
|
6
6
|
`).map(n=>n.trim()).filter(n=>n!=="").map(n=>{let[r,o]=n.split("\0");return{hash:r??"",timestamp:Number(o)||0}}).filter(n=>n.hash!=="")}function R(t){return t==="full"?[]:["-n",String(B())]}function B(){return O(process.env.SCIP_QUERY_GIT_HISTORY_MAX_COMMITS)??j}function y(t){return t==="full"?"full":`bounded:${B()}`}function I(t){let e=y(t);return e===`bounded:${j}`?D:`${D}:${e}`}function St(t,e,i){for(let r=0;r<e.length;r+=20){let o=e.slice(r,r+20),s;try{s=C(t,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...o.map(l=>l.hash)])}catch{return e[0]?.timestamp??0}let c=w(s,i);if(c.commits.length>0)return c.commits[0].timestamp}return 0}function w(t,e){let i=[],n=0;for(let r of t.split("")){if(r.trim()==="")continue;let o=r.indexOf(`
|
|
7
7
|
`),s=o>=0?r.slice(0,o):r,[c,l,d]=s.split("\0");if(!c||!l)continue;let f=o>=0?r.slice(o+1).split(`
|
|
8
8
|
`).map(u=>u.trim()).filter(u=>u!==""):[];if(f.length>e){n+=1;continue}i.push({hash:c,timestamp:Number(l)||0,subject:d??"",files:f})}return{commits:i,skippedBulkCommits:n}}function Ft(t){return t.length>=Y?!0:Rt(t).size>=V}function Rt(t){let e=new Set;for(let i of t){let n=i.indexOf("/");e.add(n>=0?i.slice(0,n):".")}return e}function Pt(t,e){return t===0?"focused":t/e>=.5?"broad-sweep":"mixed"}function Ht(t){let e=new Set,i=[],n=[];for(let r of t){!n.includes(r)&&n.length<Z&&n.push(r);for(let o of Tt(r))e.add(o);for(let o of r.match(Q)??[])i.includes(o)||i.push(o)}return{subjectLabels:[...e].sort(),issueRefs:i,sampleSubjects:n,externalIssueLabelStatus:"unavailable"}}function Tt(t){let e=new Set,i=q.exec(t)?.[1]?.toLowerCase();return i&&e.add(Gt(i)),/\b(?:feat|feature)\b/i.test(t)&&e.add("feature"),/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i.test(t)&&e.add("fix"),/\b(?:docs?|documentation|guide|readme)\b/i.test(t)&&e.add("docs"),/\brefactor(?:ing|ed)?\b/i.test(t)&&e.add("refactor"),/\btests?\b/i.test(t)&&e.add("test"),/\b(?:release|version|v\d+\.\d+)\b/i.test(t)&&e.add("release"),/\bchore\b/i.test(t)&&e.add("chore"),/\bbuild\b/i.test(t)&&e.add("build"),/\bci\b/i.test(t)&&e.add("ci"),/\bperf(?:ormance)?\b/i.test(t)&&e.add("perf"),[...e]}function Gt(t){return t==="feat"?"feature":t}export{nt as a,C as b,Ot as c};
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-KMOMNTB4.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as d}from"./chunk-7TJJY2C3.js";import{b as g}from"./chunk-B75HZHUP.js";import{a as p,c as u}from"./chunk-EMIIOOTM.js";import{n as b}from"./chunk-DZXFZAZO.js";import{d as f}from"./chunk-AYRHVJXW.js";function R(i,t={}){let{limit:l=20,scope:a,minFanIn:s=2,minFanOut:m=2,scanLimit:o}=t,r=new d(i);return g(r.productionCallableDefinitions({scope:a,requireCallableSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof o=="number"&&o>0}),o).map(e=>h(i,e,t.semantic!==!1)).filter(e=>e.fanIn>=s&&e.fanOut>=m).sort((e,y)=>y.score-e.score||y.fanIn-e.fanIn).slice(0,l)}function h(i,t,l){let a=[...new Set(u(i,t,{limit:500,semantic:l,semanticEvidence:b}).map(n=>n.file))].sort(),s=new Map;for(let n of p(i,t,{limit:500,semantic:l,semanticEvidence:b})){if(n.file===t.relativePath)continue;let e=`${n.symbol}|${n.file}`;s.has(e)||s.set(e,{symbol:n.symbol,shortName:f(n.symbol),file:n.file})}let m=[...s.values()].sort((n,e)=>n.file.localeCompare(e.file)||n.symbol.localeCompare(e.symbol)),o=a.length,r=m.length,c=o*r;return{symbol:t.symbol,shortName:f(t.symbol),fanIn:o,fanOut:r,callerFiles:a,externalCallees:m,score:c,definedIn:t.relativePath,actionTier:"signal",riskKind:"coordination-hotspot",evidenceReasons:[`${o} 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{R as a};
|
|
2
|
+
//# sourceMappingURL=chunk-KMUFGAIK.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as d}from"./chunk-
|
|
1
|
+
import{c as d}from"./chunk-EMIIOOTM.js";import{n as f}from"./chunk-DZXFZAZO.js";import{d as r,t as m}from"./chunk-AYRHVJXW.js";function g(o,t={}){let{limit:n=30,scope:e}=t,s=e?"AND def_d.relative_path LIKE ?":"",c=e?[`%${e}%`]:[],l=o.all(`SELECT
|
|
2
2
|
gs.symbol,
|
|
3
3
|
COUNT(*) AS ref_count,
|
|
4
4
|
COUNT(DISTINCT ref_d.id) AS file_count,
|
|
@@ -23,4 +23,4 @@ import{c as d}from"./chunk-F334Z5UA.js";import{n as f}from"./chunk-UVMME4FI.js";
|
|
|
23
23
|
GROUP BY gs.id
|
|
24
24
|
ORDER BY ref_count DESC
|
|
25
25
|
LIMIT ?`,...c,n).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 l.length>0?l:u(o,e,n)}function u(o,t,n){return m(o,{scope:t}).filter(e=>!o.isIgnored(e.relativePath)).map(e=>a(o,e)).filter(e=>e.refCount>0).sort((e,s)=>s.refCount-e.refCount||s.fileCount-e.fileCount).slice(0,n)}function a(o,t){let e=d(o,t,{limit:500,semanticEvidence:f}).filter(s=>s.file!==t.relativePath);return{symbol:t.symbol,shortName:r(t.symbol),refCount:e.length,fileCount:new Set(e.map(s=>s.file)).size,definedIn:t.relativePath}}export{g as a};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-LF5CIKWZ.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{execFileSync as k,spawnSync as H}from"child_process";import{platform as C}from"os";var y=C()==="win32";function j(t){let e=y?"where":"which";try{return k(e,[t],{stdio:"pipe"}),!0}catch{return!1}}var R=/\.(?:c|m)?js$/i,b=/\.(?:exe|com)$/i;function z(t,e){return R.test(t)?{binary:process.execPath,args:[t,...e]}:{binary:t,args:[...e]}}function w(t,e){return k(t,e,{stdio:["ignore","pipe","ignore"],encoding:"utf8"})}function F(t,e={}){let r=e.isWindows??y,i=e.lookup??w,n;try{n=i(r?"where":"which",[t])}catch{return null}let o=n.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);return r?o.find(s=>b.test(s))??null:o[0]??null}import{spawnSync as v}from"child_process";import{createHash as W}from"crypto";import{existsSync as E,lstatSync as D,realpathSync as I}from"fs";import{dirname as O,isAbsolute as S,join as A,resolve as c}from"path";var p={run(t,e){let r=h(t,e);return r.kind==="success"?r.output:void 0},runResult:h},T=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],G=/^[0-9a-f]{40,64}$/;function q(t,e=p){let r=e.runResult(t,T);if(r.kind==="success"){let i=_(r.output);if(i)return N(i,e)}return P(t,e)}function _(t){let e=t.split(`
|
|
2
2
|
`).map(l=>l.trim());if(e.length!==5)return;let[r,i,n,o,s]=e;if(!r||!i||!n||!o||!s||!G.test(o)||!G.test(s))return;let d=u(r);return{root:d,gitDir:u(a(d,i)),commonDir:u(a(d,n)),headCommit:o,treeOid:s}}function N(t,e){let r=e.run(t.root,["status","--porcelain=v1","-z","--untracked-files=all"]);return r===void 0?void 0:{...x(t.root,t.gitDir),commonDir:t.commonDir,repositoryId:g("repository",t.commonDir),headCommit:t.headCommit,treeOid:t.treeOid,clean:r.length===0}}function P(t,e){let r=B(t,e);if(r.kind!=="worktree")return;let i=r.identity,n=i.projectRoot,o=e.run(n,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=u(a(n,o)),d=f(e.run(n,["rev-parse","--verify","HEAD"])),l=f(e.run(n,["rev-parse","--verify","HEAD^{tree}"])),m=e.run(n,["status","--porcelain=v1","-z","--untracked-files=all"]);if(m!==void 0)return{...i,commonDir:s,repositoryId:g("repository",s),headCommit:d,treeOid:l,clean:m.length===0}}function B(t,e=p){let r=e.runResult(t,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let i=r.output.trim();if(!i)return{kind:"error",message:"Git returned an empty worktree root."};let n=u(i),o=e.run(n,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=u(a(n,o));return{kind:"worktree",identity:x(n,s)}}function x(t,e){return{projectRoot:t,gitDir:e,worktreeId:g("worktree",`${t}\0${e}`)}}function Q(t,e,r=p){return f(r.run(t,e))}function a(t,e){return S(e)?e:c(t,e)}function u(t){try{return I(t)}catch{return c(t)}}function g(t,e){return W("sha256").update(`${t}\0${e}`).digest("hex").slice(0,24)}function f(t){return t?.trim()||void 0}function h(t,e){let r=v("git",["-C",t,...e],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"]});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let n=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(n)||o==="ENOENT"&&E(c(t)))&&!M(t)?{kind:"not-repository"}:{kind:"error",message:n}}function M(t){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let e=c(t);for(;;){try{return D(A(e,".git")),!0}catch(i){let n=i.code;if(n!=="ENOENT"&&n!=="ENOTDIR")return!0}let r=O(e);if(r===e)return!1;e=r}}export{j as a,z as b,F as c,q as d,Q as e,a as f,u as g};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-LM72NQ7T.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as f}from"./chunk-7TJJY2C3.js";import{a as L}from"./chunk-HFBNIIZX.js";import{d as i,e as b,f as u,l as c}from"./chunk-AYRHVJXW.js";import{f as l}from"./chunk-GAE7WCBK.js";import{B as a}from"./chunk-WAU7HVDI.js";function S(o,s){let t=L(o,s);if(!t)return[];let e=new f(o).definitionsForFile(t.relativePath).filter(r=>r.symbol!==t.symbol).filter(r=>c(t.symbol,r.symbol)).sort((r,m)=>r.startLine-m.startLine||r.endLine-m.endLine).map(r=>({symbol:r.symbol,shortName:i(r.symbol),startLine:r.startLine,endLine:r.endLine,kind:u(r.symbol)??"unknown"}));return a(t.relativePath)!=="clojure"?e:d(e,y(o,t))}function y(o,s){let t=b(s.symbol);if(!t)return[];let n=i(s.symbol);return(l(o,s.relativePath)?.clojureMembers??[]).filter(e=>e.ownerName===t).map(e=>({symbol:`${s.symbol}${e.memberName}().`,shortName:`${n}:${e.memberName}()`,startLine:e.startLine,endLine:e.endLine,kind:e.memberKind}))}function d(o,s){let t=new Map;for(let n of[...o,...s])t.set(`${n.shortName}:${n.startLine}:${n.endLine}`,n);return[...t.values()].sort((n,e)=>n.startLine-e.startLine||n.endLine-e.endLine)}export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-LQUDSHLB.js.map
|
|
@@ -64,4 +64,4 @@ Thumbs.db
|
|
|
64
64
|
${n}
|
|
65
65
|
${o}
|
|
66
66
|
ORDER BY relative_path`,...i).map(a=>a.relative_path),s=t.extensions?r.filter(a=>t.extensions.some(c=>a.toLowerCase().endsWith(c.toLowerCase()))):r;return t.includeIgnored===!1?s.filter(a=>!e.isIgnored(a)):s}export{V as a,ce as b,le as c,R as d,B as e,ye as f,d as g,ke as h,ve as i,De as j,ae as k,we as l,Ce as m};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-MP43RX4O.js.map
|
|
@@ -4,4 +4,4 @@ import d from"process";import{existsSync as J,readFileSync as Re}from"fs";import
|
|
|
4
4
|
\r
|
|
5
5
|
${e}`}function oe(t){let e=JSON.parse(t);if(!e||typeof e!="object")throw new Error("rust-analyzer LSP response was not a JSON object");return e}function ae(t,e){return`rust-analyzer LSP transport closed${e?` by ${e}`:t===null?"":` with code ${t}`}`}async function j(t,e,r,n=Date.now){let i=r-n();if(i<=0)throw new l("rust-analyzer readiness deadline expired before quiescence");try{let s=await t.waitForQuiescence(e,i);if(w(r,n,"during quiescence"),s.health==="error")throw new l("rust-analyzer reported error health before reaching readiness");if(!s.quiescent)throw new l("rust-analyzer did not report quiescence before reaching readiness");return s}catch(s){throw s instanceof l?s:new l(s instanceof Error?s.message:String(s))}}async function Ge(t,e,r,n,i,s=Date.now,u=x){let a=await j(t,e,n,s);if(r===0)return a;let c=t.serverStatusSnapshot();if(!c)throw new l("rust-analyzer status is unavailable after initial document open");return await ue(t,c,r,n,i,s,u)??a}async function ue(t,e,r,n,i,s=Date.now,u=x){if(r===0)return null;if(!e)throw new l("rust-analyzer status is unavailable before document open");E(e.status,"before document open");try{await t.readinessBarrier({deadlineMs:n}),w(n,s,"during post-open synchronization")}catch(f){throw f instanceof l?f:new l(f instanceof Error?f.message:String(f))}let a=t.serverStatusSnapshot();if(!a||a.generation<e.generation)throw new l("rust-analyzer status is unavailable after document open");let c;return a.generation===e.generation?(E(a.status,"after document open"),c=a.status):c=await j(t,e.generation,n,s),await P(i,n,s,u),c}async function Qe(t,e,r,n=Date.now){let i=R(e,r,n);await t(i.timeoutMs),w(r,n,"during diagnostics")}async function P(t,e,r=Date.now,n=x){if(t<=0)return;if(R(t,e,r).deadlineLimited)throw new l("rust-analyzer readiness deadline cannot accommodate delay");await n(t),w(e,r,"during delay")}async function Ke(t,e){try{return await t()}catch(r){throw r instanceof l&&await e(),r}}function Ve(t){return t instanceof l?{ok:!1,error:t.message}:null}function w(t,e,r){if(t-e()<=0)throw new l(`rust-analyzer readiness deadline expired ${r}`)}function E(t,e){if(t.health==="error")throw new l(`rust-analyzer reported error health ${e}`);if(!t.quiescent)throw new l(`rust-analyzer did not report quiescence ${e}`)}function x(t){return new Promise(e=>setTimeout(e,t))}import{existsSync as le,readFileSync as ce}from"fs";import{relative as fe,resolve as H,sep as de}from"path";import{fileURLToPath as pe,pathToFileURL as me}from"url";function b(t,e){return me(H(t,e)).href}function C(t,e){let r=pe(e);return fe(t,r).split(de).join("/")}function S(t,e,r){return{textDocument:{uri:b(t,e.relativePath)},position:ye(t,e),context:{includeDeclaration:r}}}function ye(t,e){let r={line:e.startLine,character:e.startChar??0},n=H(t,e.relativePath);if(!le(n))return r;try{return he(ce(n,"utf8"),e,r)}catch{return r}}function he(t,e,r={line:e.startLine,character:e.startChar??0}){let n=t.split(/\r?\n/),i=n[e.startLine];if(i===void 0||e.leaf.length===0)return r;let s=Math.max(0,Math.min(r.character,i.length)),u=i.indexOf(e.leaf,s);if(u>=0)return{line:e.startLine,character:A(u,e.leaf)};let a=i.indexOf(e.leaf);if(a>=0)return{line:e.startLine,character:A(a,e.leaf)};let c=ge(n,e.startLine,e.leaf);return c||r}function A(t,e){return t+Math.max(0,e.length-2)}function ge(t,e,r){for(let n of[-1,1,-2,2]){let i=e+n;if(i<0||i>=t.length)continue;let s=t[i].indexOf(r);if(s>=0)return{line:i,character:A(s,r)}}return null}function F(t,e){return e.map(r=>({file:C(t,r.uri),line:r.range.start.line,column:r.range.start.character}))}function $(t){let e=new Map;for(let r of t)e.set(`${r.file}\0${r.line}\0${r.column}`,r);return[...e.values()].sort((r,n)=>{let i=r.file.localeCompare(n.file);return i!==0?i:r.line!==n.line?r.line-n.line:r.column-n.column})}async function ve(t){let e=t.includeReferences!==!1,r=t.includeCallees===!0,n=t.includeSignatures===!0,i={timeoutMs:t.requestTimeoutMs},s=Le(t),u=B(t),a=U(t),c=N(t),f=ke(t.projectRoot,s),y=Me(t.projectRoot,f),k=De(f),p=new g(W(t.rustAnalyzerBinary,y),{requestTimeoutMs:t.requestTimeoutMs,configuration:k});try{let L=await p.initialize({processId:d.pid,rootUri:b(y,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:k});if(e&&!L.capabilities.referencesProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/references support.",references:u.map(o=>[o.symbolId,[]]),...r?{callees:a.map(o=>[o.symbolId,[]])}:{}};if(r&&!L.capabilities.callHierarchyProvider)return{available:!1,reason:"rust-analyzer initialized without call hierarchy support.",references:u.map(o=>[o.symbolId,[]]),callees:a.map(o=>[o.symbolId,[]]),...n?{signatures:c.map(o=>[o.symbolId,null])}:{}};if(n&&!L.capabilities.hoverProvider)return{available:!1,reason:"rust-analyzer initialized without hover support.",references:u.map(o=>[o.symbolId,[]]),...r?{callees:a.map(o=>[o.symbolId,[]])}:{},signatures:c.map(o=>[o.symbolId,null])};let V=Ie(p,t.projectRoot,s);await Oe(p,V,t.diagnosticsTimeoutMs??1e4),await K(t.settleDelayMs??5e3);let I=e?await T(u,t.concurrency??8,async o=>{let O=await _(p,S(t.projectRoot,o,!1),{requestTimeoutMs:t.requestTimeoutMs,retryTimeoutMs:t.referenceRetryTimeoutMs});return{symbolId:o.symbolId,references:$(F(t.projectRoot,O.locations)),complete:O.complete}}):u.map(o=>({symbolId:o.symbolId,references:[],complete:!0})),X=r?await T(a,t.concurrency??8,async o=>({symbolId:o.symbolId,callees:await We(p,t.projectRoot,o,i)})):[],Y=n?await T(c,t.concurrency??8,async o=>({symbolId:o.symbolId,signature:await ze(p,t.projectRoot,o,i)})):[];return{available:!0,references:I.filter(o=>o.complete).map(o=>[o.symbolId,o.references]),incompleteReferenceSymbolIds:I.filter(o=>!o.complete).map(o=>o.symbolId),...r?{callees:X.map(o=>[o.symbolId,o.callees])}:{},...n?{signatures:Y.map(o=>[o.symbolId,o.signature])}:{}}}finally{await p.shutdown().catch(()=>{})}}function B(t){return t.referenceDefinitions??t.definitions}function U(t){return t.calleeDefinitions??t.definitions}function N(t){return t.signatureDefinitions??t.definitions}function Le(t){return[...t.includeReferences!==!1?B(t):[],...t.includeCallees===!0?U(t):[],...t.includeSignatures===!0?N(t):[]]}async function ze(t,e,r,n={}){let i=S(e,r,!1),s=await Pe(t,{textDocument:i.textDocument,position:i.position},n);return xe(s)}async function Pe(t,e,r={}){try{return await t.hover(e,r)}catch(n){if(m(n),!(n instanceof Error?n.message:String(n)).includes("content modified"))return null;await Q(r.deadlineMs);try{return await t.hover(e,r)}catch(s){return m(s),null}}}function xe(t){if(!t)return null;let e=Ae(t.contents),r=/```(?:rust)?\s*([\s\S]*?)```/i.exec(e),n=r?r[1]:e;for(let i of n.split(/\r?\n/)){let s=i.replace(/^`+|`+$/g,"").trim();if(s&&Te(s))return s}return null}function Ae(t){return typeof t=="string"?t:Array.isArray(t)?t.map(Ce).join(`
|
|
6
6
|
`):"value"in t?t.value:""}function Ce(t){return typeof t=="string"?t:t.value}function Te(t){return/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?(?:const\s+)?(?:unsafe\s+)?(?:extern\s+(?:"[^"]+"\s+)?)?(?:fn|struct|enum|trait|type|const|static|mod)\b/.test(t)}function De(t){return{...t.length>0?{linkedProjects:t}:{},references:{excludeImports:!1,excludeTests:!1}}}function Me(t,e){return e.length===1?D(e[0]):v(t)}function ke(t,e){let r=v(t),n=[],i=new Set;for(let s of e){let u=D(v(r,s.relativePath));for(;$e(r,u);){let a=we(u,"Cargo.toml");if(J(a)){i.has(a)||(i.add(a),n.push(a));break}let c=D(u);if(c===u)break;u=c}}return n}function Ie(t,e,r){let n=new Set,i=[];for(let s of r){if(n.has(s.relativePath))continue;n.add(s.relativePath);let u=v(e,s.relativePath);if(!J(u))continue;let a=b(e,s.relativePath);t.didOpenTextDocument({uri:a,languageId:"rust",version:1,text:Re(u,"utf8")}),i.push(a)}return i}async function Oe(t,e,r){await Promise.all(e.map(n=>t.waitForDiagnostics(n,r).catch(()=>!1)))}async function lt(t,e){return(await _(t,e)).locations}async function _(t,e,r={}){try{return{locations:await t.references(e,{timeoutMs:r.requestTimeoutMs,deadlineMs:r.deadlineMs}),complete:!0}}catch(n){m(n);let i=n instanceof Error?n.message:String(n);if(M(n))return qe(t,e,r);if(!i.includes("content modified"))return{locations:[],complete:!0};await Q(r.deadlineMs);try{return{locations:await t.references(e,G(r)),complete:!0}}catch(s){return m(s),{locations:[],complete:!M(s)}}}}async function qe(t,e,r){if(!r.retryTimeoutMs||r.retryTimeoutMs<=0)return{locations:[],complete:!1};let n=G(r);try{return{locations:await t.references(e,n),complete:!0}}catch(i){return m(i),{locations:[],complete:!M(i)}}}function G(t){return{...t.retryTimeoutMs&&t.retryTimeoutMs>0?{timeoutMs:t.retryTimeoutMs}:{},...t.deadlineMs!==void 0?{deadlineMs:t.deadlineMs}:{}}}function M(t){let e=t instanceof Error?t.message:String(t);return e.includes("rust-analyzer LSP request")&&e.includes("timed out after")}async function We(t,e,r,n={}){let i=S(e,r,!1),s=await Ee(t,{textDocument:i.textDocument,position:i.position},n),u=(await Promise.all(s.map(a=>je(t,a,n)))).flat();return Fe(He(e,u))}async function Ee(t,e,r={}){try{return await t.prepareCallHierarchy(e,r)}catch(n){return m(n),[]}}async function je(t,e,r={}){try{return await t.outgoingCalls(e,r)}catch(n){return m(n),[]}}async function Q(t){if(t===void 0){await K(1e3);return}await P(1e3,t)}function m(t){if(t instanceof l)throw t}function He(t,e){return e.map(r=>({symbol:r.to.name,file:C(t,r.to.uri),line:r.to.selectionRange.start.line}))}function Fe(t){let e=new Set,r=[];for(let n of t){let i=`${n.symbol}\0${n.file}\0${n.line}`;e.has(i)||(e.add(i),r.push(n))}return r.sort((n,i)=>n.file.localeCompare(i.file)||n.line-i.line||n.symbol.localeCompare(i.symbol))}function K(t){return t<=0?Promise.resolve():new Promise(e=>setTimeout(e,t))}function $e(t,e){return e===t||e.startsWith(`${t}${be}`)}async function T(t,e,r){let n=new Array(t.length),i=0,s=Math.max(1,Math.min(t.length,Math.floor(e)));return await Promise.all(Array.from({length:s},async()=>{for(;i<t.length;){let u=i++;n[u]=await r(t[u])}})),n}async function Je(){return new Promise((t,e)=>{let r=[];d.stdin.on("data",n=>r.push(n)),d.stdin.on("error",e),d.stdin.on("end",()=>t(Buffer.concat(r).toString("utf8")))})}async function Be(){try{let t=JSON.parse(await Je()),e=await ve(t);d.stdout.write(JSON.stringify(e))}catch(t){let e={available:!1,reason:t instanceof Error?t.message:String(t),references:[]};d.stdout.write(JSON.stringify(e)),d.exitCode=1}}d.argv[1]&&Se(import.meta.url)===d.argv[1]&&Be();export{b as a,C as b,S as c,F as d,$ as e,g as f,W as g,Ge as h,ue as i,Qe as j,Ke as k,Ve as l,ve as m,B as n,U as o,N as p,Le as q,ze as r,Pe as s,xe as t,De as u,Me as v,ke as w,Ie as x,Oe as y,lt as z,_ as A,We as B,K as C,T as D};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-MQ2B33LQ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./chunk-
|
|
1
|
+
import{a as M}from"./chunk-FBUNGRKI.js";import{c as C}from"./chunk-63P42UR6.js";import{a as I}from"./chunk-7TJJY2C3.js";import{h as f}from"./chunk-EMIIOOTM.js";import{f as d}from"./chunk-US44MEVU.js";import{d as h}from"./chunk-MTDBHTSF.js";import{d as g}from"./chunk-AYRHVJXW.js";import{f as y}from"./chunk-GAE7WCBK.js";var x=new Set(h());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?d(e):null;c?.materializeReferences(a,{prefetchCallees:!0});let u=s.crossFileCallerMap(a,{semantic:!1});return{callerMap:c?f(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-NTOBQK5H.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-SJ6XSCG7.js";function m(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d2.relative_path
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d1 ON c.document_id = d1.id
|
|
@@ -30,4 +30,4 @@ import{a as s}from"./chunk-DV6B262O.js";function m(e,d){let i=s(e,d);return i?e.
|
|
|
30
30
|
WHERE d2.relative_path = ?
|
|
31
31
|
AND d1.relative_path != ?
|
|
32
32
|
ORDER BY d1.relative_path`,i,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}export{m as a,o as b};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-OLG2YPLS.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as x}from"./chunk-CIYUFF24.js";import{a as k}from"./chunk-7TJJY2C3.js";import{b as L}from"./chunk-CAKPEQZB.js";import{b as g}from"./chunk-B75HZHUP.js";import{a as n}from"./chunk-BGBBVSH4.js";import{j as v}from"./chunk-US44MEVU.js";import{d as S}from"./chunk-AYRHVJXW.js";import{s as a}from"./chunk-FC5K7T35.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-OOUJBAKJ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as C,b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as C,b}from"./chunk-2WCXKANA.js";import{a as P,c as y,e as r,f}from"./chunk-B3X6KU75.js";import{a as g,b as h,c as k}from"./chunk-KMVGRIO2.js";import{N as v}from"./chunk-WAU7HVDI.js";function L(e,i={}){let{minSimilarity:o=.62,minTokens:n=8,limit:c=20,scope:l,scanLimit:u,filePattern:m,focusFiles:d}=i,s=B(e,{scope:l,minTokens:n,scanLimit:u}),p=C(s,t=>t.tokens);return b({profiles:s,limit:c,filePattern:m,focusFiles:d,candidateIndex:p,profile:{name:"vue-component-duplicates"},compare:(t,a)=>V(t,a,o),sort:(t,a)=>a.similarity-t.similarity||t.fileA.localeCompare(a.fileA)||t.fileB.localeCompare(a.fileB)})}function B(e,i){return v(e).vueProfiles({scope:i.scope,minTemplateTokens:i.minTokens,scanLimit:i.scanLimit}).map(o=>({file:o.file,tokens:o.templateTokens,loc:T(o)}))}function T(e){return e.totalLines}function V(e,i,o){let n=g(e.tokens,i.tokens);if(n.size<6||!R(n))return null;let c=k(e.tokens,i.tokens);if(c<o)return null;let l=r(n,"component:"),u=r(n,"prop:"),m=r(n,"event:"),d=r(n,"directive:"),s=r(n,"slot:"),p=r(n,"id:"),t=S({sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p});return{fileA:e.file,fileB:i.file,similarity:c,tokenCountA:e.tokens.size,tokenCountB:i.tokens.size,sharedTokens:f(n),sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p,evidenceClass:t.evidenceClass,actionTier:t.actionTier,evidenceClassReasons:t.reasons,recommendation:t.recommendation,uniqueToA:f(h(e.tokens,i.tokens)).slice(0,25),uniqueToB:f(h(i.tokens,e.tokens)).slice(0,25),locA:e.loc,locB:i.loc}}function R(e){let i=0,o=0;for(let n of e)n.startsWith("component:")&&(i+=1),(n.startsWith("prop:")||n.startsWith("event:")||n.startsWith("directive:")||n.startsWith("slot:"))&&(o+=1);return y([{name:"component",count:i},{name:"behavior",count:o}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function S(e){return P({genericWords:x,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:w})}function w(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var x=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);export{L as a};
|
|
2
|
+
//# sourceMappingURL=chunk-OQ6TCHBB.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as f}from"./chunk-B3X6KU75.js";import{N as d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{d as f}from"./chunk-B3X6KU75.js";import{N as d}from"./chunk-WAU7HVDI.js";function S(n,e={}){let{minComponentLines:o=300,minFileLines:i=800,minJsxTokens:u=80,minBehaviorTokens:s=40,limit:a=20,scope:m,scanLimit:c,filePattern:p}=e;return d(n).reactProfiles({scope:m,scanLimit:c}).filter(t=>t.kind==="component").filter(t=>!p||t.file.includes(p)||t.name.includes(p)).map(t=>C(t,{minComponentLines:o,minFileLines:i,minJsxTokens:u,minBehaviorTokens:s})).filter(t=>t!==null).sort((t,r)=>r.componentLines-t.componentLines||r.fileLines-t.fileLines||t.file.localeCompare(r.file)).slice(0,a)}function C(n,e){let o=Math.max(80,Math.floor(e.minComponentLines/2)),i=f(n,x({minComponentLines:e.minComponentLines,minFileLines:e.minFileLines,minJsxTokens:e.minJsxTokens,minBehaviorTokens:e.minBehaviorTokens,substantialComponentLines:o}),"component"),{reasons:u}=i;if(u.length===0)return null;let s=i.dominantPressure,a=i.pressureKinds,m=b(n),c=R(s,a,m);return{file:n.file,component:n.name,componentLines:n.loc,fileLines:n.fileLines,jsxTokens:n.jsxTokens.size,behaviorTokens:n.behaviorTokens.size,dominantPressure:s,pressureKinds:a,contextKind:m,recommendationKind:c,recommendation:v(c,m),reasons:u,loc:n.loc}}function x(n){return[{axis:"component",value:e=>e.loc,qualifies:(e,o)=>o>=n.minComponentLines,reason:(e,o)=>`${o} component line(s)`},{axis:"file",value:e=>e.fileLines,qualifies:(e,o)=>o>=n.minFileLines&&e.loc>=n.substantialComponentLines,reason:(e,o)=>`${o} file line(s)`},{axis:"jsx-structure",value:e=>e.jsxTokens.size,weightedValue:(e,o)=>o*3,qualifies:(e,o)=>o>=n.minJsxTokens,reason:(e,o)=>`${o} JSX structure token(s)`},{axis:"hook-behavior",value:e=>e.behaviorTokens.size,weightedValue:(e,o)=>o*4,qualifies:(e,o)=>o>=n.minBehaviorTokens,reason:(e,o)=>`${o} behavior token(s)`}]}function b(n){let e=n.file.split(/[\\/]+/).filter(Boolean),o=e.slice(0,-1).map(r=>r.toLowerCase()),i=(e.at(-1)??n.name).replace(/\.[^.]+$/,""),s=o.findIndex(r=>k.has(r))>=0,a=o.some(r=>h.has(r));if(L(i)||L(n.name))return"component";let c=T.has(i.toLowerCase()),p=/(?:Page|Route|Screen)$/.test(n.name),l=s&&/View$/.test(n.name),t=!a&&i.replace(/[^A-Za-z0-9]+/g,"").toLowerCase()===n.name.replace(/[^A-Za-z0-9]+/g,"").toLowerCase()&&/(?:Page|Route|Screen|View)$/.test(i);return c||p||l||t?"route-page":"component"}function L(n){let e=n.split(/[^A-Za-z0-9]+/).filter(Boolean).map(o=>o.toLowerCase());return e.at(-1)&&g.has(e.at(-1))?!0:[...g].some(o=>n.endsWith(P(o)))}function R(n,e,o){return n==="hook-behavior"?"behavior-extraction":o==="route-page"?"route-page-decomposition":e.includes("hook-behavior")?"behavior-extraction":e.includes("jsx-structure")?"jsx-decomposition":e.includes("file")?"file-decomposition":n==="jsx-structure"?"jsx-decomposition":n==="file"&&!e.includes("component")?"file-decomposition":"component-decomposition"}function v(n,e){switch(n){case"behavior-extraction":return"Extract independent state, effects, requests, or handlers into hooks, controllers, or feature modules.";case"route-page-decomposition":return"Split route/page orchestration from reusable panels and feature controllers.";case"jsx-decomposition":return e==="route-page"?"Split page JSX into named layout sections before extracting behavior.":"Split repeated JSX sections into named presentational components.";case"file-decomposition":return"Review file-level decomposition; split colocated panels or helpers before changing behavior.";case"component-decomposition":return"Review component boundaries around props, state ownership, and independently changing UI sections."}}var h=new Set(["component","components","panel","panels","partial","partials"]),g=new Set(["banner","button","card","dialog","drawer","filter","form","grid","header","item","list","menu","modal","nav","panel","picker","rail","row","section","selector","shell","sidebar","table","toolbar"]),k=new Set(["landing","page","pages","route","routes","screen","screens","view","views"]),T=new Set(["page","route","screen"]);function P(n){return n.charAt(0).toUpperCase()+n.slice(1)}export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PNESKY2Z.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as L}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{d as L}from"./chunk-53SUJOJA.js";import{f,g as p}from"./chunk-WWCZCH7W.js";import{a as x}from"./chunk-CIYUFF24.js";import{a as v}from"./chunk-7TJJY2C3.js";import{b as D}from"./chunk-B75HZHUP.js";import{a as E}from"./chunk-BGBBVSH4.js";import{a as y}from"./chunk-EMIIOOTM.js";import{n as C}from"./chunk-DZXFZAZO.js";import{b}from"./chunk-HFBNIIZX.js";import{d as m,s as g}from"./chunk-AYRHVJXW.js";import{c as u,f as h}from"./chunk-GAE7WCBK.js";var A=/^(?:validate|verify|check|assert)(?:[A-Z].*)?$/,N=/^(?:is|has)(?:[A-Z].*)?$/,k=/[{,]\s*(?:ok|success|valid|isValid)\s*:\s*false\b/,d=/\breturn\b/g,I=/\bfunction\b|=>|\)\s*(?::\s*[^{;=]+)?\s*\{/,_=/\.(?:addIssue|push)\s*\(/;function M(e,t={}){let{scope:n,limit:i=30,scanLimit:l}=t,a=new v(e),r=D(a.productionCallableDefinitions({scope:n,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),l),s=[];for(let o of r){let c=P(e,o);c&&s.push({symbol:o.symbol,shortName:m(o.symbol),file:o.relativePath,startLine:o.startLine,endLine:o.endLine,loc:E(o),...c})}return s.sort((o,c)=>o.file.localeCompare(c.file)||o.startLine-c.startLine||o.loc-c.loc),i?s.slice(0,i):s}function w(e){return A.test(e)?"imperative":N.test(e)?"predicate":null}function P(e,t){let n=w(t.leaf);if(!n||x(e,t))return null;let i=f(e,t);if(!i||!I.test(i))return null;let l=h(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine);if(n==="predicate"&&l?.paramCount===0)return null;if(L(i)){let r=O(e,t);return!r||S(r.body,T(r.snippet))||R(r.body)?null:{nameKind:n,resolvedVia:"one-hop-delegate",delegateTarget:r.shortName}}let a=p(i);return S(a,T(i))||R(a)?null:{nameKind:n,resolvedVia:"direct"}}var F=new Set(["if","for","while","switch","catch","function"]);function R(e){let t=u(e);for(let n of t.matchAll(/\b([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\(/g))if(!F.has(n[1]))return!0;return!1}function T(e){let t=e.indexOf("=>");return t===-1?!1:!/^\s*\{/.test(e.slice(t+2))}function S(e,t){let n=u(e);if(/\bthrow\b/.test(n)||/\.reject\s*\(/.test(n)||k.test(n)||_.test(n))return!0;let i=K(n);if(t&&i.length===0){let l=n.trim();return l!==""&&l!=="true"}for(let l of i)if(l!==""&&l!=="true")return!0;return!1}function K(e){let t=[];d.lastIndex=0;let n;for(;n=d.exec(e);){let i=n.index+n[0].length,l=0,a=e.length;for(let r=i;r<e.length;r+=1){let s=e[r];if(s==="("||s==="["||s==="{")l+=1;else if(s===")"||s==="]"||s==="}"){if(l===0){a=r;break}l-=1}else if(s===";"&&l===0){a=r;break}}t.push(e.slice(i,a).trim()),d.lastIndex=a}return t}function O(e,t){let n=y(e,t,{callableOnly:!0,limit:3,semanticEvidence:C}),i=[...new Set(n.map(o=>o.symbol))].filter(o=>o!==t.symbol);if(i.length!==1)return null;let a=b(e,i[0]).match;if(!a)return null;let r=g(e,a.relativePath).find(o=>o.symbolId===a.symbolId);if(!r)return null;let s=f(e,r);return s?{body:p(s),snippet:s,shortName:m(r.symbol)}:null}export{M as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PYMZU5EG.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as f,n as b}from"./chunk-
|
|
1
|
+
import{m as f,n as b}from"./chunk-DZXFZAZO.js";import{a as d}from"./chunk-HFBNIIZX.js";import{d as s,h as u,p as m,q as g}from"./chunk-AYRHVJXW.js";import{y as c}from"./chunk-FC5K7T35.js";function x(e,r,i={}){let n=d(e,r);if(!n)return{definitions:[],referencedBy:[]};let t=e.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",n.symbolId),a=g(t?.documentation??null),o=e.isIgnored(n.relativePath)?[]:[{relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,signature:p(a,t?.display_name??null,n.symbol),source:y(e,n.relativePath,n.startLine,n.endLine)}],S=f(e,n,{semantic:i.semantic,semanticEvidence:b}).map(l=>({relativePath:l.file,line:l.line,enclosingSymbol:l.enclosingSymbol,enclosingShort:l.enclosingSymbol?s(l.enclosingSymbol):"(top-level)"}));return{definitions:o,referencedBy:S}}function y(e,r,i,n){let t=c(e,r);if(!t)return null;let o=t.split(`
|
|
2
2
|
`).slice(i,n+1).join(`
|
|
3
3
|
`).trimEnd();return o.length>0?o:null}function p(e,r,i){let n=m(e);if(n&&!h(n))return n;let t=(r??"").trim();return t?u(i)&&!t.endsWith("()")?`${t}()`:t:s(i)}function h(e){return e.startsWith("undefined")||e.includes("|")||e.includes("```")}export{x as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-Q2WEWIKX.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{m as h,n as R}from"./chunk-
|
|
1
|
+
import{m as h,n as R}from"./chunk-DZXFZAZO.js";import{a as g}from"./chunk-HFBNIIZX.js";import{h as d}from"./chunk-AYRHVJXW.js";import{y as p}from"./chunk-FC5K7T35.js";import{a as m}from"./chunk-64MNV6AB.js";function D(t,r,n={}){let e=g(t,r);if(!e)return[];let l=!d(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=h(t,e,{semantic:n.semantic,semanticEvidence:R}).map(s=>({relativePath:s.file,line:s.line})),o=b(t,e),f=new Set,a=[];for(let s of[...l,...c,...o]){let u=`${s.relativePath}:${s.line}`;f.has(u)||(f.add(u),a.push(s))}return a}function b(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=S(r.symbol);if(n.length===0)return[];let e=[];for(let i of m(t,{extensions:[".rb"],includeIgnored:!1})){let l=p(t,i);if(!l)continue;let c=l.split(`
|
|
2
2
|
`);for(let o=0;o<c.length;o++){let f=c[o]??"";n.some(a=>new RegExp(`@${a}\\b|\\b${a}:`).test(f))&&e.push({relativePath:i,line:o})}}return e}function S(t){let n=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),e=n.split("_").filter(Boolean),i=new Set;return n&&i.add(n),e.length>=1&&i.add(e[e.length-1]),e.length>=2&&i.add(e.slice(-2).join("_")),[...i]}export{D as a};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-QHKXGMOI.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Ba as R,E as p,F as g,Fd as D,Gd as a,Kd as u,Ma as w,Md as j,Pd as y,cd as P,ec as C,fd as c,gd as O,hd as L,jd as h,ud as b,z as f}from"./chunk-
|
|
2
|
+
import{Ba as R,E as p,F as g,Fd as D,Gd as a,Kd as u,Ma as w,Md as j,Pd as y,cd as P,ec as C,fd as c,gd as O,hd as L,jd as h,ud as b,z as f}from"./chunk-ESNRT7QN.js";var _=P,J=(o=>parseInt(o,10)),z=(o=>{let e=parseInt(o,10);if(!Number.isFinite(e)||e<1)throw new Error(`Expected a positive integer, got ${o}`);return e}),H=parseFloat,K=parseInt;function l(o,e,t,...n){return n.length>0?{flags:o,description:e,parser:t,defaultValue:n[0]}:{flags:o,description:e,parser:t}}function F(){return l("--json","Output as JSON for programmatic consumption")}function N(o=[]){return o.some(e=>e.flags==="--json")?o:[...o,F()]}function d(o,e=[]){return{category:o,examples:e}}function x(o,e){let t=p(o,e),n=A(t);for(let r of n)console.log(r)}function S(o,e,t="No results found for resolved symbol."){return p(o,e).match?t:k(e,g(o,e,5))}function v(o,e,t,n){return{...T(o,e),[n]:t}}function T(o,e){let t=p(o,e);return t.match?{matched:!0,resolved:{symbol:t.match.symbol,shortName:f(t.match.symbol),relativePath:t.match.relativePath},otherMatches:t.candidates.map(n=>({shortName:n.shortName,relativePath:n.relativePath,startLine:n.startLine})),totalMatches:t.total}:{matched:!1,suggestions:g(o,e,5)}}function k(o,e){let t=`No definition matched '${o}'.`;return e.length>0?`${t} Suggestions: ${e.join(", ")}`:t}function A(o){if(!o.match||o.total<=1)return[];let e=o.match,t=Math.max(0,o.total-1),n=[`Resolved: ${f(e.symbol)} (${e.relativePath}) -- ${t} other definition(s) share this name; qualify as <dir/leaf> to target another.`],r=o.candidates.slice(0,3);return r.length>0&&n.push(`Alternates: ${r.map(s=>`${s.shortName} (${s.relativePath}:${c(s.startLine)})`).join("; ")}`),n.push(""),n}var B=b(({db:o,args:e,opts:t})=>{let n=a(e,0),r=u(t,"signatures"),s=w(o,n);if(u(t,"json")){y("outline",e,t,s);return}if(s.length===0)return h.empty(`No symbols found for "${n}".`);function i(M,$){for(let m of M){let I=" ".repeat($),E=r&&m.signature?` - ${V(m.signature)}`:"";console.log(`${I}${O(m.startLine,m.endLine)} ${m.shortName}${E}`),i(m.children,$+1)}}i(s,0)});function V(o){return o.length>120?`${o.slice(0,117)}...`:o}var q=D("refs",{query:({db:o,args:e,budget:t})=>R(o,a(e,0),{semantic:t.semantic}),format:o=>` line ${c(o.line)}`,before:(o,{db:e,args:t})=>x(e,a(t,0)),emptyMessage:({db:o,args:e})=>S(o,a(e,0),"No references found."),toJson:(o,{db:e,args:t})=>v(e,a(t,0),o,"references")}),G=b(({db:o,args:e,opts:t})=>{let n=a(e,0),r=C(o,n,{context:j(t,"context",0)});if(u(t,"json")){y("code",e,t,v(o,n,r,"code"));return}if(!r)return h.empty(S(o,n,"Symbol found, but source was unreadable."));x(o,n),console.log(`${L(r.relativePath,r.startLine,r.endLine)} ${r.shortName} [${r.language??"unknown"}]
|
|
3
3
|
`);let s=r.source.split(`
|
|
4
4
|
`);for(let i=0;i<s.length;i++)console.log(` ${String(c(r.startLine+i)).padStart(4)} ${s[i]}`)}),ao=[{id:"refs",command:"refs <symbol>",description:"Find all files referencing a symbol",options:[l("--full","Run unbounded semantic analysis on large indexes"),l("--json","Output as JSON for programmatic consumption")],budget:"semantic",renderShape:"grouped-by-file",docs:d("Navigation",["scip-query refs login"]),handler:q},{id:"outline",command:"outline <file>",description:"Tree view of symbols in a file, with line ranges",options:N([l("--signatures","Show trimmed symbol signatures")]),renderShape:"custom",docs:d("Navigation"),handler:B},{id:"code",command:"code <symbol>",description:"Read the source code for a symbol (bounded to its definition range)",options:N([l("-C, --context <n>","Extra lines of context above/below",J,0)]),renderShape:"custom",docs:d("Navigation"),handler:G}];export{_ as a,J as b,z as c,H as d,K as e,l as f,F as g,N as h,d as i,x as j,S as k,v as l,T as m,ao as n};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-RPEA7P5Z.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as u}from"./chunk-HFBNIIZX.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-SJ6XSCG7.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
1
|
+
import{a as g}from"./chunk-SJ6XSCG7.js";import{h as p}from"./chunk-US44MEVU.js";import{a as f}from"./chunk-HFBNIIZX.js";import{d as u,e as _,i as N}from"./chunk-AYRHVJXW.js";import{p as d}from"./chunk-GAE7WCBK.js";import{B as l,b as c}from"./chunk-WAU7HVDI.js";import{y as b}from"./chunk-FC5K7T35.js";import{a as I}from"./chunk-64MNV6AB.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-DV6B262O.js";import{h as p}from"./chunk-QB5WSOTY.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-SSXEYWN3.js.map
|