scip-query 0.15.0 → 0.16.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/CHANGELOG.md +41 -1
- package/README.md +148 -66
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-2EU6WVR3.js +3 -0
- package/dist/chunk-2HFXPIBT.js +2 -0
- package/dist/chunk-2LGPMYS2.js +35 -0
- package/dist/chunk-2Y7YX54K.js +16 -0
- package/dist/chunk-363TZ64I.js +2 -0
- package/dist/chunk-3I34FZ6R.js +2 -0
- package/dist/chunk-3LAKH6BV.js +2 -0
- package/dist/chunk-3M2UCPFS.js +3 -0
- package/dist/chunk-3OPIMH42.js +2 -0
- package/dist/{chunk-QZOAOLLZ.js → chunk-3YAZH3JU.js} +2 -2
- package/dist/chunk-5P26M63Y.js +2 -0
- package/dist/{chunk-72FR7KEZ.js → chunk-5TVNLPUM.js} +14 -12
- package/dist/chunk-5UKDCXVC.js +5 -0
- package/dist/{chunk-R7U2I55B.js → chunk-5XDNFOAH.js} +2 -2
- package/dist/chunk-62Y3PC27.js +4 -0
- package/dist/chunk-6DNE65QS.js +40 -0
- package/dist/{chunk-N2OTJWC2.js → chunk-6EVORGCB.js} +2 -2
- package/dist/chunk-6GZ7LM7S.js +2 -0
- package/dist/chunk-753JWTUH.js +3 -0
- package/dist/chunk-7II7NFRV.js +4 -0
- package/dist/{chunk-M7EEHYSU.js → chunk-7RAS466A.js} +2 -2
- package/dist/chunk-A46JTKTM.js +5 -0
- package/dist/{chunk-2XRXEIRK.js → chunk-AAMZRDJT.js} +2 -2
- package/dist/chunk-AMPN2VMF.js +3 -0
- package/dist/{chunk-6XA4LDHY.js → chunk-B3X6KU75.js} +2 -2
- package/dist/chunk-BFWVHD2P.js +16 -0
- package/dist/chunk-BVHP2B4D.js +61 -0
- package/dist/{chunk-BUNDZ6K2.js → chunk-BVUA3GZC.js} +2 -2
- package/dist/{chunk-EDSD3VJK.js → chunk-CKIAEVGM.js} +2 -2
- package/dist/chunk-CM4EZLW4.js +2 -0
- package/dist/chunk-CS3FXTUC.js +2 -0
- package/dist/chunk-CVBS2FD4.js +2 -0
- package/dist/chunk-D5OXYOJP.js +7 -0
- package/dist/chunk-DA34GNNO.js +29 -0
- package/dist/chunk-DKK2H4D7.js +7 -0
- package/dist/chunk-EBSSCVR4.js +5 -0
- package/dist/{chunk-OXTM2RX3.js → chunk-EVCSXWER.js} +2 -2
- package/dist/chunk-FFIYGYQR.js +67 -0
- package/dist/chunk-G4KQ7S74.js +20 -0
- package/dist/{chunk-44P4SJFN.js → chunk-GWWYLYD3.js} +2 -2
- package/dist/chunk-HGUNWXJX.js +2 -0
- package/dist/chunk-HLRWOFXC.js +9 -0
- package/dist/{chunk-YQKECTPV.js → chunk-IRIM3SUR.js} +2 -2
- package/dist/chunk-JHK2DMUQ.js +4 -0
- package/dist/chunk-JQ2PCFZW.js +3 -0
- package/dist/chunk-JRFCWCOD.js +16 -0
- package/dist/chunk-JXAJDINF.js +2 -0
- package/dist/chunk-K32ZOW3P.js +2 -0
- package/dist/{chunk-3H5OSDF7.js → chunk-KI4WPR7Q.js} +2 -2
- package/dist/{chunk-43GKP6LI.js → chunk-KP2DJY7D.js} +2 -2
- package/dist/{chunk-YTVKPJXW.js → chunk-L27UIF3E.js} +2 -2
- package/dist/chunk-LT6AHYVY.js +18 -0
- package/dist/chunk-MCNWCJYL.js +11 -0
- package/dist/{chunk-K6UI6EBZ.js → chunk-MZB3DTHW.js} +2 -2
- package/dist/chunk-NLRWGGPY.js +8 -0
- package/dist/chunk-NLVKD45E.js +13 -0
- package/dist/chunk-OO6S4ECV.js +112 -0
- package/dist/{chunk-QYOPMTZ6.js → chunk-OYGKBDAD.js} +2 -2
- package/dist/chunk-P5QZILZ4.js +2 -0
- package/dist/chunk-P5XHIJHI.js +2 -0
- package/dist/chunk-PCCMMI2M.js +3 -0
- package/dist/{chunk-2TPCIPYA.js → chunk-Q65QYKU7.js} +2 -2
- package/dist/{chunk-K7SPOJHZ.js → chunk-QB7NRST4.js} +2 -2
- package/dist/{chunk-7JZRFDCU.js → chunk-QSNG3NHQ.js} +2 -2
- package/dist/chunk-QVZSWLLZ.js +2 -0
- package/dist/chunk-RLB7FZKR.js +10 -0
- package/dist/{chunk-KYB7FPXT.js → chunk-RPMT6MTX.js} +2 -2
- package/dist/chunk-RQWNF2RM.js +2 -0
- package/dist/chunk-RYFIRFYJ.js +4 -0
- package/dist/{chunk-QARYU7R3.js → chunk-S2FZILCF.js} +2 -2
- package/dist/{chunk-HV27H2V2.js → chunk-S3IXCXW2.js} +2 -2
- package/dist/{chunk-TYCZ7S4I.js → chunk-S5MTSES5.js} +2 -2
- package/dist/chunk-S5RZQA6V.js +2 -0
- package/dist/{chunk-PEHDARNC.js → chunk-SEEJPIWG.js} +2 -2
- package/dist/chunk-SOCS3467.js +2 -0
- package/dist/chunk-U6BJVXWQ.js +2 -0
- package/dist/chunk-UO4IADXJ.js +38 -0
- package/dist/{chunk-ZEO4CXQR.js → chunk-VLSI5MYU.js} +2 -2
- package/dist/chunk-VSQRU3AP.js +2 -0
- package/dist/chunk-VYQY75NA.js +2 -0
- package/dist/{chunk-NOKUZU56.js → chunk-VZCR3VQY.js} +2 -2
- package/dist/chunk-W3ZVRLCH.js +2 -0
- package/dist/chunk-WA64GKWB.js +20 -0
- package/dist/chunk-WFRZGMWJ.js +71 -0
- package/dist/chunk-WN6XEYVX.js +2 -0
- package/dist/chunk-XAEU4ROB.js +101 -0
- package/dist/chunk-XBPAJASV.js +2 -0
- package/dist/{chunk-GY3HAWUA.js → chunk-XC6PUFNN.js} +2 -2
- package/dist/chunk-Y42DMR6F.js +6 -0
- package/dist/chunk-YCVYOV4A.js +7 -0
- package/dist/{chunk-WPZPB42I.js → chunk-YD37KSEK.js} +2 -2
- package/dist/{chunk-V5W7H7V4.js → chunk-YFEJIYWH.js} +2 -2
- package/dist/chunk-YSUD2S7T.js +3 -0
- package/dist/{chunk-KJCDEDQW.js → chunk-ZEKBAMCN.js} +2 -2
- package/dist/chunk-ZHGUZKJL.js +2 -0
- package/dist/cli.js +586 -312
- package/dist/{config-types-aCgyLrvE.d.ts → config-types-SVkUIufk.d.ts} +8 -2
- package/dist/{db-DwCdT3rv.d.ts → db-CS0TuVH6.d.ts} +1 -1
- package/dist/{git-history-Dao3_Pu9.d.ts → git-history-ChNHbfZQ.d.ts} +2 -1
- package/dist/{health-nJUidasZ.d.ts → health-Btal3mQi.d.ts} +4 -4
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -19
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.d.ts +8 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +4 -3
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +3 -3
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +5 -4
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +12 -3
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +8 -3
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +5 -4
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +3 -3
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +4 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +3 -3
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +11 -5
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +3 -3
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +5 -5
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +3 -3
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +4 -4
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +4 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +4 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +4 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +4 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +4 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +256 -12
- package/dist/reindex.d.ts +29 -3
- package/dist/reindex.js +251 -22
- package/dist/runtime.d.ts +8 -4
- package/dist/runtime.js +2 -2
- package/dist/rust-semantic-session-server.js +2 -0
- package/dist/rust-semantic-session-worker.js +2 -0
- package/dist/rust-semantic-worker.js +2 -0
- package/dist/{scip-cli-DeAbuJ2b.d.ts → scip-cli-BKL-26TZ.d.ts} +2 -2
- package/dist/{symbol-types-DaoeXKUt.d.ts → symbol-types-BgWU6lhL.d.ts} +2 -0
- package/dist/watch-server.js +42 -0
- package/docs/AGENT_GUIDE.md +110 -34
- package/docs/AI_FAILURE_MODES.md +8 -3
- package/docs/COMMAND_REFERENCE.md +10 -6
- package/docs/REGEX_POLICY.md +3 -1
- package/docs/accuracy-audit-checklist.md +300 -0
- package/docs/accuracy-hardening-goal.md +493 -54
- package/docs/analyzer-inventory.md +31 -23
- package/docs/analyzer-validation-ledger.md +51 -21
- package/package.json +2 -1
- package/scripts/build-scip-windows.mjs +7 -7
- package/skills/_shared/SKILL.md +20 -19
- package/skills/scip-calibrate/SKILL.md +4 -2
- package/skills/scip-hyper-optimization/SKILL.md +5 -1
- package/skills/scip-query/SKILL.md +1 -1
- package/skills/scip-setup/SKILL.md +104 -4
- package/skills/scip-verify/SKILL.md +20 -14
- package/dist/chunk-27HMTUJE.js +0 -3
- package/dist/chunk-27XEGMCT.js +0 -7
- package/dist/chunk-3AMWF6V5.js +0 -3
- package/dist/chunk-4SCMYKD6.js +0 -2
- package/dist/chunk-5AAAEZ2Z.js +0 -2
- package/dist/chunk-5JRMZMLM.js +0 -2
- package/dist/chunk-5VY3RIEI.js +0 -38
- package/dist/chunk-6JUAGXR4.js +0 -4
- package/dist/chunk-6KDOYKCB.js +0 -40
- package/dist/chunk-6KMTPNZL.js +0 -3
- package/dist/chunk-7COVQPQQ.js +0 -9
- package/dist/chunk-7S5E7KWT.js +0 -2
- package/dist/chunk-7TVFPOD7.js +0 -102
- package/dist/chunk-A6KSEIRN.js +0 -61
- package/dist/chunk-AAMURYOK.js +0 -4
- package/dist/chunk-BP7S6V3M.js +0 -20
- package/dist/chunk-BRBF3E5X.js +0 -35
- package/dist/chunk-BZXE3HO4.js +0 -6
- package/dist/chunk-CXQQOXSI.js +0 -10
- package/dist/chunk-EVZSAR3S.js +0 -2
- package/dist/chunk-GMOEX7EV.js +0 -2
- package/dist/chunk-GNG622H3.js +0 -3
- package/dist/chunk-GUDKRIGW.js +0 -7
- package/dist/chunk-GULVO6NF.js +0 -43
- package/dist/chunk-HZZQKNVE.js +0 -2
- package/dist/chunk-I4R3SNMR.js +0 -2
- package/dist/chunk-IMQFJ53K.js +0 -2
- package/dist/chunk-ISLWJ4PY.js +0 -10
- package/dist/chunk-IUSSGHJO.js +0 -2
- package/dist/chunk-J5WVNZ6O.js +0 -2
- package/dist/chunk-JJUX2OAP.js +0 -2
- package/dist/chunk-JZBGTSAB.js +0 -13
- package/dist/chunk-K5N5RNGM.js +0 -2
- package/dist/chunk-KSJ544IV.js +0 -5
- package/dist/chunk-LY7NMOBW.js +0 -2
- package/dist/chunk-N23FT4EZ.js +0 -2
- package/dist/chunk-NCVFKOLB.js +0 -2
- package/dist/chunk-PESEPWZO.js +0 -2
- package/dist/chunk-PMY4UFGV.js +0 -2
- package/dist/chunk-Q7PWDXL5.js +0 -5
- package/dist/chunk-QVGFVRKD.js +0 -2
- package/dist/chunk-R5336VHZ.js +0 -2
- package/dist/chunk-RLB6SG25.js +0 -2
- package/dist/chunk-SFDVBARK.js +0 -2
- package/dist/chunk-TG7QSYCJ.js +0 -2
- package/dist/chunk-UHPWZCYQ.js +0 -3
- package/dist/chunk-URSSPS5H.js +0 -2
- package/dist/chunk-WIBFXSYB.js +0 -6
- package/dist/chunk-WMO2VZZK.js +0 -3
- package/dist/chunk-WS3Z6W3M.js +0 -65
- package/dist/chunk-X3DTIEMU.js +0 -18
- package/dist/chunk-X5C43YVI.js +0 -2
- package/dist/chunk-X7CHWTZ2.js +0 -72
- package/dist/chunk-XDESMVOL.js +0 -4
- package/dist/chunk-XZBLZHXL.js +0 -16
- package/dist/chunk-YBGC7HTY.js +0 -3
- package/dist/chunk-ZMGBWSFZ.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d,b as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as d,b as m}from"./chunk-ZEKBAMCN.js";import{c as u}from"./chunk-KMVGRIO2.js";import{a as c}from"./chunk-G4KQ7S74.js";function y(t,e={}){let{minSimilarity:o=.5,limit:l=20,scope:n,filePattern:p}=e,r=e.minDeps??(p?1:3),{profiles:i,distinctiveDeps:f}=D(t,{scope:n,minDeps:r}),s=d(i,a=>a.deps);return m({profiles:i,limit:l,filePattern:p,overrunFactor:5,candidateIndex:s,profile:{name:"similar-files"},compare:(a,g)=>F(a,g,o,f)})}function D(t,e){let{scope:o,minDeps:l}=e,n=c(t,o),{universalDeps:p,distinctiveDeps:r}=S(n),i=[];for(let[f,s]of n)s.size>=l&&i.push({file:f,deps:new Set([...s].filter(a=>!p.has(a)))});return{profiles:i,distinctiveDeps:r}}function S(t){let e=new Set,o=new Set,l=t.size;if(l===0)return{universalDeps:e,distinctiveDeps:o};let n=new Map;for(let r of t.values())for(let i of r)n.set(i,(n.get(i)??0)+1);let p=Math.max(3,Math.ceil(l*.03));for(let[r,i]of n)i>=5&&i/l>.3?e.add(r):i<=p&&o.add(r);return{universalDeps:e,distinctiveDeps:o}}function F(t,e,o,l){let n=new Set;for(let s of t.deps)e.deps.has(s)&&n.add(s);if(n.size<3||t.deps.size<4||e.deps.size<4)return null;let p=0;for(let s of n)l.has(s)&&p++;if(p<2)return null;let r=u(t.deps,e.deps);if(r<o)return null;let i=[];for(let s of t.deps)e.deps.has(s)||i.push(s);let f=[];for(let s of e.deps)t.deps.has(s)||f.push(s);return{fileA:t.file,fileB:e.file,similarity:r,sharedDeps:[...n],uniqueToA:i,uniqueToB:f}}export{y as a};
|
|
2
|
+
//# sourceMappingURL=chunk-3YAZH3JU.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as _}from"./chunk-
|
|
1
|
+
import{a as _}from"./chunk-QB7NRST4.js";import{a as r}from"./chunk-YSUD2S7T.js";import{a as l}from"./chunk-G4KQ7S74.js";import{d as c}from"./chunk-OO6S4ECV.js";function y(n,o){let e=r(n,o);if(!e)return[];let i=n.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN (
|
|
@@ -10,7 +10,7 @@ import{a as _}from"./chunk-K7SPOJHZ.js";import{a as r}from"./chunk-27HMTUJE.js";
|
|
|
10
10
|
) sym_def ON sym_def.symbol_id = m.symbol_id
|
|
11
11
|
WHERE m.symbol_id = ?
|
|
12
12
|
AND m.role != 1
|
|
13
|
-
AND sym_def.document_id != c.document_id`,
|
|
13
|
+
AND sym_def.document_id != c.document_id`,e.symbolId);return[{name:c(e.symbol),count:i?.file_count??0,symbol:e.symbol,definedIn:e.relativePath}]}function b(n,o){let e=_(n,o);if(!e)return[];let s=n.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
|
|
14
14
|
FROM mentions m
|
|
15
15
|
JOIN chunks c ON m.chunk_id = c.id
|
|
16
16
|
JOIN documents d ON c.document_id = d.id
|
|
@@ -27,7 +27,9 @@ import{a as _}from"./chunk-K7SPOJHZ.js";import{a as r}from"./chunk-27HMTUJE.js";
|
|
|
27
27
|
AND m.role != 1
|
|
28
28
|
AND def_d.id != d.id
|
|
29
29
|
GROUP BY d.id
|
|
30
|
-
ORDER BY symbol_count DESC`,
|
|
30
|
+
ORDER BY symbol_count DESC`,e).filter(t=>!n.isIgnored(t.relative_path)).map(t=>({name:t.relative_path,count:t.symbol_count}));if(s.length>0)return s;let d=l(n).get(e);return!d||d.size===0?[]:[{name:e,count:d.size}]}function p(n,o={}){return u(n,o).map(e=>({name:c(e.symbol),count:e.file_count,symbol:e.symbol,definedIn:e.defined_in}))}function u(n,o){let{limit:e=30,scope:i}=o,s=i?"AND def_d.relative_path LIKE ?":"",m=i?[`%${i}%`]:[];return n.all(`SELECT gs.symbol,
|
|
31
|
+
COUNT(DISTINCT c.document_id) AS file_count,
|
|
32
|
+
def_d.relative_path AS defined_in
|
|
31
33
|
FROM mentions m
|
|
32
34
|
JOIN chunks c ON m.chunk_id = c.id
|
|
33
35
|
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
@@ -41,13 +43,13 @@ import{a as _}from"./chunk-K7SPOJHZ.js";import{a as r}from"./chunk-27HMTUJE.js";
|
|
|
41
43
|
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
42
44
|
WHERE m.role != 1
|
|
43
45
|
AND def_d.id != c.document_id
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
46
|
+
${n.pathExclusionsFor("def_d")}
|
|
47
|
+
${n.symbolNoiseFor("gs")}
|
|
48
|
+
${s}
|
|
47
49
|
GROUP BY gs.id
|
|
48
50
|
HAVING file_count > 1
|
|
49
51
|
ORDER BY file_count DESC
|
|
50
|
-
LIMIT ?`,...m,
|
|
52
|
+
LIMIT ?`,...m,e)}function I(n,o={}){let{limit:e=30,scope:i}=o,s=i?"AND d.relative_path LIKE ?":"",m=i?[`%${i}%`]:[];return n.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
|
|
51
53
|
FROM mentions m
|
|
52
54
|
JOIN chunks c ON m.chunk_id = c.id
|
|
53
55
|
JOIN documents d ON c.document_id = d.id
|
|
@@ -62,10 +64,10 @@ import{a as _}from"./chunk-K7SPOJHZ.js";import{a as r}from"./chunk-27HMTUJE.js";
|
|
|
62
64
|
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
63
65
|
WHERE m.role != 1
|
|
64
66
|
AND def_d.id != d.id
|
|
65
|
-
${
|
|
66
|
-
${
|
|
67
|
-
${
|
|
67
|
+
${n.pathExclusionsFor("d")}
|
|
68
|
+
${n.symbolNoiseFor("gs")}
|
|
69
|
+
${s}
|
|
68
70
|
GROUP BY d.id
|
|
69
71
|
ORDER BY symbol_count DESC
|
|
70
|
-
LIMIT ?`,...m,
|
|
71
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
LIMIT ?`,...m,e).filter(t=>!n.isIgnored(t.relative_path)).map(t=>({name:t.relative_path,count:t.symbol_count}))}export{y as a,b,p as c,I as d};
|
|
73
|
+
//# sourceMappingURL=chunk-5TVNLPUM.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as U}from"./chunk-QZ4JVECJ.js";import{a as G}from"./chunk-WXVGNFAO.js";import{a as _}from"./chunk-HLRWOFXC.js";import{h as F,o as O,p as L,q as H,s as $,v as K,x as z,y as X}from"./chunk-WFRZGMWJ.js";import{existsSync as Y,readFileSync as P,statSync as St}from"fs";import{join as T}from"path";function I(t,n){let e=it(t,n)??rt(t,n)??ot(t,n)??st(t,n);return ct(t,e,n)}function it(t,n){let e=-1,i=null;for(let r=0;r<=n;r+=1){let o=j(t[r]??"");o&&(i===null?(i=o,e=r):o===i&&(i=null,e=-1))}if(i===null||e<0)return null;for(let r=n+1;r<t.length;r+=1)if(j(t[r]??"")===i)return{start:e,end:r+1};return{start:e,end:t.length}}function j(t){let n=t.match(/^\s*(```+|~~~+)/);return n?n[1].startsWith("`")?"`":"~":null}function rt(t,n){if(!v(t[n]??""))return null;let e=n;for(;e>0&&v(t[e-1]??"");)e-=1;let i=n+1;for(;i<t.length&&v(t[i]??"");)i+=1;return{start:e,end:i}}function v(t){let n=t.trim();return n.startsWith("|")&&n.endsWith("|")&&n.includes("|")}function ot(t,n){let e=n;for(;e>=0;){let o=t[e]??"";if(w(o)!==null)break;if(N(o)!==null)return null;e-=1}if(e<0)return null;let i=w(t[e]??"");if(i===null)return null;let r=e+1;for(;r<t.length;){let o=t[r]??"",s=w(o);if(s!==null){if(s<=i)break;r+=1;continue}if(N(o)!==null)break;r+=1}return{start:e,end:r}}function w(t){let n=t.match(/^(\s*)(?:[-*+]\s+|\d+[.)]\s+)/);return n?n[1].length:null}function st(t,n){let e=t[n]??"";if(V(e)||e.trim().length===0)return{start:n,end:n+1};let i=n;for(;i>0&&q(t[i-1]??"");)i-=1;let r=n+1;for(;r<t.length&&q(t[r]??"");)r+=1;return{start:i,end:r}}function q(t){return N(t)===null}function N(t){return t.trim().length===0?"blank":V(t)?"heading":j(t)?"fence":v(t)?"table":w(t)!==null?"list":null}function V(t){return/^#{1,6}\s+/.test(t.trim())}function ct(t,n,e){let{start:i,end:r}=n;if(r-i>40){let s=Math.floor(20);i=Math.max(i,e-s),r=Math.min(r,i+40),i=Math.max(n.start,r-40)}let o=t.slice(i,r).join(`
|
|
2
|
+
`).trim();return o.length<=2e3?o:`${o.slice(0,2e3).trimEnd()}...`}function R(t,n){return n.filter(e=>t.includes(e))}import{existsSync as at,readFileSync as W}from"fs";var lt=/<!--\s*scip-query:\s*snapshot\s*-->/i;function Z(t,n){if((t.config.docs?.snapshotPaths??[]).some(r=>U(r,n)))return!0;let i=X(t,n);return i.length>0&<.test(i)}var J={classifyCitation:ut,citationContexts:ft,citationKindLabel:mt,citationRemediation:ht,referenceTargets:pt,hasLineAnchoredCitation:dt};function dt(t){return t.some(n=>(n.lineReferences?.length??0)>0)}function ut(t){let n=t.join(`
|
|
3
|
+
`).toLowerCase(),e=[],i=R(n,[".scipquery","declaredcouplings","suppression","suppressions","config","configuration","json"]);if(i.length>0)return e.push(`configuration/example terms near citation: ${i.join(", ")}`),{citationKind:"configuration-example",actionTier:"support",reasons:e};let r=R(n,["accepted","intentional","intentionally","retained","historical"]);if(r.length>0)return e.push(`intentional-record terms near citation: ${r.join(", ")}`),{citationKind:"intentional-record",actionTier:"support",reasons:e};let o=R(n,["command","cli","usage","example","run","workflow"]);return o.length>0?(e.push(`guide/reference terms near citation: ${o.join(", ")}`),{citationKind:"guide-reference",actionTier:"signal",reasons:e}):(e.push(t.length>0?"citation appears in prose without config or guide markers":"citation context unavailable"),{citationKind:"behavioral-claim",actionTier:"direct",reasons:e})}function ft(t,n,e){let i;try{i=W(`${t.config.projectRoot}/${n}`,"utf-8").split(/\r?\n/)}catch{return[]}let r=e.flatMap(gt),o=[];for(let s=0;s<i.length;s+=1){let c=i[s]??"";r.some(a=>c.includes(a))&&o.push(I(i,s))}return o}function gt(t){let n=t.split("/");return[t,`./${t}`,n.slice(-3).join("/"),n.slice(-2).join("/")].filter((e,i,r)=>e.length>0&&r.indexOf(e)===i)}function mt(t){switch(t){case"behavioral-claim":return"a behavioral doc claim";case"configuration-example":return"a configuration example";case"guide-reference":return"a guide reference";case"intentional-record":return"an intentional record"}}function ht(t,n){switch(t){case"behavioral-claim":return`Re-read ${n} and update the behavioral claim or citation.`;case"configuration-example":return`Verify the configuration example in ${n} still points at the intended file; update only if the example target changed.`;case"guide-reference":return`Verify the guide reference in ${n} still sends readers to the right implementation or command surface.`;case"intentional-record":return`Verify the intentional citation in ${n} is still meant to name this file.`}}function pt(t,n,e){let i=G(e),r=new Set;for(let o of n)yt(t,o,i.get(o)??[])&&r.add(o);return r}function yt(t,n,e){if(!Ct.test(n))return!0;let i=`${t.config.projectRoot}/${n}`;if(!at(i))return!0;if(e.length===0)return!1;let r=W(i,"utf-8").split(/\r?\n/),o=bt(r);for(let s of e)for(let c=s.startLine;c<=s.endLine;c+=1)if((r[c]??"").trim()!==""&&!o.has(c))return!0;return!1}var Ct=/\.(?:[cm]?[jt]sx?)$/i;function bt(t){let n=new Set,e=!1;for(let i=0;i<t.length;i+=1){let r=t[i].trim();!e&&Dt(r)&&(e=!0),e&&(n.add(i),r.endsWith(";")&&(e=!1))}return n}function Dt(t){return/^import(?:\s|$)/.test(t)||/^export(?:\s+type)?\s+(?:\*|\{)/.test(t)}var Q=K({kind:"doc-path-evidence",invalidation:z("doc-path-evidence"),serialize:Nt,deserialize:Bt}),M=/\.(?:md|mdx|rst|txt)$/i;function xt(t){return/(?:^|\/)(?:docs\/plans|plans|adrs?|rfcs?|decisions|changelogs?|archive|reports?)\//i.test(t)||/(?:^|\/)CHANGELOG\.(?:md|mdx|rst|txt)$/i.test(t)}var Rt=3,Tt=/([A-Za-z0-9_@-]+(?:\/[A-Za-z0-9_.@-]+)+\.[A-Za-z0-9]{1,6})(?::([1-9][0-9]*))?\b/g;function sn(t,n={}){let{doc:e,limit:i=20,minCoupling:r=Rt,includeSnapshotExcluded:o=!1}=n,s=wt(t,n.historyMode??"bounded");if(!s)return{available:!1,commitsAnalyzed:0,docsScanned:0,findings:[]};let c=[];for(let a of s.docFiles){if(e!==void 0&&!a.includes(e)||e===void 0&&!tt(t,a)||e!==void 0&&!Y(T(t.config.projectRoot,a)))continue;let d=Z(t,a);if(d&&!o)continue;let{value:p,estimated:y}=At(t,a,s.changeTimes.get(a)),g=Mt(t,a),u=new Map,{resolved:l,broken:m,citations:D}=kt(t,a,s.tracked,s.trackedBySuffix,s.everSeenInHistory),S=new Map(D.map(f=>[f.file,f]));for(let f of l){if(f===a||M.test(f))continue;let C=(s.changeTimes.get(f)??[]).filter(b=>b>p).length;if(C===0)continue;let h=S.get(f);u.set(f,{file:f,evidence:"reference",coChanges:0,changesSinceDocUpdate:C,...B("reference",g,h?.contexts),citationContexts:h?.contexts,citedLines:h?.lineReferences})}for(let[f,C]of s.coupling.get(a)??[]){if(C<r||!s.tracked.has(f))continue;let h=(s.changeTimes.get(f)??[]).filter(A=>A>p).length;if(h===0)continue;let b=u.get(f);b?(b.evidence="both",b.coChanges=C,Object.assign(b,B("both",g,b.citationContexts))):u.set(f,{file:f,evidence:"co-change",coChanges:C,changesSinceDocUpdate:h,...B("co-change",g)})}if(u.size===0&&m.length===0)continue;let x=[...u.values()].sort((f,C)=>C.changesSinceDocUpdate-f.changesSinceDocUpdate);c.push({doc:a,docLastChangedAt:p,staleness:x.reduce((f,C)=>f+C.changesSinceDocUpdate,0)+m.length*10,subjects:x.slice(0,8),brokenReferences:m,...d?{snapshotExcluded:!0}:{},...y?{docLastChangedAtEstimated:!0}:{}})}return c.sort((a,d)=>d.staleness-a.staleness),{available:!0,commitsAnalyzed:s.historyCommitCount,docsScanned:s.docFiles.length,findings:c.slice(0,i)}}function At(t,n,e){if(e&&e.length>0)return{value:Math.max(...e),estimated:!1};try{return{value:Math.floor(St(T(t.config.projectRoot,n)).mtimeMs/1e3),estimated:!0}}catch{return{value:0,estimated:!1}}}function Mt(t,n){let e;try{e=P(T(t.config.projectRoot,n),"utf8").slice(0,6e3)}catch{return{docIntent:"unknown",reasons:["doc text unavailable"]}}let i=`${n}
|
|
4
|
+
${e}`.toLowerCase(),r=R(i,["historical note","historical record","history note","retrospective","postmortem","post-mortem","archived","archive","previously","legacy","recorded","record of","snapshot","as of","migration note","decision record"]);if(r.length>0)return{docIntent:"historical-note",reasons:[`historical-note terms: ${r.join(", ")}`]};let o=R(i,["current","standard","standards","must","should","policy","guide","guidance","workflow","contract","invariant","source of truth"]);return o.length>0?{docIntent:"current-guidance",reasons:[`current-guidance terms: ${o.join(", ")}`]}:{docIntent:"unknown",reasons:["no current-guidance or historical-note markers found"]}}function B(t,n,e=[]){let i=t==="co-change"||e.length===0?null:J.classifyCitation(e);return{actionTier:vt(t,n.docIntent,i?.actionTier),docIntent:n.docIntent,docIntentReasons:n.reasons,...i?{citationKind:i.citationKind,citationKindReasons:i.reasons}:{}}}function vt(t,n,e){return n==="historical-note"?"support":e||(t==="co-change"?"signal":"direct")}function wt(t,n){let e=_(t,{historyMode:n}),i=e.commitHistory();if(!i)return null;let r=e.trackedFiles()??new Set,o=new Map,s=new Map,c=new Set;for(let a of i.commits){let d=[...new Set(a.files)],p=d.filter(g=>M.test(g)),y=d.filter(g=>!M.test(g));for(let g of d){c.add(g);let u=o.get(g)??[];u.push(a.timestamp),o.set(g,u)}for(let g of p){let u=s.get(g);u||(u=new Map,s.set(g,u));for(let l of y)u.set(l,(u.get(l)??0)+1)}}return{changeTimes:o,coupling:s,docFiles:[...r].filter(a=>M.test(a)),everSeenInHistory:c,historyCommitCount:i.commits.length,tracked:r,trackedBySuffix:nt(r)}}function cn(t,n){if(n.size===0)return[];let e=H(),i=0,r=0,o=0,s=0,c=0,a=0;return $("doc-reference.docs-citing-files",()=>{let d=_(t).trackedFiles()??new Set;i=d.size;let p=nt(d),y=It(n,p),g=[];for(let u of d){if(!tt(t,u))continue;e&&(r+=1);let l;try{l=P(T(t.config.projectRoot,u),"utf-8")}catch{e&&(o+=1);continue}if(!_t(l,y)){e&&(s+=1);continue}let m=et(t,u,l);if(!m)continue;e&&(c+=1);let D=Et(m.candidates,n,y,d,p);if(D.size===0)continue;let S=[...new Set([...D.values()].flatMap(h=>[...h]))],x=Lt(m.contextsByCandidate,S),f=[...D].map(([h,b])=>({file:h,contexts:E([...b].flatMap(A=>x.get(A)??[])).slice(0,3),lineReferences:k([...b].flatMap(A=>m.lineReferencesByCandidate.get(A)??[]))})).filter(h=>h.contexts.length>0),C=[...D.keys()];if(C.length>0){e&&(a+=1);let h=C.sort();g.push({doc:u,cited:h,citations:f,citedClaims:E(f.flatMap(b=>b.contexts)).slice(0,3)})}}return g},()=>({targets:n.size,trackedFiles:i,livingDocs:r,unreadableDocs:o,candidateMisses:s,evidenceDocs:c,citedDocs:a}))}function tt(t,n){return M.test(n)&&!xt(n)&&Y(T(t.config.projectRoot,n))}function nt(t){let n=new Map;for(let e of t){let i=e.split("/");for(let r of[2,3]){if(i.length<r)continue;let o=i.slice(-r).join("/"),s=n.get(o)??[];s.push(e),n.set(o,s)}}return n}function It(t,n){let e=new Set(t);for(let i of t){let r=i.split("/");for(let o of[2,3]){if(r.length<o)continue;let s=r.slice(-o).join("/"),c=n.get(s);c?.length===1&&c[0]===i&&e.add(s)}}return e}function Et(t,n,e,i,r){let o=new Map;for(let s of t){if(!e.has(s))continue;let c;if(n.has(s))c=s;else if(i.has(s))c=s;else{let d=r.get(s);d?.length===1&&(c=d[0])}if(!c||!n.has(c))continue;let a=o.get(c)??new Set;a.add(s),o.set(c,a)}return o}function kt(t,n,e,i,r){let o=new Set,s=new Set,c=et(t,n);if(!c)return{resolved:o,broken:[],citations:[]};let a=c.candidates,d=c.contextsByCandidate,p=c.lineReferencesByCandidate,y=new Map,g=new Map,u=(l,m)=>{let D=d.get(m);if(D&&D.length>0){let x=y.get(l)??[];x.push(...D),y.set(l,E(x).slice(0,3))}let S=p.get(m);S&&S.length>0&&g.set(l,k([...g.get(l)??[],...S]))};for(let l of a){if(e.has(l)){o.add(l),u(l,l);continue}let m=i.get(l);if(m&&m.length===1){o.add(m[0]),u(m[0],l);continue}m&&m.length>1||r.has(l)&&s.add(l)}return{resolved:o,broken:[...s],citations:[...y].map(([l,m])=>({file:l,contexts:m,lineReferences:g.get(l)}))}}function Lt(t,n){let e=new Map;for(let i of n){let r=t.get(i);r&&r.length>0&&e.set(i,[...r])}return e}function et(t,n,e){let i=e;if(i===void 0)try{i=P(T(t.config.projectRoot,n),"utf-8")}catch{return null}let r=F(t,n,i),o=Q.read(t,n,r);if(o)return o;let s=jt(i);return Q.write(t,n,r,s),s}function _t(t,n){for(let e of n)if(t.includes(e))return!0;return!1}function jt(t){let n=t.split(/\r?\n/),e=new Set,i=new Map,r=new Map;for(let o=0;o<n.length;o+=1){let s=n[o]??"";for(let c of s.matchAll(Tt)){let a=(c[1]??"").replace(/^\.?\//,"");if(a.length===0)continue;e.add(a);let d=c[2]?Number(c[2]):null;d!==null&&Number.isSafeInteger(d)&&r.set(a,k([...r.get(a)??[],d]));let p=I(n,o);if(p.length===0)continue;let y=i.get(a)??[];y.push(p),i.set(a,E(y).slice(0,3))}}return{candidates:[...e],contextsByCandidate:i,lineReferencesByCandidate:r}}function Nt(t){let n={candidates:t.candidates,contextsByCandidate:[...t.contextsByCandidate.entries()],lineReferencesByCandidate:[...t.lineReferencesByCandidate.entries()]};return JSON.stringify(n)}function Bt(t){try{let n=JSON.parse(t);if(!O(n))return null;let e=L(n.candidates),i=Ft(n.contextsByCandidate),r=Pt(n.lineReferencesByCandidate);return!e||!i?null:{candidates:e,contextsByCandidate:new Map(i),lineReferencesByCandidate:new Map(r??[])}}catch{return null}}function Pt(t){if(t===void 0)return[];if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string"||!Array.isArray(e[1]))return null;let i=[];for(let r of e[1]){if(typeof r!="number"||!Number.isSafeInteger(r))return null;i.push(r)}n.push([e[0],k(i)])}return n}function Ft(t){if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;let i=L(e[1]);if(!i)return null;n.push([e[0],i])}return n}function E(t){let n=[];for(let e of new Set(t))n.some(i=>Ot(i,e))||n.push(e);return n}function k(t){return[...new Set(t)].sort((n,e)=>n-e)}function Ot(t,n){if(t===n)return!0;let e=t.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0),i=n.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0),r=Math.min(e.length,i.length);if(r===0)return!1;if(r<3)return t.includes(n)||n.includes(t);let o=new Set(i),s=e.filter(c=>o.has(c)).length;return s>=3&&s/r>=.6}export{Z as a,J as b,xt as c,sn as d,cn as e};
|
|
5
|
+
//# sourceMappingURL=chunk-5UKDCXVC.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as c}from"./chunk-G4KQ7S74.js";function j(e,s={}){let{minSimilarity:t=.5,limit:n=15,scope:i,minChainLength:r=3,maxChainLength:l=8}=s,a=c(e,i),o=y(a,r,l);if(o.length===0)return[];let f=d(o);return f.length<2?[]:S(x(f,t,n),n)}function d(e){let s=m(e),t=[];for(let n of e){let i=n.filter(r=>!s.has(r));i.length>=2&&t.push({original:n,filtered:i})}return t}function m(e){let{nodeFreq:s,tailFreq:t}=p(e),n=e.length*.9,i=e.length*.8,r=new Set;for(let[a,o]of s)o>n&&r.add(a);for(let[a,o]of t)o>i&&r.add(a);let l=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let a of s.keys()){let o=a.split("/").pop()??"";l.includes(o)&&r.add(a)}return r}function p(e){let s=new Map,t=new Map;for(let n of e){let i=new Set;for(let r of n)i.has(r)||(s.set(r,(s.get(r)??0)+1),i.add(r));for(let r=Math.max(0,n.length-2);r<n.length;r++)t.set(n[r],(t.get(n[r])??0)+1)}return{nodeFreq:s,tailFreq:t}}function x(e,s,t){let n=[];for(let i=0;i<e.length;i++){for(let r=i+1;r<e.length;r++){let l=b(e[i],e[r],s);l&&n.push(l)}if(n.length>t*10)break}return n.sort((i,r)=>Math.abs(r.similarity-i.similarity)>.01?r.similarity-i.similarity:i.divergencePoints.length-r.divergencePoints.length),n}function b(e,s,t){if(!C(e.filtered,s.filtered))return null;let{distance:n,ops:i}=A(e.filtered,s.filtered),r=Math.max(e.filtered.length,s.filtered.length);if(r===0)return null;let l=1-n/r;if(l<t||n===0)return null;let a=i.filter(f=>f.type==="substitute").map(f=>({index:f.indexA,nodeA:e.filtered[f.indexA],nodeB:s.filtered[f.indexB]}));return a.length===0||i.filter(f=>f.type==="match").length<2?null:{chainA:e.original,chainB:s.original,similarity:l,editDistance:n,divergencePoints:a,commonPrefix:F(e.original,s.original),commonSuffix:B(e.original,s.original)}}function C(e,s){let t=new Set(e);return s.some(n=>t.has(n))}function S(e,s){let t=[];for(let n of e)if(t.some(r=>h(n.chainA,r.chainA)&&h(n.chainB,r.chainB))||t.push(n),t.length>=s)break;return t}function y(e,s,t){let n=[];for(let r of e.keys()){if(n.length>=500)break;g(e,r,[r],new Set([r]),s,t,n,500)}return n}function g(e,s,t,n,i,r,l,a){if(l.length>=a)return;if(t.length>=r){t.length>=i&&l.push([...t]);return}let o=e.get(s);if(!o||o.size===0){t.length>=i&&l.push([...t]);return}let f=!1;for(let u of o)if(!n.has(u)&&(n.add(u),t.push(u),g(e,u,t,n,i,r,l,a),t.pop(),n.delete(u),f=!0,l.length>=a))return;!f&&t.length>=i&&l.push([...t])}function A(e,s){let t=e.length,n=s.length,i=Array.from({length:t+1},()=>Array(n+1).fill(0));for(let o=0;o<=t;o++)i[o][0]=o;for(let o=0;o<=n;o++)i[0][o]=o;for(let o=1;o<=t;o++)for(let f=1;f<=n;f++)e[o-1]===s[f-1]?i[o][f]=i[o-1][f-1]:i[o][f]=1+Math.min(i[o-1][f],i[o][f-1],i[o-1][f-1]);let r=[],l=t,a=n;for(;l>0||a>0;)l>0&&a>0&&e[l-1]===s[a-1]?(r.unshift({type:"match",indexA:l-1,indexB:a-1}),l--,a--):l>0&&a>0&&i[l][a]===i[l-1][a-1]+1?(r.unshift({type:"substitute",indexA:l-1,indexB:a-1}),l--,a--):a>0&&i[l][a]===i[l][a-1]+1?(r.unshift({type:"insert",indexA:l,indexB:a-1}),a--):(r.unshift({type:"delete",indexA:l-1,indexB:a}),l--);return{distance:i[t][n],ops:r}}function F(e,s){let t=[];for(let n=0;n<Math.min(e.length,s.length)&&e[n]===s[n];n++)t.push(e[n]);return t}function B(e,s){let t=[],n=e.length-1,i=s.length-1;for(;n>=0&&i>=0&&e[n]===s[i];)t.unshift(e[n]),n--,i--;return t}function h(e,s){if(e.length>s.length)return!1;let t=s.join("\u2192"),n=e.join("\u2192");return t.includes(n)}export{j as a};
|
|
2
|
+
//# sourceMappingURL=chunk-5XDNFOAH.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as D,b as v,c as $,d as B}from"./chunk-CVBS2FD4.js";import{a as K}from"./chunk-MZB3DTHW.js";import{a as A}from"./chunk-3I34FZ6R.js";import{b as M,g as R}from"./chunk-NLRWGGPY.js";import{a as g}from"./chunk-BGBBVSH4.js";import{g as I}from"./chunk-UO4IADXJ.js";import{b as k,d as F,e as b}from"./chunk-OO6S4ECV.js";import{l as w}from"./chunk-NLVKD45E.js";import{y as C}from"./chunk-WFRZGMWJ.js";function de(t,e){let{scope:n,minLoc:i=3,maxLoc:s=80,limit:r=30,includeLowConfidence:l=!1,scanLimit:o}=e??{},d=e?.semantic!==!1,a=new A(t),m=a.scopedDefinitions(n),y=Q(a,n),p={high:0,medium:1,low:2};return K({candidates:()=>O(t,a,m,{minLoc:i,maxLoc:s}),orderCandidates:(u,c)=>g(c)-g(u)||u.relativePath.localeCompare(c.relativePath),scanLimit:o,profile:{name:"stale-abstractions"},prepare:u=>{let c=U(u),f=W(t,a,u,c,{semantic:d}),h=u.filter(P=>{let x=S(t,P,f,c);return x.realConsumers.length<=1&&!x.transitivelyReachable&&j(P,x.realConsumers.length,y)});return{consumerFileMap:f,singletonBackedClassIds:H(t,a,m,h,{semantic:d}),candidateIndex:c}},evaluate:(u,c)=>{if(c.singletonBackedClassIds.has(u.symbolId))return null;let f=S(t,u,c.consumerFileMap,c.candidateIndex);if(f.transitivelyReachable||f.realConsumers.length>1||f.realConsumers.length===0&&f.barrelConsumers>0||!j(f.definition,f.realConsumers.length,y))return null;let h=V(t,f);return!l&&h.confidence==="low"?null:h},orderResults:(u,c)=>p[u.confidence]-p[c.confidence]||c.loc-u.loc||u.file.localeCompare(c.file)||u.startLine-c.startLine,limit:r})}function O(t,e,n,i){return n.filter(s=>s.isTypeLike&&g(s)>=i.minLoc).filter(s=>g(s)<=i.maxLoc).filter(s=>!t.isIgnored(s.relativePath)).filter(s=>!s.relativePath.endsWith(".d.ts")).filter(s=>M(s.relativePath)!=="test").filter(s=>!R(t,s.symbol,s.relativePath)).filter(s=>!X(s.symbol)).filter(s=>!e.hasSuppressionComment(s))}function L(t,e,n,i){return v(D(t,e).forDefinitions(n,{semantic:i.semantic,sourceFallback:i.sourceFallback}))}function W(t,e,n,i,s){let r=L(t,e,n,{semantic:!1,sourceFallback:!1}),l=n.filter(a=>{let m=S(t,a,r,i);return m.realConsumers.length<=1&&!(m.realConsumers.length>0&&T(a.relativePath))}),o=s.semantic&&l.length>0?I(r,L(t,e,l,{semantic:!0,sourceFallback:!1})):r,d=l.filter(a=>S(t,a,o,i).realConsumers.length<=1);return I(o,L(t,e,d,{semantic:!1,sourceFallback:!0}))}function U(t){let e=new Map;for(let n of t){let i=e.get(n.relativePath);i||(i=new Map,e.set(n.relativePath,i));let s=b(n.symbol);s&&i.set(s,n)}return e}function S(t,e,n,i){let r=[...n.get(e.symbolId)??new Set].filter(m=>m!==e.relativePath&&!t.isIgnored(m)),{realConsumers:l,barrelConsumers:o,importOnlyConsumers:d}=$(t,e,r),a=Y(t,e,n,i);return{definition:e,realConsumers:l,barrelConsumers:o+d,transitivelyReachable:a}}function V(t,e){let n=E(t,e.definition.relativePath,e.definition.startLine),i=T(e.definition.relativePath)?!0:ee(t,e.definition),{confidence:s,reason:r}=ne(e.realConsumers.length,n,i),l=z(e.realConsumers.length,n,i);return{symbol:e.definition.symbol,shortName:F(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:g(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:n,definerUsesType:i,confidence:s,reason:r,actionTier:l.actionTier,stalenessKind:l.stalenessKind,recommendation:l.recommendation}}function z(t,e,n){return t===0?{actionTier:"direct",stalenessKind:"unused-abstraction",recommendation:"Delete the abstraction or wire the missing consumer after checking public/package surfaces."}:e==="class"?{actionTier:"signal",stalenessKind:"one-to-one-class-encapsulation",recommendation:"Treat as weak signal: a one-consumer class may be intentional encapsulation, so inline only after reviewing ownership and state boundaries."}:n?{actionTier:"signal",stalenessKind:"single-consumer-abstraction",recommendation:"Review whether this single-consumer abstraction earns its name or should be folded into the owning feature."}:{actionTier:"signal",stalenessKind:"misplaced-single-consumer-type",recommendation:"Review moving or co-locating the type with its only real consumer; keep it here only if this file owns the public contract."}}function H(t,e,n,i,s){let r=_(t,Z(n),i),l=r.map(a=>a.singleton);if(r.length===0)return new Set;let o=v(D(t,e).forDefinitions(l,{semantic:s.semantic,sourceFallback:!0})),d=new Set;for(let{singleton:a,classId:m}of r)G(t,a,o)&&d.add(m);return d}function Z(t){let e=new Map;for(let n of t){let i=b(n.symbol);i&&e.set(N(n.relativePath,i),n)}return e}function _(t,e,n){let i=[];for(let s of n){let r=q(t,e,s);r&&i.push({singleton:r,classId:s.symbolId})}return i}function q(t,e,n){if(E(t,n.relativePath,n.startLine)!=="class")return null;let i=b(n.symbol);if(!i)return null;let s=J(t,n.relativePath,i);return s?e.get(N(n.relativePath,s))??null:null}function G(t,e,n){let i=b(e.symbol),s=n.get(e.symbolId);return!i||!s?!1:[...s].some(r=>r!==e.relativePath&&!t.isIgnored(r)&&!B(t,r,i))}function N(t,e){return`${t}\0${e}`}function J(t,e,n){let i=C(t,e);if(!i)return null;let s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\bexport\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*new\\s+${s}\\s*\\(`);return i.match(r)?.[1]??null}function Q(t,e){return new Set(t.scopedDefinitions(e).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function X(t){let e=k(t);if("kind"in e)return!1;let n=e.descriptors;if(n.length<2)return!1;let i=n[n.length-1],s=n[n.length-2];return i?.suffix==="type"&&s?.suffix==="type"}function T(t){let n=(t.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n.endsWith("-types")||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||n==="contracts"||/(^|\/)types(\/|\.)/.test(t)||/(^|\/)models?(\/|\.)/.test(t)||/(^|\/)proto(?:col)?(\/|\.)/.test(t)||/(^|\/)schema(\/|\.)/.test(t)||/(^|\/)contracts?(\/|\.)/.test(t))}function j(t,e,n){return!(T(t.relativePath)&&e>0||e===0&&n.has(t.relativePath))}function Y(t,e,n,i){let s=w(t,e.relativePath),r=b(e.symbol);if(!r)return!1;let l=i.get(e.relativePath);if(!l)return!1;let o=[...s.get(r)??[]],d=new Set;for(;o.length>0;){let a=o.pop();if(d.has(a))continue;d.add(a);let m=l.get(a);if(!m)continue;let y=n.get(m.symbolId);if(y){for(let p of y)if(p!==e.relativePath&&!t.isIgnored(p))return!0}for(let p of s.get(a)??[])o.push(p)}return!1}function E(t,e,n){let i=C(t,e);if(!i)return"other";let s=i.split(`
|
|
2
|
+
`),r=Math.max(0,n-2),l=Math.min(s.length-1,n+2);for(let o=r;o<=l;o++){let a=(s[o]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(a))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(a))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(a))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(a))return"enum"}return"other"}function ee(t,e){let n=C(t,e.relativePath);if(!n)return!1;let i=b(e.symbol);if(!i)return!1;let s=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${s}\\b`),l=n.split(`
|
|
3
|
+
`);for(let o=0;o<l.length;o++)if(!(o>=e.startLine&&o<=e.endLine)&&r.test(l[o]??""))return!0;return!1}function ne(t,e,n){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&e==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}export{de as a};
|
|
4
|
+
//# sourceMappingURL=chunk-62Y3PC27.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{b as w}from"./chunk-2EU6WVR3.js";import{b as g}from"./chunk-YSUD2S7T.js";import{c as h,d as f}from"./chunk-MTDBHTSF.js";import{d as u,e as c,h as m,p as b,q as p}from"./chunk-OO6S4ECV.js";import{dirname as $,relative as T,resolve as k}from"path";var A=new Set(f());function O(t,n){return`tests/generated/twin-ab/${y(t)}-vs-${y(n)}.test.ts`}function y(t){return(t.split(/[/#]/).pop()||t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"symbol"}function I(t,n,a,e){let o=d(t,n);if(!o.ok)return o;let i=d(t,a);if(!i.ok)return i;let r=o.symbol.paramCount===null||i.symbol.paramCount===null?null:o.symbol.paramCount===i.symbol.paramCount,s=v(o.symbol,i.symbol,t.config.projectRoot,e,r);return{ok:!0,a:o.symbol,b:i.symbol,signatureCompatible:r,testSource:s}}function d(t,n){let e=g(t,n).match;if(!e)return{ok:!1,reason:`${n} does not resolve to an indexed symbol.`};let i=t.get("SELECT kind FROM global_symbols WHERE id = ?",e.symbolId)?.kind??null;if(!(i!==null?A.has(i):m(e.symbol)))return{ok:!1,reason:`${n} resolves to ${u(e.symbol)}${i!==null?` with SCIP kind ${h(i)}`:""} \u2014 twin-ab compares call outputs, so both referents must be functions or methods.`};if(!w(t,e))return{ok:!1,reason:`${n} (${u(e.symbol)} at ${e.relativePath}:${e.startLine+1}) is not exported \u2014 twin-ab needs an importable named binding for both twins.`};let s=t.get("SELECT documentation FROM global_symbols WHERE id = ?",e.symbolId),l=b(p(s?.documentation??null));return{ok:!0,symbol:{ref:n,symbol:e.symbol,shortName:c(e.symbol)||u(e.symbol),file:e.relativePath,startLine:e.startLine,signature:l,paramCount:l?x(l):null}}}function x(t){let n=t.indexOf("(");if(n===-1)return null;let a=0,e=-1;for(let s=n;s<t.length;s+=1){let l=t[s];if(l==="(")a+=1;else if(l===")"&&(a-=1,a===0)){e=s;break}}if(e===-1)return null;let o=t.slice(n+1,e).trim();if(!o)return 0;let i=1,r=0;for(let s of o)s==="("||s==="["||s==="{"?r+=1:s===")"||s==="]"||s==="}"?r=Math.max(0,r-1):s===","&&r===0&&(i+=1);return i}function S(t,n,a){let e=$(n),o=k(t,a),r=T(e,o).replace(/\\/g,"/").replace(/\.tsx?$/,".js");return r.startsWith(".")?r:`./${r}`}function v(t,n,a,e,o){let i=S(a,e,t.file),r=S(a,e,n.file),s=o===null?"Signature comparison: unknown (one or both signatures unavailable in the index) \u2014 check by hand.":o?"Signature comparison: param counts match.":"Signature comparison: param counts DIFFER \u2014 twins may not be directly comparable; check by hand.";return`/**
|
|
2
|
+
* Generated by 'scip-query twin-ab'. scip-integrity-audit drill 5
|
|
3
|
+
* ("cross-examine same-concept twins"): where one concept is computed in
|
|
4
|
+
* more than one place, feed both the same input and require the same
|
|
5
|
+
* answer. Disagreement between twins means at least one is wrong \u2014
|
|
6
|
+
* determine which before consolidating.
|
|
7
|
+
*
|
|
8
|
+
* Twin A: ${t.shortName} (${t.file}:${t.startLine+1})
|
|
9
|
+
* ${t.signature??"(signature unavailable)"}
|
|
10
|
+
* Twin B: ${n.shortName} (${n.file}:${n.startLine+1})
|
|
11
|
+
* ${n.signature??"(signature unavailable)"}
|
|
12
|
+
* ${s}
|
|
13
|
+
*
|
|
14
|
+
* Fill in the TODO input table below with inputs both twins should agree
|
|
15
|
+
* on, then run this file with vitest.
|
|
16
|
+
*/
|
|
17
|
+
import { describe, expect, it } from 'vitest';
|
|
18
|
+
import { ${t.shortName} as twinA } from '${i}';
|
|
19
|
+
import { ${n.shortName} as twinB } from '${r}';
|
|
20
|
+
|
|
21
|
+
// TODO: fill in shared inputs both twins should agree on \u2014 one arg array per call.
|
|
22
|
+
const inputs: any[][] = [
|
|
23
|
+
// [/* arg1, arg2, ... */],
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// Cast to a variadic signature so the input table can hold any arg shape \u2014
|
|
27
|
+
// the real twins have fixed, non-rest parameter lists, and TS rejects
|
|
28
|
+
// spreading a generic args array into those (TS2556) even when the array
|
|
29
|
+
// itself is 'any'; casting the callee's signature, not the args, satisfies
|
|
30
|
+
// the checker without weakening the twins' real exported types elsewhere.
|
|
31
|
+
const callA = twinA as (...callArgs: any[]) => any;
|
|
32
|
+
const callB = twinB as (...callArgs: any[]) => any;
|
|
33
|
+
|
|
34
|
+
describe.skipIf(inputs.length === 0)('twin-ab: ${t.shortName} vs ${n.shortName}', () => {
|
|
35
|
+
it.each(inputs)('agrees on input %#', (...args) => {
|
|
36
|
+
expect(callA(...args)).toEqual(callB(...args));
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
`}export{O as a,I as b};
|
|
40
|
+
//# sourceMappingURL=chunk-6DNE65QS.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as T,c as E,g as L,h as D}from"./chunk-
|
|
1
|
+
import{a as T,c as E,g as L,h as D}from"./chunk-RPMT6MTX.js";import{j as O,o as A}from"./chunk-A46JTKTM.js";import{d as H}from"./chunk-KMVGRIO2.js";import{a as _}from"./chunk-3I34FZ6R.js";import{d as C,e as F}from"./chunk-OO6S4ECV.js";import{a as w}from"./chunk-NLVKD45E.js";var J=5;function ae(e,t={}){let{base:a="HEAD",minContainment:o=.7,minCallees:r=3,minSiteCoverage:n=.4,maxHelpers:c=Number.POSITIVE_INFINITY,limit:m=20,scanLimit:g}=t,f=t.semantic!==!1,s=t.diffPlan??E(e,{base:a}),l={available:s.note!==T,base:a,changedFiles:s.changedFiles,helpersChecked:0,skipped:[],findings:[]};if(!l.available||s.changedFiles.length===0)return l;let x=new _(e),k=new Set(s.changedFiles),$=new Map(s.renamedFiles.map(i=>[i.to,i.from])),j=t.baseContentAt??L(e.config.projectRoot,a,D(s)),h=Z(x,k,$,j);if(h.length===0)return l;let R=h.slice(0,c);h.length>c&&(l.note=`helper scoring capped at ${c} of ${h.length} new symbols`);let q=x.calleeMap(R,{semantic:f}),B=R.map(i=>({def:i,callees:A((q.get(i.symbolId)??[]).map(p=>p.symbol))})),V=O(e),M,G=()=>(M??=V.calleeIndex({minCallees:Math.min(3,r),scanLimit:g,semantic:f}),M);for(let{def:i,callees:p}of B){let d=C(i.symbol);if(p.size<r){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let P=G(),N=Y(p,P);if(N===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let b=Q(e,i.symbolId);if(b.length===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}l.helpersChecked+=1;let I=K({candidateIndex:P,changed:k,helperCallees:p,helperFile:i.relativePath,helperSymbol:i.symbol,minContainment:o,minSiteCoverage:n,migratedFiles:b});I.length!==0&&(I.sort((u,S)=>z(S.migrationScope)-z(u.migrationScope)||S.containment-u.containment||S.siteCoverage-u.siteCoverage||u.file.localeCompare(S.file)),l.findings.push({helperSymbol:i.symbol,helperShortName:d,helperFile:i.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:N,migratedFiles:b.sort(),leftovers:I.slice(0,J)}))}return l.findings.sort((i,p)=>(p.leftovers[0]?.containment??0)-(i.leftovers[0]?.containment??0)||i.helperFile.localeCompare(p.helperFile)),l.findings=l.findings.slice(0,m),l}function K(e){let t=[],a=U(e.helperSymbol,e.helperFile,e.migratedFiles),o=new Set;for(let r of e.helperCallees)for(let n of e.candidateIndex.candidateIndexesByCallee.get(r)??[])o.add(n);for(let r of o){let n=e.candidateIndex.corpus[r];if(n.symbol===e.helperSymbol||e.changed.has(n.file)||n.callees.has(e.helperSymbol))continue;let c=H(e.helperCallees,n.callees);if(c<e.minContainment)continue;let m=[...e.helperCallees].filter(s=>n.callees.has(s)),g=n.callees.size===0?0:m.length/n.callees.size;if(g<e.minSiteCoverage||!m.some(s=>(e.candidateIndex.docFreq.get(s)??0)<=e.candidateIndex.ubiquityThreshold))continue;let f=W(a,n.symbol,n.file);t.push({symbol:n.symbol,shortName:C(n.symbol),file:n.file,...f,containment:c,siteCoverage:g,uniqueSiteCalleeCount:Math.max(0,n.callees.size-m.length),sharedCallees:m.map(C).sort()})}return t}function z(e){return e==="same-scope"?2:e==="unknown"?1:0}function U(e,t,a){let o=new Set([...y(t),...v(F(e))]);for(let r of a)for(let n of y(r))o.add(n);return o}function W(e,t,a){let o=new Set([...y(a),...v(F(t))]);if(e.size===0||o.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...o].filter(n=>e.has(n)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var X=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function y(e){return v(e.replace(/\.[^.]+$/,""))}function v(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!X.has(t))}function Y(e,t){let a=0;for(let o of e)(t.docFreq.get(o)??0)<=t.ubiquityThreshold&&(a+=1);return a}function Z(e,t,a,o){return e.productionCallableDefinitions({files:[...t],requireFunctionLikeSymbol:!0}).filter(r=>{if(!t.has(r.relativePath))return!1;let n=a.get(r.relativePath)??r.relativePath,c=o(n);return c===null||!new RegExp(`\\b${w(r.leaf)}\\b`).test(c)})}function Q(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
5
5
|
WHERE m.symbol_id = ?
|
|
6
6
|
AND m.role != 1
|
|
7
7
|
${e.pathExclusionsFor("ref_d")}`,t).map(o=>o.relative_path)}export{ae as a};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-6EVORGCB.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as M}from"./chunk-753JWTUH.js";import{b as $}from"./chunk-B75HZHUP.js";import{a as p}from"./chunk-BGBBVSH4.js";import{m as D}from"./chunk-DA34GNNO.js";import{d as I}from"./chunk-MTDBHTSF.js";import{d as b,j as h,p as x,q as y,t as L}from"./chunk-OO6S4ECV.js";import{a as g,e as S}from"./chunk-NLVKD45E.js";import{y as d}from"./chunk-WFRZGMWJ.js";var B=new Set(I());function X(e,n={}){let{scope:s,minLoc:i=1,limit:r,scanLimit:c,maxShapeFrequency:a=12}=n,o=n.semantic!==!1,t=w(e,F(e,{scope:s,minLoc:i,scanLimit:c}),{semantic:o,maxShapeFrequency:a}),m=P(t);return r?m.slice(0,r):m}function F(e,n){let s=L(e,{scope:n.scope}).filter(i=>v(i)&&!e.isIgnored(i.relativePath)).filter(i=>p(i)>=n.minLoc);return typeof n.scanLimit=="number"&&n.scanLimit>0&&s.sort((i,r)=>p(r)-p(i)||i.relativePath.localeCompare(r.relativePath)),$(s,n.scanLimit)}function v(e){return!e.isFunctionLike||h(e.symbol)?!1:e.kind===null||B.has(e.kind)}function w(e,n,s){let i=[];for(let a of n){let o=G(e,a,s);o&&i.push({signature:o,definition:a,fn:z(a)})}let r=new Map;for(let a of i)r.set(a.signature,(r.get(a.signature)??0)+1);let c=new Map;for(let a of i){let o=C(a.fn.loc),t=(r.get(a.signature)??0)>s.maxShapeFrequency,m=t?M(e,a.definition):null;if(t&&!m)continue;let u=t?`${a.signature}\0body\0${m}`:`${a.signature}\0band\0${o}`,l=c.get(u)??{signature:a.signature,locBand:o,exactBody:t,functions:[]};l.functions.push(a.fn),c.set(u,l)}return[...c.values()]}function z(e){return{symbol:e.symbol,shortName:b(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:p(e)}}function P(e){let n=[];for(let s of e)s.functions.length>=2&&n.push(s);return n.sort((s,i)=>{let r=i.functions.length-s.functions.length;if(r!==0)return r;let c=s.functions.reduce((o,t)=>o+t.loc,0);return i.functions.reduce((o,t)=>o+t.loc,0)-c}),n}function C(e){return e<=5?"<=5":e<=20?"6-20":">20"}function G(e,n,s){if(s.semantic){let c=D(e,n);if(c)return c}let i=k(n.documentation),r=i?A(i):null;return r||E(N(e,n.relativePath,n.startLine,n.endLine,n.leaf),n.leaf)}function k(e){return x(y(e))}function N(e,n,s,i,r){let c=d(e,n);if(!c)return null;let a=c.split(/\r?\n/),o=O(a,s,i,r);for(let t of o){let m=Math.min(a.length-1,Math.max(t,t+4)),u="";for(let l=t;l<=m;l+=1){let f=a[l]?.trim();if(f&&(u=u?`${u} ${f}`:f,q(u)))return u}if(u&&u.includes("("))return u}return null}function q(e){let n=e.replace(/\s+/g," ").trim();return!n.includes("(")||S(n)>0?!1:/[;{]$/.test(n)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(n)||/\)\s*As\s+.+$/i.test(n)}function A(e){if(!e||!e.trim())return null;let n=e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),s=n.indexOf("(");return s===-1||(n=n.slice(s),n=n.replace(/\s+/g,"").toLowerCase(),n.length<3)?null:n}function E(e,n){if(!e||!e.trim())return null;let s=e.replace(/\s+/g," ").trim(),i=s.indexOf("(");if(i===-1)return null;let r=s.slice(0,i),a=new RegExp(`\\b${g(n)}\\b`,"i").exec(r);a&&typeof a.index=="number"&&(r=r.slice(0,a.index)),r=r.replace(/\b(public|private|protected|internal|final|static|abstract|sealed|virtual|override|async|suspend|inline|constexpr|consteval|constinit|const|pub|fn|function|def|sub|friend|shared|readonly|new|open|partial|export)\b/gi," ").replace(/\s+/g," ").trim();let o=R(s.slice(i)).replace(/\)\s*=\s*[\s\S]*$/,")").replace(/\s+throws\s+[^={]+$/i,"").replace(/\s+where\s+.+$/i,"").replace(/\s+/g," ").trim();if(!o.startsWith("("))return null;let t=`${r?`${r} `:""}${o}`.replace(/\s+/g,"").toLowerCase();return t.length>=3?t:null}function R(e){let n=0,s=0,i=0,r=0,c=null,a=!1;for(let o=0;o<e.length;o+=1){let t=e[o];if(c){if(a){a=!1;continue}if(t==="\\"){a=!0;continue}t===c&&(c=null);continue}if(t==='"'||t==="'"||t==="`"){c=t;continue}if(t==="(")n+=1;else if(t===")")n=Math.max(0,n-1);else if(t==="[")i+=1;else if(t==="]")i=Math.max(0,i-1);else if(t==="<")r+=1;else if(t===">")r=Math.max(0,r-1);else if(t==="{"){if(n===0&&i===0&&r===0)return e.slice(0,o);s+=1}else if(t==="}")s=Math.max(0,s-1);else if(t==="="&&e[o+1]===">"&&n===0&&s===0&&i===0&&r===0)return e.slice(0,o)}return e}function O(e,n,s,i){let r=g(i),c=new RegExp(`\\b${r}\\b\\s*\\(`,"i"),a=new RegExp(`\\bdef\\s+${r}\\b`,"i"),o=[],t=new Set,m=Math.max(0,Math.min(n,e.length-1)),u=Math.max(m,Math.min(e.length-1,Math.max(s,n+4)));for(let l=m;l<=u;l+=1){let f=e[l]??"";(c.test(f)||a.test(f))&&!t.has(l)&&(t.add(l),o.push(l))}for(let l=0;l<e.length;l+=1){let f=e[l]??"";(c.test(f)||a.test(f))&&!t.has(l)&&(t.add(l),o.push(l))}return o}export{X as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6GZ7LM7S.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{c as p}from"./chunk-HLRWOFXC.js";import{b as B}from"./chunk-B75HZHUP.js";import{a as m}from"./chunk-BGBBVSH4.js";import{d as f,t as g}from"./chunk-OO6S4ECV.js";import{b as y}from"./chunk-NLVKD45E.js";import{z as d}from"./chunk-WFRZGMWJ.js";import{createHash as C}from"crypto";var b=3;function w(n,t={}){let{scope:e,maxLoc:o=15,minLoc:i=b,limit:r,scanLimit:a}=t,l=p(n),u=L(n,{scope:e,maxLoc:o,scanLimit:a}).map(s=>h(n,s,l,i)).filter(s=>s!==null),c=I(u);return r?c.slice(0,r):c}function H(n,t,e={}){let{scope:o,maxLoc:i=15,minLoc:r=b,scanLimit:a}=e,l=p(n),u=L(n,{scope:o,maxLoc:i,scanLimit:a}).map(s=>h(n,s,l,r)).filter(s=>s!==null),c=u.find(s=>s.symbol===t);return c?u.filter(s=>s.symbol!==c.symbol&&s.normalizedBody===c.normalizedBody&&s.file!==c.file).sort(z).map(({normalizedBody:s,...S})=>S):[]}function A(n){let t=E(n);return y(t).replace(/\s+/g,"")}function I(n){let t=new Map;for(let o of n){if(o.normalizedBody.length<8)continue;let i=W(o.normalizedBody),r=t.get(i)??[];r.push(o),t.set(i,r)}let e=[];for(let[o,i]of t){let r=new Set(i.map(l=>l.file));if(i.length<2||r.size<2)continue;let a=[...i].sort(z).map(({normalizedBody:l,...u})=>u);e.push({hash:o,canonical:a[0],functions:a})}return e.sort((o,i)=>{let r=i.functions.length-o.functions.length;if(r!==0)return r;let a=D(i)-D(o);return a!==0?a:o.canonical.file.localeCompare(i.canonical.file)}),e}function L(n,t){let e=g(n,{scope:t.scope}).filter(o=>o.isFunctionLike&&!n.isIgnored(o.relativePath)).filter(o=>m(o)<=t.maxLoc);return e.sort((o,i)=>m(i)-m(o)||o.relativePath.localeCompare(i.relativePath)),B(e,t.scanLimit)}function h(n,t,e,o){let i=x(n,t);if(!i||P(i)<o)return null;let r=v(n,t);return r?{symbol:t.symbol,shortName:f(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:m(t),ageCommits:e?.get(t.relativePath)?.commitsAgo??null,normalizedBody:r}:null}function v(n,t){let e=x(n,t);return e&&A(e)||null}function x(n,t){let e=d(n,t.relativePath);return e.length===0?null:e.slice(t.startLine,t.endLine+1).join(`
|
|
2
|
+
`)}function E(n){let t=n.indexOf("{"),e=n.lastIndexOf("}");if(t>=0&&e>t)return n.slice(t+1,e);let o=n.indexOf("=>");return o>=0?n.slice(o+2).replace(/;+\s*$/,""):n}function P(n){return E(n).split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0).length}function W(n){return C("sha256").update(n).digest("hex").slice(0,16)}function z(n,t){let e=n.ageCommits??-1;return(t.ageCommits??-1)-e||n.file.localeCompare(t.file)||n.startLine-t.startLine}function D(n){return n.functions.reduce((t,e)=>t+e.loc,0)}export{w as a,H as b,A as c,I as d,v as e,x as f,E as g};
|
|
3
|
+
//# sourceMappingURL=chunk-753JWTUH.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{m as f}from"./chunk-2Y7YX54K.js";import{a as d}from"./chunk-YSUD2S7T.js";import{d as s,h as u,p as m,q as g}from"./chunk-OO6S4ECV.js";import{y as c}from"./chunk-WFRZGMWJ.js";function E(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:y(a,t?.display_name??null,n.symbol),source:S(e,n.relativePath,n.startLine,n.endLine)}],b=f(e,n,{semantic:i.semantic}).map(l=>({relativePath:l.file,line:l.line,enclosingSymbol:l.enclosingSymbol,enclosingShort:l.enclosingSymbol?s(l.enclosingSymbol):"(top-level)"}));return{definitions:o,referencedBy:b}}function S(e,r,i,n){let t=c(e,r);if(!t)return null;let o=t.split(`
|
|
2
|
+
`).slice(i,n+1).join(`
|
|
3
|
+
`).trimEnd();return o.length>0?o:null}function y(e,r,i){let n=m(e);if(n&&!p(n))return n;let t=(r??"").trim();return t?u(i)&&!t.endsWith("()")?`${t}()`:t:s(i)}function p(e){return e.startsWith("undefined")||e.includes("|")||e.includes("```")}export{E as a};
|
|
4
|
+
//# sourceMappingURL=chunk-7II7NFRV.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as g}from"./chunk-MZB3DTHW.js";import{a as d}from"./chunk-3I34FZ6R.js";import{a as c}from"./chunk-2Y7YX54K.js";import{d as p}from"./chunk-OO6S4ECV.js";import{f as o}from"./chunk-NLVKD45E.js";import{B as u}from"./chunk-MCNWCJYL.js";function F(r,a={}){let{scope:l,limit:s=30,scanLimit:b}=a,f=new d(r);return g({candidates:()=>f.productionCallableDefinitions({scope:l,files:a.files,minLoc:2,excludeRootedSymbols:!0,requireFunctionLikeSymbol:!0}),filterCandidate:e=>y(e.relativePath),scanLimit:b,profile:{name:"unused-params"},evaluate:e=>{let n=o(r,e.relativePath)?.callables.find(t=>t.startLine===e.startLine&&t.endLine===e.endLine);if(!n||n.params.length===0||n.params.some(t=>!t.simple)||n.paramsEndLine>=n.endLine)return null;let L=c(r,e.relativePath),m=[];for(let t=n.params.length-1;t>=0;t--){let i=n.params[t];if(i.name===""||i.name.startsWith("_")||h(L.get(i.name),n.paramsEndLine,n.endLine))break;m.unshift(i.name)}return m.length===0?null:{symbol:e.symbol,shortName:p(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,paramCount:n.paramCount,unusedTrailing:m}},orderResults:(e,n)=>n.unusedTrailing.length-e.unusedTrailing.length||e.file.localeCompare(n.file)||e.startLine-n.startLine,limit:s})}function y(r){let a=u(r);return a==="typescript"||a==="tsx"||a==="javascript"}function h(r,a,l){return r?r.some(s=>s>a&&s<=l):!1}export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7RAS466A.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as ie,b as N,e as V,f as j,g as E,h as te,i as re}from"./chunk-KMVGRIO2.js";import{b as _}from"./chunk-B75HZHUP.js";import{a as q}from"./chunk-3I34FZ6R.js";import{a as ne}from"./chunk-UO4IADXJ.js";import{a as D}from"./chunk-YSUD2S7T.js";import{d as I,e as K,h as $}from"./chunk-OO6S4ECV.js";import{a as B}from"./chunk-NLVKD45E.js";import{a as Y}from"./chunk-64MNV6AB.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-WFRZGMWJ.js";function Ie(e,n,t={}){let{minSimilarity:i=.4,limit:r=20}=t,s=Ee(e,n,{semantic:t.semantic!==!1});if(!s)return[];if(!$(s.symbol))return[];if(s.callees.size===0)return se(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"});let a=we(e,s,i,{scanLimit:t.scanLimit,semantic:t.semantic!==!1});return a.length>0?a.slice(0,r):se(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"})}function vn(e,n,t,i={}){let r=D(e,n),s=D(e,t);if(!r||!s)return null;let a=Ie(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:ve(a)}}function ve(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 we(e,n,t,i){let r=G(e).calleeIndex({minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),s=_e(n,r.corpus),a=Pe(s,r),l=Me(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=ce(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 Me(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 ce(e,n,t,i){let r=Le(e,n,t,i);if(!Re(r,i))return null;let{similarity:s,significantShared:a,trivialShared:l}=r,c=a.length>0?a:l,m=pe(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 Te(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 Le(e,n,t,i){return i.magnitudeA===void 0||i.magnitudeB===void 0?te(e.callees,n.callees,t,{medianIdf:i.medianIdf}):re(e.callees,n.callees,t,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB})}function Re(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 wn(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(ue(F,L)){m&&(p+=1);continue}m&&(u+=1);let R=ce(F,L,b.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:b.medianIdf,magnitudeA:w,magnitudeB:b.weightedMagnitudes[O]});R&&(Ae(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 Mn(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(ue(k,w)){c&&(d+=1);continue}c&&(o+=1),Te(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 ue(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 me=Q({kind:"source-fingerprints",invalidation:ee("source-fingerprints"),serialize:ln,deserialize:on});function Ae(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 Be=["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 Ee(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});return{symbol:i.symbol,file:i.relativePath,callees:ge(s.map(a=>a.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}var ze=z("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),De=z("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function de(e,n){let{minCallees:t,scope:i,excludeSymbol:r,scanLimit:s}=n,a=n.semantic!==!1,l=ze.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=Oe(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 qe(e,n){let{minCallees:t,scope:i,scanLimit:r}=n,s=n.semantic!==!1,a=De.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=Ne(de(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=>de(e,n),calleeIndex:n=>qe(e,n),sourceCorpus:(n={})=>Ce(e,n),sourceIndex:(n={})=>le(e,n),sourceCandidates:(n,t)=>(t.candidateMode??"full")==="target-pruned"?Ye(e,n,{minSimilarity:t.minSimilarity,scanLimit:t.scanLimit}):Je(n,le(e,{scanLimit:t.scanLimit}))}}function Ne(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 Pe(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 Oe(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:ge((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 fe=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)>=fe);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 _e(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>=fe);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 ge(e){return new Set([...e].filter(n=>!je(n)))}function je(e){return Be.some(n=>e.includes(n))}function se(e,n,t){let i=Ke(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=ie(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(),...pe([...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 pe(e,n){let t=e.flatMap(W),i=e.flatMap(S=>ae(S,n)),r=Z(t,Se),s=Z(t,be),a=Z(i,X),l=[...new Set(i.filter(oe))],c=e.filter(S=>{let h=ae(S,n);return h.some(b=>X.has(b))&&h.some(oe)}).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=>ye.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:Ge(d,p)}}function Ge(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 ae(e,n){if(n==="source-tokens")return W(e);let t=K(e);return W(t.length>0?t:Ue(e))}function Ue(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 oe(e){return e.length>3&&!X.has(e)&&!Se.has(e)&&!be.has(e)&&!ye.has(e)&&!He.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"]),Se=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),be=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"]),ye=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),He=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 Ke(e,n){let t=D(e,n);if(!t||!$(t.symbol))return null;let i=Ve(e,t);return i?{symbol:t.symbol,file:t.relativePath,tokens:i}:null}function Ve(e,n){let t=K(n.symbol),i=rn(e,n.relativePath,n.startLine,n.endLine,t),r=ke(i,t);return r.size>0?r:null}var Ze=z("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),We=z("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function he(e){return`${e.scanLimit??""}`}function Ce(e,n={}){let t=Ze.get(e,()=>new Map),i=he(n),r=t.get(i);return r||(r=tn(e,n),t.set(i,r)),r}function le(e,n={}){let t=We.get(e,()=>new Map),i=he(n),r=t.get(i);return r||(r=Xe(Ce(e,n)),t.set(i,r)),r}function Xe(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 Je(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 Ye(e,n,t){let i=A(),r=new q(e),s=Qe(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,en(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=Fe(e,f);return i&&(o=d.length),d},()=>({symbol:n.symbol,definitionCount:g,fingerprintCount:o})).filter(d=>d.symbol!==n.symbol)}function Qe(e,n){return Math.max(2,Math.ceil(e*n))}function en(e,n,t){if(n.length<t)return!1;let i=e.toLowerCase(),r=0;for(let s of n)if(nn(i,s)&&(r+=1,r>=t))return!0;return!1}function nn(e,n){return n==="num"?/\b\d+\b/.test(e):e.includes(n)}function tn(e,n={}){let t=new q(e),{scanLimit:i}=n,r=_(t.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return Fe(e,r)}function Fe(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=an(e,r,l),m=!1,g=null;for(let f of s){let o=sn(f),u=c.get(o),d=u?new Set(u.tokens):null;d||(g??=H(e,r),d=ke(xe(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&&cn(e,r,l,c)}return n.map(r=>i.get(r.symbol)).filter(r=>!!r)}function rn(e,n,t,i,r){let s=H(e,n);return s.length===0?"":xe(s,t,i,r)}function xe(e,n,t,i){if(t>=n&&t-n<=12)return e.slice(n,t+1).join(`
|
|
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&&mn(c)||(a=l,c.trim()===""&&l>s+1))break}return e.slice(s,a+1).join(`
|
|
3
|
+
`)}return e.slice(n,Math.min(e.length,n+8)).join(`
|
|
4
|
+
`)}function sn(e){return`${e.symbol}\0${e.startLine}\0${e.endLine}\0${e.leaf}`}function an(e,n,t){return me.read(e,n,t)??new Map}function on(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 ln(e){let n={entries:[...e.values()].sort((t,i)=>t.key.localeCompare(i.key))};return JSON.stringify(n)}function cn(e,n,t,i){me.write(e,n,t,new Map(i))}function ke(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=un(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 un(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 mn(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}export{Ie as a,vn as b,Me as c,ce as d,wn as e,Mn as f,Ae as g,de as h,qe as i,G as j,Ne as k,Pe as l,fe as m,$e as n,ge as o,pe as p};
|
|
5
|
+
//# sourceMappingURL=chunk-A46JTKTM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as g}from"./chunk-MZB3DTHW.js";import{a as m}from"./chunk-3I34FZ6R.js";import{a as d}from"./chunk-BGBBVSH4.js";import{d as u}from"./chunk-OO6S4ECV.js";function k(n,c={}){let{scope:e,minLoc:t=10,minCallees:a=6,limit:r=20,scanLimit:i}=c,o=new m(n);return g({candidates:()=>o.productionCallableDefinitions({scope:e,minLoc:t,excludeTypesFiles:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:!0}),scanLimit:i,profile:{name:"extract-candidates"},prepare:s=>o.calleeMap(s,{semantic:c.semantic!==!1}),evaluate:(s,l)=>h(s,l.get(s.symbolId)??[],a),orderResults:(s,l)=>l.clusters.length-s.clusters.length||l.loc-s.loc,limit:r})}function h(n,c,e){let t=new Set(c.map(l=>l.symbol));if(t.size<e)return null;let a=S(t,c),r=y(t,a);if(r.length<2)return null;let i=C(r,a);if(i.length===0)return null;let o=u(n.symbol),s=p(o,t.size,r.length,i);return{symbol:n.symbol,shortName:o,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:d(n),totalCallees:t.size,extractionKind:s.extractionKind,actionTier:"signal",evidenceReasons:s.evidenceReasons,recommendation:s.recommendation,clusters:i}}function p(n,c,e,t){let a=Math.max(...t.map(s=>s.callees.length)),r=Math.max(...t.map(s=>s.isolation)),i=[`${c} distinct callees across ${e} co-occurrence cluster(s)`,`${t.length} extractable cluster(s) passed size and isolation thresholds`,`largest extractable cluster has ${a} callees at ${Math.round(r*100)}% isolation`],o=f(n,c,e);return o!==null?{extractionKind:"workflow-orchestration",evidenceReasons:[...i,o],recommendation:"Review the isolated helper group as a possible private or feature-local helper, but keep the orchestration sequence together when it preserves the workflow."}:a>=6?{extractionKind:"broad-helper-cluster",evidenceReasons:[...i,"one isolated helper group is broad enough to deserve a named review"],recommendation:"Review whether the broad helper cluster has a stable concept name before extracting it; avoid creating a bag-of-helpers abstraction."}:{extractionKind:"cohesive-helper-cluster",evidenceReasons:i,recommendation:"Review the isolated callee group as a possible same-file or feature-local helper; extract only if the new name preserves the current behavior."}}function f(n,c,e){if(c>=10)return`callee breadth suggests orchestration: ${c} callees`;if(e>=4)return`multiple disconnected callee groups suggest orchestration: ${e} groups`;let t=b(n);return x.has(t)?`caller verb suggests orchestration: ${t}`:null}function b(n){return n.split(":").pop()?.replace(/\(\)$/,"").replace(/[^A-Za-z0-9_]/g,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\s-]+/).filter(Boolean)[0]?.toLowerCase()??""}var x=new Set(["apply","build","check","collect","create","diff","execute","find","handle","load","prepare","process","render","resolve","run","select","sync","update","validate","verify","write"]);function S(n,c){let e=new Map;for(let a of n)e.set(a,new Set);let t=new Map;for(let a of c){let r=t.get(a.chunkId);r||(r=new Set,t.set(a.chunkId,r)),r.add(a.symbol)}for(let a of t.values()){let r=[...a];for(let i=0;i<r.length;i++)for(let o=i+1;o<r.length;o++)e.get(r[i]).add(r[o]),e.get(r[o]).add(r[i])}return e}function y(n,c){let e=new Set,t=[];for(let a of n){if(e.has(a))continue;let r=new Set,i=[a];for(;i.length>0;){let o=i.pop();if(!e.has(o)){e.add(o),r.add(o);for(let s of c.get(o)??[])e.has(s)||i.push(s)}}t.push(r)}return t}function C(n,c){return n.filter(e=>e.size>=3).map(e=>v(e,n,c)).filter(e=>e.isolation>.5).sort((e,t)=>t.isolation-e.isolation)}function v(n,c,e){let t=new Set;for(let o of c)if(o!==n)for(let s of o)t.add(s);let a=0;for(let o of n)for(let s of e.get(o)??[])t.has(s)&&a++;let r=n.size*t.size,i=r>0?1-a/r:1;return{callees:[...n].map(u),isolation:i}}export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-AAMZRDJT.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as $e}from"./chunk-7RAS466A.js";import{a as Se}from"./chunk-6EVORGCB.js";import{a as se,c as ae,d as ce,e as D}from"./chunk-VLSI5MYU.js";import{a as Ce}from"./chunk-YCVYOV4A.js";import{a as ye}from"./chunk-62Y3PC27.js";import{a as be}from"./chunk-C2QSK7E7.js";import{a as ge}from"./chunk-2EU6WVR3.js";import{a as he}from"./chunk-CS3FXTUC.js";import{a as fe}from"./chunk-LT6AHYVY.js";import{a as ue}from"./chunk-AAMZRDJT.js";import{b as re}from"./chunk-SOCS3467.js";import{a as ne,b as oe}from"./chunk-753JWTUH.js";import{a as Q,b as X,c as ee,g as M,h as K}from"./chunk-RPMT6MTX.js";import{a as ie,b as F,e as te}from"./chunk-5UKDCXVC.js";import{b as de}from"./chunk-JQ2PCFZW.js";import{a as B,c as J,d as Y,e as Z}from"./chunk-U6BJVXWQ.js";import{a as V}from"./chunk-HLRWOFXC.js";import{a as me,e as pe}from"./chunk-A46JTKTM.js";import{a as le}from"./chunk-WN6XEYVX.js";import{a as W}from"./chunk-3I34FZ6R.js";import{f as T,g as A}from"./chunk-NLRWGGPY.js";import{e as q}from"./chunk-2Y7YX54K.js";import{e as R,f as U,g as N}from"./chunk-OO6S4ECV.js";import{a as O}from"./chunk-NLVKD45E.js";import{e as H}from"./chunk-MCNWCJYL.js";import{s as z}from"./chunk-WFRZGMWJ.js";import{createHash as ei}from"crypto";import{existsSync as _}from"fs";function we(e){let[i,t]=j(e,":"),o=i||"unknown",n=(a={})=>{let s=a.actionTier??Me(o);return{sourceAnalyzer:o,actionTier:s,rootCauseKey:a.rootCauseKey??(t||e),label:a.label??`${o} finding`,relatedFiles:a.relatedFiles??[],why:a.why??[],remediation:a.remediation??Ke(s,o),file:a.file}};if(!t)return n({rootCauseKey:e,why:["Baseline identity did not include analyzer payload."]});if(["dead","isolated","extract","wrapper","passthrough","stale"].includes(o)){let[a,s]=j(t,":");return n({file:a,relatedFiles:a?[a]:[],rootCauseKey:s?`${a}:${s}`:t,label:`${o} finding`,why:s?[`Baseline subject: ${s}.`]:[]})}if(o==="cycle"){let a=t.split(">").filter(Boolean);return n({relatedFiles:a,rootCauseKey:t,label:"cycle finding",why:a.length>0?[`Cycle path: ${a.join(" > ")}.`]:[]})}if(o==="similar"){let a=t.split("|").filter(Boolean);return n({relatedFiles:[],rootCauseKey:t,label:"similarity finding",why:a.length>0?[`Similar symbols: ${a.join(" | ")}.`]:[]})}if(o==="drift"){let[a,s]=j(t,":"),[c,d]=j(s,":");return n({actionTier:a==="unused-import"?"direct":"signal",file:c,relatedFiles:[...new Set([c,d].filter(Boolean))],rootCauseKey:t,label:`${a||"drift"} finding`,why:[...a?[`Drift kind: ${a}.`]:[],...d?[`Related dependency: ${d}.`]:[]]})}return n({why:["Baseline analyzer prefix is not recognized by this diff-gate version."]})}function Me(e){switch(e){case"dead":case"isolated":case"cycle":case"passthrough":return"direct";case"similar":case"extract":case"wrapper":case"stale":return"signal";default:return"signal"}}function Ke(e,i){return e==="direct"?`Fix the new ${i} baseline finding, or knowingly accept it via health --write-baseline.`:`Review the new ${i} baseline signal; fix it if it reflects real debt, or knowingly accept it via health --write-baseline.`}function j(e,i){let t=e.indexOf(i);return t<0?[e,""]:[e.slice(0,t),e.slice(t+i.length)]}import{existsSync as Le,readFileSync as Pe,writeFileSync as _e}from"fs";import{isAbsolute as He,join as ze}from"path";var Oe=25e3,Ue=2500,qe=2500;function We(e){let i=be(e);return i.symbols>=Oe||i.documents>=Ue?qe:void 0}var Ve=".scipquery-baseline.json";function E(e,i){return i&&He(i)?i:ze(e.config.projectRoot,i??Ve)}function De(e,i={}){let{scope:t}=i,o=We(e),n=[],a=de(e,{scope:t,...D.dead,scanLimit:o});for(let s of a.symbols)T(e,s.relativePath)||A(e,s.symbol,s.relativePath)||s.kind==="dead-code"&&n.push(`dead:${s.relativePath}:${s.shortName}`);for(let s of he(e,{scope:t,...D.isolated,scanLimit:o}))T(e,s.relativePath)||A(e,s.symbol,s.relativePath)||n.push(`isolated:${s.relativePath}:${s.shortName}`);for(let s of le(e,{scope:t}))s.kind==="real"&&n.push(`cycle:${Je(s.path)}`);for(let s of pe(e,{scope:t,...D.similar,scanLimit:o}))n.push(`similar:${[s.symbolA,s.symbolB].sort().join("|")}`);for(let s of ne(e,{scope:t,...D.duplicateBodies,scanLimit:o}))n.push(`duplicate-bodies:${s.hash}:${s.functions.map(c=>c.symbol).sort().join("|")}`);for(let s of ue(e,{scope:t,...D.extract,scanLimit:o}))n.push(`extract:${s.relativePath}:${s.shortName}`);for(let s of Ce(e,{scope:t,...D.wrappers,scanLimit:o}))n.push(`wrapper:${s.file}:${s.shortName}`);for(let s of ge(e,{scope:t,...D.passthroughs,scanLimit:o}))n.push(`passthrough:${s.file}:${s.shortName}`);for(let s of ye(e,{scope:t,...D.stale,scanLimit:o}))n.push(`stale:${s.file}:${s.shortName}`);for(let s of fe(e,{scope:t,...D.drift,includePatternDeviations:!1,limit:Number.POSITIVE_INFINITY}).results)n.push(`drift:${s.kind}:${s.file}:${s.dep}`);return[...new Set(n)].sort()}function Je(e){if(e.length===0)return"";let i=0;for(let t=1;t<e.length;t++)e[t]<e[i]&&(i=t);return[...e.slice(i),...e.slice(0,i)].join(">")}function qi(e,i={}){let t=De(e,{scope:i.scope}),o=E(e,i.path);return _e(o,JSON.stringify({version:1,findings:t},null,2)+`
|
|
2
|
+
`),{path:o,findingCount:t.length}}function ke(e,i={}){let t=E(e,i.path);if(!Le(t))throw new Error(`No baseline found at ${t}. Create one with: scip-query health --write-baseline`);let o=JSON.parse(Pe(t,"utf-8")),n=new Set(o.findings??[]),a=De(e,{scope:i.scope}),s=new Set(a);return{baselinePath:t,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}import{existsSync as Ye,mkdirSync as Ji,readdirSync as Ze,readFileSync as Qe,writeFileSync as Yi}from"fs";import{createHash as Qi}from"crypto";import{join as L}from"path";var x=L(".scipquery","suppressions");function Xe(e){return L(e,x)}function ve(e){let i=Xe(e);if(!Ye(i))return{suppressions:[],warnings:[]};let t=[],o=[];for(let n of Ze(i).sort()){if(!n.endsWith(".json"))continue;let a=L(i,n),s;try{s=JSON.parse(Qe(a,"utf-8"))}catch{o.push(`${x}/${n}: malformed JSON \u2014 ignored`);continue}if(typeof s!="object"||s===null||Array.isArray(s)){o.push(`${x}/${n}: not a suppression object \u2014 ignored`);continue}let c=s;if(typeof c.reason!="string"||c.reason.trim()===""){o.push(`${x}/${n}: missing reason \u2014 ignored`);continue}if(!c.id&&!c.check){o.push(`${x}/${n}: needs an id or a check \u2014 ignored`);continue}t.push(c)}return{suppressions:t,warnings:o}}var kt=["echo","incomplete-migration","co-change-partner","twin-partner","coverage-contract","doc-reference","unused-params","new-dead","baseline"];function vt(e,i={}){let t=i.base??"HEAD",{minTogether:o=6,minConfidence:n=.6,maxEchoChecks:a=Number.POSITIVE_INFINITY,maxHelpers:s=Number.POSITIVE_INFINITY,minSimilarity:c=.8,includeBaseline:d=!1,scanLimit:r}=i,f=i.semantic!==!1,m=i.historyMode??"bounded",u=new Set(i.skip??[]),h=ee(e,{base:t}),p=X(e,{base:t,plan:h}),y=p.changedFiles,S=new Set(y),l=new Set(h.changedFileLines),w=new Set([...S,...l]),$=M(e.config.projectRoot,t,K(h,y)),C=Ri(e.config.projectRoot,t,h,$),g={base:t,changedFiles:y,changedSymbols:p.changedSymbols.length,checksRun:[],skipped:[],suppressed:[],findings:[],attributionNotes:p.attributionNotes,rootCauseGroups:[],note:p.summary.note};if(y.length===0)return g;let k=(G,Ee)=>{if(u.has(G)){g.skipped.push({check:G,reason:"skipped via --skip"});return}let Ie=g.findings.length,Ne=g.skipped.length,Be=g.checksRun.length;z(`diff-gate.check.${G}`,Ee,()=>({check:G,changedFiles:y.length,changedSymbols:p.changedSymbols.length,findingsAdded:g.findings.length-Ie,skippedAdded:g.skipped.length-Ne,checksRunAdded:g.checksRun.length-Be}))};return k("echo",()=>oi(e,p.changedSymbols,S,C,a,c,r,f,g)),k("incomplete-migration",()=>di(e,t,h,s,r,f,$,g)),k("co-change-partner",()=>fi(e,w,o,n,m,g)),k("twin-partner",()=>ui(e,p.changedSymbols,S,r,g)),k("coverage-contract",()=>hi(e,w,g)),k("doc-reference",()=>bi(e,S,l,h.changedRanges,h.renamedFiles,g)),k("unused-params",()=>wi(e,y,g)),k("new-dead",()=>Di(e,p.changedSymbols,C,g)),d&&k("baseline",()=>Ai(e,g)),ti(g,[...e.config.suppressions??[],...ve(e.config.projectRoot).suppressions]),g.rootCauseGroups=ii(g.findings),g}function Ft(e){return e.checksRun.length===0&&e.note===Q}function Rt(e){return e.filter(i=>!i.advisory)}function ii(e){let i=new Map;for(let t of e){let o=t.groupKey??`${t.check}:${t.id}`,n=i.get(o);n||(n={groupKey:o,check:t.check,severity:t.severity,actionTier:t.actionTier,sourceAnalyzer:t.sourceAnalyzer,rootCauseKey:t.rootCauseKey,count:0,findingIds:[],files:new Set,relatedFiles:new Set,message:t.message,remediation:t.remediation},i.set(o,n)),n.count+=1,n.findingIds.push(t.id),n.severity=Ge(n.severity,t.severity),n.actionTier=je(n.actionTier,t.actionTier),t.file&&n.files.add(t.file);for(let a of t.relatedFiles??[])n.relatedFiles.add(a)}return[...i.values()].map(t=>({...t,files:[...t.files].sort(),relatedFiles:[...t.relatedFiles].sort()})).sort((t,o)=>o.count-t.count||I(o.severity)-I(t.severity)||t.groupKey.localeCompare(o.groupKey))}function Ge(e,i){return I(i)>I(e)?i:e}function I(e){return e==="error"?2:e==="warning"?1:0}function je(e,i){return e?i&&Fe(i)>Fe(e)?i:e:i}function Fe(e){return e==="direct"?2:e==="signal"?1:0}function ti(e,i){if(i.length===0||e.findings.length===0)return;let t=[];for(let o of e.findings){let n=i.find(a=>ni(a,o));n?e.suppressed.push({finding:o,suppression:n}):t.push(o)}e.findings=t}function ni(e,i){return!e.reason||e.reason.trim()===""||e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()||e.id&&e.id!==i.id&&!i.legacySuppressionIds?.includes(e.id)||e.check&&e.check!==i.check||e.file&&e.file!==i.file?!1:!!(e.id||e.check)}function v(e,i){e.findings.push({...i,suppressionHint:`scip-query: ignore ${i.check} ${i.id} -- <reason>`})}function oi(e,i,t,o,n,a,s,c,d){d.checksRun.push("echo");for(let r of i.slice(0,n)){if(!N(r.symbol)||o(r))continue;let f=oe(e,r.symbol,{maxLoc:15,scanLimit:s}).filter(l=>!t.has(l.file)).slice(0,5).map(l=>({otherFile:l.file,otherShort:l.shortName,otherSymbol:l.symbol,similarity:1,similarityBasis:"exact-body",sharedEvidence:[`exact normalized body (${l.loc} LOC)`]}));if(f.length>0){let l=b("echo",r.symbol,r.file),w=b("echo",r.symbol,r.file,...f.map(C=>`${C.otherSymbol}|${C.otherFile}`).sort()),$=f[0];v(d,{id:l,legacySuppressionIds:w===l?void 0:[w],groupKey:l,actionTier:"direct",check:"echo",severity:"warning",evidence:"heuristic",confidence:1,file:r.file,symbol:r.symbol,relatedFiles:[...new Set(f.map(C=>C.otherFile))].sort(),sourceAnalyzer:"duplicate-bodies",rootCauseKey:`${r.symbol}:${$.otherSymbol}`,message:Te(r,f),why:Ae(r,f),remediation:xe("direct",r.shortName,$.otherShort)});continue}let m=me(e,r.symbol,{minSimilarity:a,limit:5,scanLimit:s,semantic:c,sourceCandidateMode:"target-pruned"}),u=[];for(let l of m){let w=l.fileA===r.file?l.fileB:l.fileA,$=l.fileA===r.file?l.shortNameB:l.shortNameA,C=l.fileA===r.file?l.symbolB:l.symbolA;t.has(w)||u.push({otherFile:w,otherShort:$,otherSymbol:C,similarity:l.similarity,similarityBasis:l.similarityBasis??"callees",sharedEvidence:l.sharedCallees})}if(u.length===0)continue;let h=u[0],p=b("echo",r.symbol,r.file,...u.map(l=>`${l.otherSymbol}|${l.otherFile}`).sort()),y=b("echo",r.symbol,r.file),S=ri(r,u);v(d,{id:y,legacySuppressionIds:p===y?void 0:[p],groupKey:y,actionTier:S,check:"echo",severity:"warning",evidence:"heuristic",confidence:h.similarity,file:r.file,symbol:r.symbol,relatedFiles:[...new Set(u.map(l=>l.otherFile))].sort(),message:Te(r,u),why:Ae(r,u),remediation:xe(S,r.shortName,h.otherShort)})}i.length>n&&d.skipped.push({check:"echo",reason:`echo check capped at ${n} of ${i.length} changed symbols`})}function ri(e,i){return i.some(o=>si(e.symbol,o))?"direct":"signal"}function si(e,i){if(i.similarityBasis==="exact-body")return!0;if(i.similarityBasis!=="source-tokens"||i.similarity<.98||i.sharedEvidence.length>8)return!1;let t=R(e),o=R(i.otherSymbol);return!t||!o?!1:t===o?!0:li(i.sharedEvidence)?!1:ai(t,o)}function ai(e,i){let t=Re(e),o=Re(i);if(t.length===0||o.length===0)return!1;let n=new Set(o),a=t.filter(s=>n.has(s)).length;return a>=2&&a/Math.min(t.length,o.length)>=.5}function Re(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(i=>i.toLowerCase()).filter(i=>i.length>=2)}var ci=new Set(["bytes","crypto","hex","num","random","secret","to","token"]);function li(e){return e.length>=3&&e.every(i=>ci.has(i.toLowerCase()))}function Te(e,i){let t=i[0],o=Math.round(t.similarity*100);return i.length===1?`${e.shortName} (${e.file}) is ${o}% similar to established ${t.otherShort} (${t.otherFile})`:`${e.shortName} (${e.file}) resembles ${i.length} established symbol(s); strongest is ${o}% similar to ${t.otherShort} (${t.otherFile})`}function Ae(e,i){let t=[`${e.shortName} was changed in this diff.`];for(let o of i.slice(0,3))t.push(`${o.otherShort} is outside this diff and scored ${Math.round(o.similarity*100)}% similar by ${o.similarityBasis} evidence.`),t.push(`Shared evidence: ${o.sharedEvidence.slice(0,5).join(", ")||"(none listed)"}.`);return i.length>3&&t.push(`${i.length-3} additional similar match(es) grouped into this finding.`),t}function xe(e,i,t){return e==="direct"?`Extract or reuse the shared behavior with ${t}, or keep the duplicate with a suppression reason.`:`Review whether ${i} is intentionally parallel to the established implementation(s); extract shared behavior only if the product semantics match.`}function di(e,i,t,o,n,a,s,c){let d=Se(e,{base:i,maxHelpers:o,diffPlan:t,scanLimit:n,semantic:a,baseContentAt:s});if(!d.available){c.skipped.push({check:"incomplete-migration",reason:"no git history"});return}c.checksRun.push("incomplete-migration"),d.note&&c.skipped.push({check:"incomplete-migration",reason:d.note});for(let r of d.findings){let f=r.leftovers.map(l=>`${l.shortName} (${l.file}, ${Math.round(l.containment*100)}% helper / ${Math.round(l.siteCoverage*100)}% site, ${l.migrationScope})`).join(", "),m=r.leftovers.map(l=>`${l.shortName}: ${l.migrationScope} (${l.migrationScopeReasons[0]})`).join("; "),u=[...r.migratedFiles,...r.leftovers.map(l=>l.file)],h=r.leftovers.length===0?void 0:Math.max(...r.leftovers.map(l=>Math.min(l.containment,l.siteCoverage))),p=r.leftovers.some(l=>l.migrationScope==="possible-subtype"),y=b("incomplete-migration",r.helperSymbol,r.helperFile,u.join("|")),S=b("incomplete-migration",r.helperSymbol,r.helperFile);v(c,{id:S,legacySuppressionIds:y===S?void 0:[y],check:"incomplete-migration",severity:"warning",evidence:"heuristic",confidence:h,file:r.helperFile,symbol:r.helperSymbol,relatedFiles:u,message:`new helper ${r.helperShortName} (${r.helperFile}) is wired into ${r.migratedFiles.length} file(s), but ${r.leftovers.length} similar un-migrated site(s) remain: ${f}`,why:[`${r.helperShortName} is new in this diff and already referenced by ${r.migratedFiles.join(", ")}.`,`Helper shape: ${r.helperShape}; ${r.specificHelperCalleeCount}/${r.helperCalleeCount} helper callees are specific enough to score.`,`Unchanged site(s) still contain the helper's callee pattern: ${f}.`,`Migration scope hints: ${m}.`],remediation:p?`Migrate same-scope sites to ${r.helperShortName}; review possible subtype/variant sites before applying the helper.`:`Migrate the remaining sites to ${r.helperShortName}, or confirm they are intentionally different.`})}}function fi(e,i,t,o,n,a){let s=V(e,{historyMode:n}).directionalCoChangePairsForFiles(i,{minTogether:t,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,d;for(let r of s){let f=i.has(r.fileA),m=i.has(r.fileB);if(f===m)continue;let u=f?r.fileA:r.fileB,h=f?r.fileB:r.fileA,p=f?r.changesA:r.changesB,y=p>0?r.together/p:0;if(y<o||B(h)||B(u)||!_(`${e.config.projectRoot}/${h}`))continue;let S=`${u}|${h}`;if(c.has(S))continue;c.add(S);let l=b("co-change-partner",u,h,String(r.together)),w=b("co-change-partner",u,h),$=J(u,h),C=Y({fileA:u,fileB:h,together:r.together,confidence:y,commitScope:r.commitScope,recency:r.recency,subjectContext:r.subjectContext},$,(d??=Z(e))(u,h)),g=[u,h].sort().join("|");a.findings.push({id:w,legacySuppressionIds:l===w?void 0:[l],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:r.commitScope,recency:r.recency,focusedTogether:r.focusedTogether,broadTogether:r.broadTogether,broadCommitRatio:r.broadCommitRatio,lastTogetherAt:r.lastTogetherAt,recentTogether:r.recentTogether,subjectContext:r.subjectContext,...C?{declaredCouplingSuggestion:C}:{},message:`${u} changed, but ${h} did not \u2014 they change together ${r.together}x (${Math.round(y*100)}% of the time)`,why:[`${u} is in this diff and ${h} is not.`,`Git history shows ${r.together} co-change(s), which is ${Math.round(y*100)}% of changes to the edited side.`,`History context: ${gi(r)}.`,`Subject context: ${mi(r.subjectContext)}.`,...pi(r),`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 ui(e,i,t,o,n){n.checksRun.push("twin-partner");let a=re(e,{scanLimit:o}).filter(d=>d.relationship==="divergent"||d.relationship==="identical");if(a.length===0)return;let s=new Map;for(let d of a)for(let r of d.members)s.set(r.symbol,d);let c=new Set;for(let d of i){if(!N(d.symbol))continue;let r=s.get(d.symbol);if(!r)continue;let f=r.members.filter(p=>p.symbol!==d.symbol&&!t.has(p.file));if(f.length===0)continue;let m=[d.symbol,...f.map(p=>p.symbol)].sort().join("|");if(c.has(m))continue;c.add(m);let u=f[0],h=b("twin-partner",d.symbol,d.file,u.symbol);v(n,{id:h,groupKey:`twin-partner:${m}`,check:"twin-partner",severity:"warning",evidence:"heuristic",actionTier:"signal",advisory:!0,confidence:r.relationship==="identical"?1:Math.max(0,1-r.maxDivergence),file:d.file,symbol:d.symbol,relatedFiles:f.map(p=>p.file).sort(),sourceAnalyzer:"twin-drift",rootCauseKey:m,message:`${d.shortName} (${d.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:[`${d.symbol} is in this diff.`,`${u.symbol} shares its (near-)name and is classified '${r.relationship}' with it, but ${u.file} is not in this diff.`,r.relationship==="divergent"?`The two bodies already diverge (~${Math.round(r.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 ${d.shortName}/${u.shortName} into one helper, or confirm the twin should diverge on purpose.`})}}function hi(e,i,t){t.checksRun.push("coverage-contract");let o=e.config.coverageContracts??[];for(let n of o){if(!ae(n,i))continue;let a=se(e,n);if(a.status==="ok")continue;let s=b("coverage-contract",n.name,n.file);v(t,{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:ce(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 gi(e){return`${e.commitScope}/${e.recency}; ${e.focusedTogether} focused, ${e.broadTogether} broad-sweep (${Math.round(e.broadCommitRatio*100)}% broad), ${e.recentTogether} recent, last ${yi(e.lastTogetherAt)}`}function mi(e){let i=e.subjectLabels.length>0?e.subjectLabels.slice(0,5).join(", "):"none inferred",t=e.issueRefs.length>0?e.issueRefs.slice(0,5).join(", "):"none",o=e.sampleSubjects.length>0?e.sampleSubjects.slice(0,3).map(n=>`"${n}"`).join("; "):"none";return`labels ${i}; refs ${t}; samples ${o}; external issue/PR labels ${e.externalIssueLabelStatus}`}function pi(e){let i=[];return e.commitScope==="broad-sweep"&&i.push("Broad-sweep history is weaker than focused co-edits; confirm this is a real coordination contract."),e.recency==="stale"&&i.push("The pair has no co-change in the recent history window; confirm the coupling still holds."),i}function yi(e){return e<=0?"unknown":new Date(e*1e3).toISOString().slice(0,10)}var P=3;function bi(e,i,t,o,n,a){a.checksRun.push("doc-reference");let s=F.referenceTargets(e,i,o);if(s.size===0)return;let c=new Set(n.map(r=>r.from)),d=[];for(let r of te(e,s))t.has(r.doc)||ie(e,r.doc)||d.push(Ci(e,r,c));for(let r of Si(d))v(a,r)}function Ci(e,i,t){let o=i.citedClaims.length>0?i.citedClaims:F.citationContexts(e,i.doc,i.cited),n=F.classifyCitation(o),a=F.hasLineAnchoredCitation(i.citations),s=i.cited.some(m=>t.has(m)||!_(`${e.config.projectRoot}/${m}`)),c=!(a||s),d=i.cited[0]??"",r=b("doc-reference",i.doc,i.cited.join("|")),f=b("doc-reference",i.doc,d);return{id:f,legacySuppressionIds:r===f?void 0:[r],check:"doc-reference",severity:"warning",evidence:"change-graph",actionTier:n.actionTier,groupKey:`doc-reference:${d}`,rootCauseKey:d,confidence:1,file:i.doc,relatedFiles:i.cited,citationKind:n.citationKind,citationKindReasons:n.reasons,citedClaims:o,...c?{advisory:!0}:{},message:`${i.doc} cites ${i.cited.join(", ")} as ${F.citationKindLabel(n.citationKind)} \u2014 changed in this diff, doc untouched`,why:[`${i.cited.join(", ")} changed in this diff.`,`${i.doc} cites the changed file(s) but was not updated in the same diff.`,...n.reasons.map(m=>`Citation kind evidence: ${m}`),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,i.doc)}}function Si(e){let i=new Map;for(let o of e){let n=o.rootCauseKey??"",a=i.get(n);a?a.push(o):i.set(n,[o])}let t=[];for(let[o,n]of i)n.length<=P?t.push(...n):t.push($i(o,n));return t}function $i(e,i){let t=[...i].sort((f,m)=>(f.file??"").localeCompare(m.file??"")),o=t.slice(0,P).map(f=>({doc:f.file??"",citedClaims:f.citedClaims??[]})),n=t.length-o.length,a=t.every(f=>f.advisory===!0),s=t.reduce((f,m)=>Ge(f,m.severity),"info"),c=t.reduce((f,m)=>je(f,m.actionTier),void 0),d=t.map(f=>f.file??"").filter(f=>f.length>0),r=[...new Set(t.flatMap(f=>[f.id,...f.legacySuppressionIds??[]]))];return{id:b("doc-reference","hub-cluster",e),memberFindingIds:r,check:"doc-reference",severity:s,evidence:"change-graph",actionTier:c,groupKey:`doc-reference:${e}`,rootCauseKey:e,confidence:1,file:o[0]?.doc,relatedFiles:[e],citationCount:t.length,citationExemplars:o,suppressedCount:n,...a?{advisory:!0}:{},message:`${e} is cited by ${t.length} doc(s) changed in this diff, doc(s) untouched \u2014 showing ${o.length} example(s), ${n} more damped`,why:[`${e} changed in this diff.`,`${t.length} doc(s) cite it but were not updated in the same diff: ${d.join(", ")}.`,...o.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 (${P}) \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 ${o.length} example doc(s) above; ${t.length} total doc(s) cite ${e} the same way \u2014 see citationExemplars and memberFindingIds in --json for the complete list.`}}function wi(e,i,t){t.checksRun.push("unused-params");for(let o of $e(e,{files:i,limit:50})){let n=b("unused-params",o.symbol,o.file,o.unusedTrailing.join("|")),a=b("unused-params",o.symbol,o.file);v(t,{id:a,legacySuppressionIds:n===a?void 0:[n],check:"unused-params",severity:"warning",evidence:"heuristic",confidence:.85,file:o.file,startLine:o.startLine,endLine:o.endLine,symbol:o.symbol,message:`${o.shortName} (${o.file}) has trailing unused parameter(s): ${o.unusedTrailing.join(", ")}`,why:[`${o.shortName} is in a changed file.`,`The trailing parameter(s) ${o.unusedTrailing.join(", ")} are not referenced in the function body.`],remediation:"Drop the unused trailing parameters and their call-site arguments."})}}function Di(e,i,t,o){o.checksRun.push("new-dead");let n=new W(e),a=H(e.config.projectRoot),s=a.length>1;for(let c of i){if(t(c)||c.fanIn>0||n.fileKind(c.file)==="test"||T(e,c.file)||A(e,c.symbol,c.file)||Fi(c.symbol))continue;let d=b("new-dead",c.symbol,c.file),r=s&&ki(a,c.file)&&vi(e,c.symbol);v(o,{id:d,check:"new-dead",severity:"warning",evidence:r?"heuristic":"graph-fact",confidence:r?.4:.9,file:c.file,symbol:c.symbol,message:r?`${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:r?[`${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:r?"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 ki(e,i){return e.some(t=>i===t.relativeDir||i.startsWith(`${t.relativeDir}/`))}function vi(e,i){let t=R(i);return t?(q(e).get(t)?.length??0)>1:!1}function Fi(e){if(U(e)!=="type")return!1;let i=R(e);return i.startsWith("_Assert")||i.startsWith("Assert")}function Ri(e,i,t,o){let n=new Map(t.renamedFiles.map(s=>[s.to,s.from])),a=o??M(e,i,K(t));return s=>{let c=n.get(s.file)??s.file,d=R(s.symbol);if(!d)return!1;let r=a(c);return r!==null&&Ti(r,d)}}function Ti(e,i){return new RegExp(`\\b${O(i)}\\b`).test(e)}function Ai(e,i){if(!_(E(e))){i.skipped.push({check:"baseline",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}i.checksRun.push("baseline");let t=ke(e);for(let o of t.newFindings){let n=we(o),a=b("baseline",o);v(i,{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: ${o}`,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 b(e,...i){return`SQ${ei("sha256").update([e,...i].join("\0")).digest("hex").slice(0,12).toUpperCase()}`}export{De as a,qi as b,ke as c,kt as d,vt as e,Ft as f,Rt as g,Ri as h};
|
|
3
|
+
//# sourceMappingURL=chunk-AMPN2VMF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u,c as g}from"./chunk-KMVGRIO2.js";function v(e){let r=[],i=[],s=[];for(let t of e.primitiveGroups)t.values.length!==0&&f(t.bucket,i,s).push(`${t.reasonPrefix}: ${t.values.join(", ")}`);for(let t of e.nameGroups)p(t.names,t.label,e.genericWords,e.stripPrefixes??[],r,f(t.fallbackBucket,i,s));let l=r.length>0,c=i.length>0,o=s.length>0,a=l?c||o?"mixed":"domain-behavior":o?"shared-abstraction":"generic-workflow-scaffolding";return{actionTier:a==="domain-behavior"||a==="mixed"?"signal":"support",evidenceClass:a,reasons:[...r,...s,...i].slice(0,6),recommendation:e.recommendation(a)}}function x(e,r){if(e.size===0||r.size===0)return 0;let l=u(e,r).size/Math.min(e.size,r.size)*Math.min(1,Math.min(e.size,r.size)/(.35*Math.max(e.size,r.size)));return Math.max(g(e,r),l)}function b(e,r){let i=Object.fromEntries(e.map(s=>[s.name,s.count]));for(let s of r)if(Object.entries(s.min).every(([c,o])=>(i[c]??0)>=o))return{pass:!0,reason:s.reason,counts:i};return{pass:!1,reason:"shared tokens did not meet calibrated overlap thresholds",counts:i}}function P(e,r,i){let s=r.map(n=>{let t=n.value(e),d=n.weightedValue?n.weightedValue(e,t):t;return{axis:n,value:t,weighted:d,qualifies:n.qualifies?n.qualifies(e,t):t>0}}),l=s.filter(n=>n.qualifies&&n.axis.reason).map(n=>n.axis.reason(e,n.value)),c=s.filter(n=>n.axis.dominantEligible!==!1).sort((n,t)=>t.weighted-n.weighted)[0],o=c&&c.weighted>0?c.axis.axis:i,a=[...new Set(s.filter(n=>n.qualifies).map(n=>n.axis.axis).concat(l.length>0?[]:[o]))];return{dominantPressure:o,pressureKinds:a,reasons:l}}function
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as u,c as g}from"./chunk-KMVGRIO2.js";function v(e){let r=[],i=[],s=[];for(let t of e.primitiveGroups)t.values.length!==0&&f(t.bucket,i,s).push(`${t.reasonPrefix}: ${t.values.join(", ")}`);for(let t of e.nameGroups)p(t.names,t.label,e.genericWords,e.stripPrefixes??[],r,f(t.fallbackBucket,i,s));let l=r.length>0,c=i.length>0,o=s.length>0,a=l?c||o?"mixed":"domain-behavior":o?"shared-abstraction":"generic-workflow-scaffolding";return{actionTier:a==="domain-behavior"||a==="mixed"?"signal":"support",evidenceClass:a,reasons:[...r,...s,...i].slice(0,6),recommendation:e.recommendation(a)}}function x(e,r){if(e.size===0||r.size===0)return 0;let l=u(e,r).size/Math.min(e.size,r.size)*Math.min(1,Math.min(e.size,r.size)/(.35*Math.max(e.size,r.size)));return Math.max(g(e,r),l)}function b(e,r){let i=Object.fromEntries(e.map(s=>[s.name,s.count]));for(let s of r)if(Object.entries(s.min).every(([c,o])=>(i[c]??0)>=o))return{pass:!0,reason:s.reason,counts:i};return{pass:!1,reason:"shared tokens did not meet calibrated overlap thresholds",counts:i}}function P(e,r,i){let s=r.map(n=>{let t=n.value(e),d=n.weightedValue?n.weightedValue(e,t):t;return{axis:n,value:t,weighted:d,qualifies:n.qualifies?n.qualifies(e,t):t>0}}),l=s.filter(n=>n.qualifies&&n.axis.reason).map(n=>n.axis.reason(e,n.value)),c=s.filter(n=>n.qualifies&&n.axis.dominantEligible!==!1).sort((n,t)=>t.weighted-n.weighted)[0],o=c&&c.weighted>0?c.axis.axis:i,a=[...new Set(s.filter(n=>n.qualifies).map(n=>n.axis.axis).concat(l.length>0?[]:[o]))];return{dominantPressure:o,pressureKinds:a,reasons:l}}function A(e,r){return[...e].filter(i=>i.startsWith(r)).map(i=>i.slice(r.length)).sort()}function E(e){return[...e].sort()}function p(e,r,i,s,l,c){let o=[],a=[];for(let n of e)m(n,s).filter(d=>!i.has(d)).length>0?o.push(n):a.push(n);o.length&&l.push(`${r} has domain term(s): ${o.slice(0,6).join(", ")}`),a.length&&c.push(`${r} is generic workflow: ${a.slice(0,6).join(", ")}`)}function m(e,r){let i=e.replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/([a-z0-9])([A-Z])/g,"$1 $2");for(let s of r)i=i.replace(s,"");return i.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function f(e,r,i){return e==="generic"?r:i}export{v as a,x as b,b as c,P as d,A as e,E as f};
|
|
2
|
+
//# sourceMappingURL=chunk-B3X6KU75.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{a as d}from"./chunk-3I34FZ6R.js";import{a as h}from"./chunk-YSUD2S7T.js";import{d as f}from"./chunk-OO6S4ECV.js";import{b as u}from"./chunk-NLVKD45E.js";import{E as l}from"./chunk-MCNWCJYL.js";import{readFileSync as E}from"fs";import{join as B}from"path";function j(t,e,s={}){let n=h(t,e);if(!n)return null;let a=new d(t),o=N(t,n),r=n.endLine-n.startLine+1,m=a.calleeMap([n],{additive:!0,semantic:s.semantic}).get(n.symbolId)??[],c=new Set(m.map(x=>x.symbol));return{symbol:n.symbol,shortName:f(n.symbol),relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:r,branches:o.branches,estimateBasis:o.estimateBasis,cyclomaticEstimate:o.branches+1,calleeCount:c.size,fanIn:P(t,n.symbolId),fanOut:w(m,n.relativePath)}}function N(t,e){let s=l(t,e.relativePath);if(s){let n=g(s.rootNode,e.startLine,e.endLine);if(n)return{branches:v(n),estimateBasis:"ast"}}return{branches:_(p(t,e.relativePath,e.startLine,e.endLine),y(t,e.relativePath)),estimateBasis:"regex-fallback"}}function H(t,e){let s=new Map,n=new Map;for(let a of e){let o=n.get(a.relativePath)??[];o.push(a),n.set(a.relativePath,o)}for(let[a,o]of n){let r=l(t,a),i=r===null?[]:o.filter(c=>r.rootNode.startPosition.row<=c.startLine&&r.rootNode.endPosition.row>=c.endLine),m=new Set(i.map(c=>c.symbolId));if(r&&i.length>0){for(let c of i)s.set(c.symbolId,{branches:0,estimateBasis:"ast"});C(r.rootNode,i,s)}for(let c of o)m.has(c.symbolId)||s.set(c.symbolId,L(t,c))}return s}function L(t,e){return{branches:_(p(t,e.relativePath,e.startLine,e.endLine),y(t,e.relativePath)),estimateBasis:"regex-fallback"}}function y(t,e){return t.get("SELECT language FROM documents WHERE relative_path = ?",e)?.language??"unknown"}function p(t,e,s,n){try{return E(B(t.config.projectRoot,e),"utf-8").split(`
|
|
2
|
+
`).slice(s,n+1).join(`
|
|
3
|
+
`)}catch{return""}}function P(t,e){return t.get(`SELECT COUNT(DISTINCT c.document_id) AS c
|
|
4
|
+
FROM mentions m
|
|
5
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
6
|
+
JOIN (
|
|
7
|
+
SELECT m2.symbol_id, c2.document_id
|
|
8
|
+
FROM mentions m2
|
|
9
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
10
|
+
WHERE m2.role = 1
|
|
11
|
+
GROUP BY m2.symbol_id
|
|
12
|
+
) sym_def ON sym_def.symbol_id = m.symbol_id
|
|
13
|
+
WHERE m.symbol_id = ?
|
|
14
|
+
AND m.role != 1
|
|
15
|
+
AND sym_def.document_id != c.document_id`,e)?.c??0}function w(t,e){return new Set(t.filter(s=>s.file!==e).map(s=>s.symbol)).size}function v(t){let e=0;return b(t,s=>{e+=S(s)}),e}function C(t,e,s){let n=[...e].sort((a,o)=>a.startLine-o.startLine||o.endLine-a.endLine);b(t,a=>{let o=S(a);if(o===0)return;let r=a.startPosition.row,i=a.endPosition.row;for(let m of n){if(m.startLine>r)break;if(m.endLine<i)continue;let c=s.get(m.symbolId);c&&(c.branches+=o)}})}function b(t,e){e(t);for(let s of t.namedChildren)b(s,e)}function g(t,e,s){if(t.startPosition.row>e||t.endPosition.row<s)return null;for(let n of t.namedChildren){let a=g(n,e,s);if(a)return a}return t}var D=new Set(["if_statement","conditional_expression","ternary_expression","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_case","case_statement","catch_clause","except_clause","elif_clause","match_arm"]);function S(t){return D.has(t.type)?1:t.type==="binary_expression"&&t.parent?.type!=="binary_expression"&&(t.text.includes("&&")||t.text.includes("||"))?I(t.text):0}function I(t){return(t.match(/&&|\|\|/g)??[]).length}function _(t,e){let s=u(t),n=0,a=[/\bif\b/g,/\belse\s+if\b/g,/\belse\b/g,/\bfor\b/g,/\bwhile\b/g,/\bswitch\b/g,/\bcase\b/g,/\bcatch\b/g,/\?\s*[^?]/g,/&&/g,/\|\|/g];for(let o of a){let r=s.match(o);r&&(n+=r.length)}if(e==="python"){let o=[/\belif\b/g,/\bexcept\b/g,/\bfinally\b/g];for(let r of o){let i=s.match(r);i&&(n+=i.length)}}else if(e==="rust"){let o=[/\bmatch\b/g,/=>/g,/\bloop\b/g];for(let r of o){let i=s.match(r);i&&(n+=i.length)}}else if(e==="ruby"){let o=[/\belsif\b/g,/\bunless\b/g,/\brescue\b/g,/\bwhen\b/g];for(let r of o){let i=s.match(r);i&&(n+=i.length)}}else if(e==="go"){let o=[/\bselect\b/g,/\bdefer\b/g];for(let r of o){let i=s.match(r);i&&(n+=i.length)}}return n}export{j as a,N as b,H as c,v as d};
|
|
16
|
+
//# sourceMappingURL=chunk-BFWVHD2P.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{a as R}from"./chunk-3I34FZ6R.js";import{a as _,d as f}from"./chunk-NLRWGGPY.js";import{d as l}from"./chunk-OO6S4ECV.js";import{o as u,p,q as a}from"./chunk-NLVKD45E.js";import{a as d}from"./chunk-64MNV6AB.js";import{y as m}from"./chunk-WFRZGMWJ.js";function $(e,o={}){let{scope:n,limit:r}=o,i=new R(e),t=D([...x(e,n),...O(e,i,n)]);return y(t),r?t.slice(0,r):t}function x(e,o){let n=[];for(let r of S(e,o)){if(e.isIgnored(r.barrel_path)||e.isIgnored(r.original_path)||f(e,r.barrel_path)||m(e,r.barrel_path)&&a(e,r.barrel_path).length===0)continue;let i=N(e,r),t=i?.barrel_consumers??0,s=i?.direct_consumers??0;t!==0||s!==0||n.push({barrelFile:r.barrel_path,symbol:r.symbol,shortName:l(r.symbol),originalFile:r.original_path,barrelConsumers:t,directConsumers:s,...b(e,r.barrel_path)})}return n}function S(e,o){let n=o?"AND barrel_d.relative_path LIKE ?":"",r=o?[`%${o}%`]:[];return e.all(`SELECT DISTINCT
|
|
2
|
+
barrel_d.id AS barrel_doc_id,
|
|
3
|
+
barrel_d.relative_path AS barrel_path,
|
|
4
|
+
gs.id AS symbol_id,
|
|
5
|
+
gs.symbol AS symbol,
|
|
6
|
+
orig_d.id AS original_doc_id,
|
|
7
|
+
orig_d.relative_path AS original_path
|
|
8
|
+
FROM mentions m
|
|
9
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
10
|
+
JOIN documents barrel_d ON c.document_id = barrel_d.id
|
|
11
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
12
|
+
JOIN (
|
|
13
|
+
SELECT m2.symbol_id, c2.document_id
|
|
14
|
+
FROM mentions m2
|
|
15
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
16
|
+
WHERE m2.role = 1
|
|
17
|
+
GROUP BY m2.symbol_id
|
|
18
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
19
|
+
JOIN documents orig_d ON sym_def.document_id = orig_d.id
|
|
20
|
+
WHERE m.role != 1
|
|
21
|
+
AND (barrel_d.relative_path LIKE '%/index.ts'
|
|
22
|
+
OR barrel_d.relative_path LIKE '%/index.js'
|
|
23
|
+
OR barrel_d.relative_path = 'index.ts'
|
|
24
|
+
OR barrel_d.relative_path = 'index.js')
|
|
25
|
+
AND orig_d.id != barrel_d.id
|
|
26
|
+
${e.pathExclusionsFor("barrel_d","orig_d")}
|
|
27
|
+
${e.symbolNoiseFor("gs")}
|
|
28
|
+
-- Only function-level symbols (ending with ().), not module-level
|
|
29
|
+
AND gs.symbol LIKE '%().'
|
|
30
|
+
${n}
|
|
31
|
+
ORDER BY barrel_d.relative_path, gs.symbol`,...r)}function N(e,o){return e.get(`SELECT
|
|
32
|
+
SUM(CASE WHEN uses_barrel = 1 THEN 1 ELSE 0 END) AS barrel_consumers,
|
|
33
|
+
SUM(CASE WHEN uses_barrel = 0 THEN 1 ELSE 0 END) AS direct_consumers
|
|
34
|
+
FROM (
|
|
35
|
+
SELECT
|
|
36
|
+
consumer_d.id AS consumer_doc_id,
|
|
37
|
+
MAX(CASE WHEN EXISTS (
|
|
38
|
+
SELECT 1
|
|
39
|
+
FROM mentions barrel_m
|
|
40
|
+
JOIN chunks barrel_c ON barrel_m.chunk_id = barrel_c.id
|
|
41
|
+
WHERE barrel_c.document_id = consumer_d.id
|
|
42
|
+
AND barrel_m.role != 1
|
|
43
|
+
AND barrel_m.symbol_id IN (
|
|
44
|
+
SELECT m2.symbol_id
|
|
45
|
+
FROM mentions m2
|
|
46
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
47
|
+
WHERE c2.document_id = ?
|
|
48
|
+
AND m2.role != 1
|
|
49
|
+
)
|
|
50
|
+
) THEN 1 ELSE 0 END) AS uses_barrel
|
|
51
|
+
FROM mentions ref_m
|
|
52
|
+
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
53
|
+
JOIN documents consumer_d ON ref_c.document_id = consumer_d.id
|
|
54
|
+
WHERE ref_m.symbol_id = ?
|
|
55
|
+
AND ref_m.role != 1
|
|
56
|
+
AND consumer_d.id != ?
|
|
57
|
+
AND consumer_d.id != ?
|
|
58
|
+
${e.pathExclusionsFor("consumer_d")}
|
|
59
|
+
GROUP BY consumer_d.id
|
|
60
|
+
)`,o.barrel_doc_id,o.symbol_id,o.barrel_doc_id,o.original_doc_id)}function O(e,o,n){let r=[];for(let i of C(e,n))h(e,i,i)>0||r.push(...I(e,o,i));return r}function C(e,o){return d(e,{scope:o,includeIgnored:!1}).filter(n=>a(e,n).length>0||u(e,n).length>0)}function I(e,o,n){let r=a(e,n).filter(t=>t.sourcePath&&!e.isIgnored(t.sourcePath)).flatMap(t=>g(e,o,n,t.sourcePath,[A(t.specifier)])),i=u(e,n).filter(t=>t.sourcePath&&!e.isIgnored(t.sourcePath)).flatMap(t=>g(e,o,n,t.sourcePath,t.kind==="named"&&t.names.length>0?t.names:[t.kind==="star"?`* from ${t.sourcePath}`:`* namespace from ${t.sourcePath}`]));return[...r,...i]}function g(e,o,n,r,i){let t=o.definitionsForFile(r);return i.map(s=>{let c=t.find(E=>E.leaf===s);return{barrelFile:n,symbol:c?.symbol??`source-reexport:${n}:${s}`,shortName:c?l(c.symbol):s,originalFile:r,barrelConsumers:0,directConsumers:h(e,r,n),...b(e,n)}})}function A(e){return e.split("::").at(-1)?.split("/").at(-1)?.replace(/\.[^.]+$/,"")??e}function b(e,o){return _(e,o)?{actionTier:"signal",surfaceEvidence:["barrel file is declared on the package public surface"],recommendation:"Review the package API before removing this re-export; local consumers are zero, but external consumers may import through the public barrel."}:{actionTier:"direct",surfaceEvidence:[],recommendation:"Remove this unused re-export when the barrel is not part of an external API surface."}}function h(e,o,n){let r=new Set;for(let i of d(e,{includeIgnored:!1}))if(i!==n)for(let t of p(e,i))t.sourcePath===o&&r.add(i);return r.size}function D(e){let o=new Set,n=[];for(let r of e){let i=`${r.barrelFile}|${r.symbol}|${r.originalFile}`;o.has(i)||(o.add(i),n.push(r))}return n}function y(e){e.sort((o,n)=>n.directConsumers-o.directConsumers||o.barrelFile.localeCompare(n.barrelFile)||o.shortName.localeCompare(n.shortName))}export{$ as a};
|
|
61
|
+
//# sourceMappingURL=chunk-BVHP2B4D.js.map
|