scip-query 0.17.0 → 0.17.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +19 -0
  3. package/dist/{chunk-A4KRWTXD.js → chunk-2DUWNJKE.js} +2 -2
  4. package/dist/{chunk-KTZACYL6.js → chunk-2TM23JYJ.js} +2 -2
  5. package/dist/{chunk-42YU6TEB.js → chunk-35DURZXI.js} +2 -2
  6. package/dist/{chunk-TCOWAGR2.js → chunk-3YEBIYXL.js} +2 -2
  7. package/dist/{chunk-H4SMB657.js → chunk-5QSMW5IO.js} +2 -2
  8. package/dist/{chunk-AQ34B63A.js → chunk-623AZLTE.js} +2 -2
  9. package/dist/{chunk-RZEVUYMG.js → chunk-6TJERPN3.js} +2 -2
  10. package/dist/{chunk-NJBARXRO.js → chunk-7H37Z4UO.js} +2 -2
  11. package/dist/{chunk-VT2KFEPG.js → chunk-BBTVIIOI.js} +2 -2
  12. package/dist/{chunk-CYDOV3AQ.js → chunk-BTYDBDX5.js} +2 -2
  13. package/dist/{chunk-3EBDPBBU.js → chunk-BW4VDICR.js} +2 -2
  14. package/dist/{chunk-JVTMRIKU.js → chunk-CKRVVBM6.js} +2 -2
  15. package/dist/{chunk-6G3GQWTK.js → chunk-CSMPXDYE.js} +2 -2
  16. package/dist/{chunk-KYUYAWKA.js → chunk-E5HPTSRD.js} +2 -2
  17. package/dist/chunk-E7BTIEAY.js +2 -0
  18. package/dist/{chunk-KLFCCRI7.js → chunk-EUMETOTD.js} +2 -2
  19. package/dist/{chunk-MVFNACWB.js → chunk-FY6RCFDH.js} +2 -2
  20. package/dist/{chunk-JYBF5CPE.js → chunk-FZXN37RN.js} +2 -2
  21. package/dist/{chunk-Y3DG4J6A.js → chunk-G4IUQW27.js} +2 -2
  22. package/dist/{chunk-WH65EY7U.js → chunk-HJYHSTCP.js} +2 -2
  23. package/dist/{chunk-PVXSHZLW.js → chunk-HYRSGWFX.js} +2 -2
  24. package/dist/{chunk-ZMD4O5UP.js → chunk-HZVG4KID.js} +2 -2
  25. package/dist/{chunk-HV4N3UBV.js → chunk-IHD2CHMX.js} +2 -2
  26. package/dist/{chunk-7CHIAMKS.js → chunk-IKAJI4SI.js} +2 -2
  27. package/dist/{chunk-TL2IXVGH.js → chunk-IZLWLO4X.js} +2 -2
  28. package/dist/{chunk-JJAH2VLD.js → chunk-JYBP5ZIR.js} +2 -2
  29. package/dist/{chunk-QNCVN5EH.js → chunk-KWMRY4RN.js} +2 -2
  30. package/dist/{chunk-KAOWSWEX.js → chunk-KWQKWY6M.js} +2 -2
  31. package/dist/{chunk-IK2NG76R.js → chunk-MBDBNQBW.js} +2 -2
  32. package/dist/chunk-MON5XXTG.js +7 -0
  33. package/dist/{chunk-BBBZB5WY.js → chunk-O27267B6.js} +2 -2
  34. package/dist/{chunk-34RCSYMZ.js → chunk-O56VBJKB.js} +2 -2
  35. package/dist/{chunk-J4HK7PQS.js → chunk-OBPR6E5Z.js} +2 -2
  36. package/dist/{chunk-YD7GGLGE.js → chunk-OC7XDK62.js} +2 -2
  37. package/dist/{chunk-ABRWGVC6.js → chunk-PPAT3XUL.js} +2 -2
  38. package/dist/{chunk-PYOZHG6A.js → chunk-QYBCGCY5.js} +2 -2
  39. package/dist/{chunk-EPDV3SQD.js → chunk-RPPV6Y4K.js} +2 -2
  40. package/dist/{chunk-OQRMCT2N.js → chunk-SQJ72PQW.js} +5 -5
  41. package/dist/{chunk-KO2TFDIP.js → chunk-SSH2NPYS.js} +2 -2
  42. package/dist/chunk-U267E6YN.js +120 -0
  43. package/dist/{chunk-JUADXGUH.js → chunk-UKUISUS6.js} +2 -2
  44. package/dist/{chunk-LC57FSPX.js → chunk-V7MX6YUF.js} +2 -2
  45. package/dist/{chunk-SREWDA7Q.js → chunk-W2I4QAW7.js} +2 -2
  46. package/dist/{chunk-5ODF4JGH.js → chunk-W3HSUCRG.js} +2 -2
  47. package/dist/{chunk-VCOAUTSI.js → chunk-WENI5ZDR.js} +2 -2
  48. package/dist/{chunk-VPVAQRHM.js → chunk-WGDIA2TU.js} +2 -2
  49. package/dist/{chunk-7MT6UM4D.js → chunk-WT34AUWL.js} +2 -2
  50. package/dist/{chunk-OP5RO2CF.js → chunk-Y4BBVPRK.js} +2 -2
  51. package/dist/cli.js +280 -280
  52. package/dist/index.js +1 -1
  53. package/dist/queries/affected.js +1 -1
  54. package/dist/queries/bottlenecks.js +1 -1
  55. package/dist/queries/call-graph.js +1 -1
  56. package/dist/queries/change-surface.js +1 -1
  57. package/dist/queries/cleanup-plan.js +1 -1
  58. package/dist/queries/complexity-hotspots.js +1 -1
  59. package/dist/queries/complexity.js +1 -1
  60. package/dist/queries/convergence.js +1 -1
  61. package/dist/queries/dataflow.js +1 -1
  62. package/dist/queries/dead.js +1 -1
  63. package/dist/queries/decorative-checkers.js +1 -1
  64. package/dist/queries/diff-gate.js +1 -1
  65. package/dist/queries/diff-impact.js +1 -1
  66. package/dist/queries/drift.js +1 -1
  67. package/dist/queries/extract-candidates.js +1 -1
  68. package/dist/queries/health.js +1 -1
  69. package/dist/queries/hotspots.js +1 -1
  70. package/dist/queries/imports.js +1 -1
  71. package/dist/queries/incomplete-migration.js +1 -1
  72. package/dist/queries/index.js +1 -1
  73. package/dist/queries/isolated.js +1 -1
  74. package/dist/queries/locality-candidates.js +1 -1
  75. package/dist/queries/members.js +1 -1
  76. package/dist/queries/methods.js +1 -1
  77. package/dist/queries/not-implemented.js +1 -1
  78. package/dist/queries/passthrough-candidates.js +1 -1
  79. package/dist/queries/plan-context.js +1 -1
  80. package/dist/queries/recent-duplicates.js +1 -1
  81. package/dist/queries/redundant-reexports.js +1 -1
  82. package/dist/queries/refs.js +1 -1
  83. package/dist/queries/self-audit.js +1 -1
  84. package/dist/queries/similar-signatures.js +1 -1
  85. package/dist/queries/similar.js +1 -1
  86. package/dist/queries/slice.js +1 -1
  87. package/dist/queries/stale-abstractions.js +1 -1
  88. package/dist/queries/surface.js +1 -1
  89. package/dist/queries/trace.js +1 -1
  90. package/dist/queries/twin-ab.js +1 -1
  91. package/dist/queries/unused-imports.js +1 -1
  92. package/dist/queries/unused-params.js +1 -1
  93. package/dist/queries/wrapper-candidates.js +1 -1
  94. package/dist/reindex-worker.js +22 -22
  95. package/dist/reindex.js +36 -36
  96. package/dist/runtime.d.ts +2 -0
  97. package/dist/runtime.js +1 -1
  98. package/dist/watch-server.js +4 -4
  99. package/package.json +2 -1
  100. package/skills/scip-tla-model-system/SKILL.md +10 -8
  101. package/dist/chunk-L7UITWFE.js +0 -120
  102. package/dist/chunk-QVZSWLLZ.js +0 -2
  103. package/dist/chunk-RSZ4KX4B.js +0 -7
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to `scip-query` are documented here. This file starts at 0.1
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.17.1]
8
+
9
+ ### Fixes (worktree watcher isolation)
10
+
11
+ - Automatic refresh now persists and validates the Git worktree identity of each daemon. Every default-managed worktree starts or reuses its own watcher, watches only its own checkout, and sends reindex output only to its own writable cache; portable source subscriptions detect ordinary unstaged edits on Node 18 Linux, Git polling independently detects `HEAD` and index changes, and `watch --status` reports the bound root and worktree ID.
12
+
13
+ ## [0.17.0]
14
+
7
15
  ### Performance (Git worktree warm starts)
8
16
 
9
17
  - Clean Git worktrees at the same repository snapshot now warm-start from one immutable shared index generation while retaining separate writable local caches. Concurrent cold worktrees coordinate one generation build, dirty edits stay isolated to their checkout, safe content-keyed evidence reads through a bounded repository database, and managed caches for removed worktrees are reclaimed automatically. `SCIP_QUERY_SHARED_CACHE=0` disables the behavior, and explicit cache/database overrides remain private.
@@ -112,4 +120,6 @@ All notable changes to `scip-query` are documented here. This file starts at 0.1
112
120
  - **Calibration retunes from external repo validation:** `duplicate-bodies`' default `--min-loc` raised from 1 to 3 (kills 1-line forwarding-stub noise); `twin-drift` excludes synthetic constructor-style leaves and test-only groups; `co-change` exempts locale/i18n sibling resource files from hidden-coupling findings; `stale-abstractions`/`wrapper-candidates` gained an explicit false-positive-rate caveat and were demoted from the default `cleanup-audit` sweep to an opt-in deep-dive.
113
121
  - Assorted smaller fixes: parameterized SQL in a scope filter (injection-shaped hygiene, no known exploit), fan-in/hotspot queries no longer counting a symbol's own defining file as a consumer, AST-based cyclomatic-complexity counting, nested `.gitignore` support, and Vue single-file-component script extraction unified across the codebase.
114
122
 
123
+ [0.17.1]: https://github.com/PlunderStruck/scip-query/releases/tag/v0.17.1
124
+ [0.17.0]: https://github.com/PlunderStruck/scip-query/releases/tag/v0.17.0
115
125
  [0.11.0]: https://github.com/PlunderStruck/scip-query/releases/tag/v0.11.0
package/README.md CHANGED
@@ -448,6 +448,22 @@ copy-on-write cloning is used when available, with an ordinary copy fallback;
448
448
  hard links are never used. Dirty edits, watcher refreshes, locks, and local
449
449
  `evidence.db` state therefore remain private to the worktree.
450
450
 
451
+ Automatic refresh follows the same boundary. When `watch.enabled` is true,
452
+ the first watcher-eligible command in each worktree starts or reuses a daemon
453
+ identified by that checkout's Git worktree ID. A Git worktree ID is a checkout
454
+ identifier derived from its filesystem path after symbolic-link redirects are
455
+ resolved and its checkout-specific Git control directory; that combination
456
+ distinguishes sibling worktrees even though they share repository objects. The
457
+ daemon observes only that worktree's files and Git index, and every reindex
458
+ child writes only to that worktree's writable `index.scip` and `index.db`. A
459
+ cross-platform source watcher maintains the directory subscriptions needed to
460
+ detect ordinary unstaged edits even when Node does not provide recursive
461
+ filesystem events, while separate Git polling detects commit and staging-state
462
+ changes. A
463
+ shared generation is only a warm starting snapshot; it never implies a shared
464
+ watcher or shared later writes. A daemon that exits after its configured idle
465
+ timeout starts warm again when that worktree is next used.
466
+
451
467
  The primary checkout is only a possible source of a generation, never an
452
468
  authority for a linked worktree. If its local cache already contains
453
469
  uncommitted changes that are absent from a new worktree's `HEAD`, the full
@@ -465,6 +481,9 @@ repository budget requires earlier eviction. Ownership checksums and physical
465
481
  path containment prevent cleanup from following forged records or symlinks.
466
482
  Explicit `dbPath`, `SCIP_QUERY_CACHE_DIR`, and
467
483
  `SCIP_QUERY_INDEX_DB` locations are never shared or automatically deleted.
484
+ Those explicit overrides also bypass default path isolation, so pointing two
485
+ worktrees at the same mutable override is intentionally outside automatic
486
+ per-worktree protection.
468
487
  Set `SCIP_QUERY_SHARED_CACHE=0` to restore worktree-local-only behavior.
469
488
 
470
489
  Each rebuilt generation also records an affected-set shadow beside the index:
@@ -1,5 +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-CYDOV3AQ.js";import{a as ne}from"./chunk-TCOWAGR2.js";import{a as D}from"./chunk-2HCWAL42.js";import{d as I,e as K,h as $}from"./chunk-7XP7ZRSI.js";import{a as B}from"./chunk-JLZUM476.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-M2TRDR25.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(`
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-BTYDBDX5.js";import{a as ne}from"./chunk-3YEBIYXL.js";import{a as D}from"./chunk-2HCWAL42.js";import{d as I,e as K,h as $}from"./chunk-7XP7ZRSI.js";import{a as B}from"./chunk-JLZUM476.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-M2TRDR25.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
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
3
  `)}return e.slice(n,Math.min(e.length,n+8)).join(`
4
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-A4KRWTXD.js.map
5
+ //# sourceMappingURL=chunk-2DUWNJKE.js.map
@@ -1,4 +1,4 @@
1
- import{c as d}from"./chunk-TCOWAGR2.js";import{d as r,t as m}from"./chunk-7XP7ZRSI.js";function y(o,t={}){let{limit:i=30,scope:e}=t,s=e?"AND def_d.relative_path LIKE ?":"",f=e?[`%${e}%`]:[],l=o.all(`SELECT
1
+ import{c as d}from"./chunk-3YEBIYXL.js";import{d as r,t as m}from"./chunk-7XP7ZRSI.js";function y(o,t={}){let{limit:i=30,scope:e}=t,s=e?"AND def_d.relative_path LIKE ?":"",f=e?[`%${e}%`]:[],l=o.all(`SELECT
2
2
  gs.symbol,
3
3
  COUNT(*) AS ref_count,
4
4
  COUNT(DISTINCT ref_d.id) AS file_count,
@@ -23,4 +23,4 @@ import{c as d}from"./chunk-TCOWAGR2.js";import{d as r,t as m}from"./chunk-7XP7ZR
23
23
  GROUP BY gs.id
24
24
  ORDER BY ref_count DESC
25
25
  LIMIT ?`,...f,i).filter(n=>!o.isIgnored(n.defined_in)).map(n=>({symbol:n.symbol,shortName:r(n.symbol),refCount:n.ref_count,fileCount:n.file_count,definedIn:n.defined_in}));return l.length>0?l:c(o,e,i)}function c(o,t,i){return m(o,{scope:t}).filter(e=>!o.isIgnored(e.relativePath)).map(e=>u(o,e)).filter(e=>e.refCount>0).sort((e,s)=>s.refCount-e.refCount||s.fileCount-e.fileCount).slice(0,i)}function u(o,t){let e=d(o,t,{limit:500}).filter(s=>s.file!==t.relativePath);return{symbol:t.symbol,shortName:r(t.symbol),refCount:e.length,fileCount:new Set(e.map(s=>s.file)).size,definedIn:t.relativePath}}export{y as a};
26
- //# sourceMappingURL=chunk-KTZACYL6.js.map
26
+ //# sourceMappingURL=chunk-2TM23JYJ.js.map
@@ -1,8 +1,8 @@
1
- import{a as T,c as E,g as L,h as D}from"./chunk-KLFCCRI7.js";import{j as O,o as A}from"./chunk-A4KRWTXD.js";import{d as H}from"./chunk-KMVGRIO2.js";import{a as _}from"./chunk-CYDOV3AQ.js";import{d as C,e as F}from"./chunk-7XP7ZRSI.js";import{a as w}from"./chunk-JLZUM476.js";var J=5;function ae(e,t={}){let{base:a="HEAD",minContainment:o=.7,minCallees:r=3,minSiteCoverage:n=.4,maxHelpers:c=Number.POSITIVE_INFINITY,limit:m=20,scanLimit:g}=t,f=t.semantic!==!1,s=t.diffPlan??E(e,{base:a}),l={available:s.note!==T,base:a,changedFiles:s.changedFiles,helpersChecked:0,skipped:[],findings:[]};if(!l.available||s.changedFiles.length===0)return l;let x=new _(e),k=new Set(s.changedFiles),$=new Map(s.renamedFiles.map(i=>[i.to,i.from])),j=t.baseContentAt??L(e.config.projectRoot,a,D(s)),h=Z(x,k,$,j);if(h.length===0)return l;let R=h.slice(0,c);h.length>c&&(l.note=`helper scoring capped at ${c} of ${h.length} new symbols`);let q=x.calleeMap(R,{semantic:f}),B=R.map(i=>({def:i,callees:A((q.get(i.symbolId)??[]).map(p=>p.symbol))})),V=O(e),M,G=()=>(M??=V.calleeIndex({minCallees:Math.min(3,r),scanLimit:g,semantic:f}),M);for(let{def:i,callees:p}of B){let d=C(i.symbol);if(p.size<r){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let P=G(),N=Y(p,P);if(N===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let b=Q(e,i.symbolId);if(b.length===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}l.helpersChecked+=1;let I=K({candidateIndex:P,changed:k,helperCallees:p,helperFile:i.relativePath,helperSymbol:i.symbol,minContainment:o,minSiteCoverage:n,migratedFiles:b});I.length!==0&&(I.sort((u,S)=>z(S.migrationScope)-z(u.migrationScope)||S.containment-u.containment||S.siteCoverage-u.siteCoverage||u.file.localeCompare(S.file)),l.findings.push({helperSymbol:i.symbol,helperShortName:d,helperFile:i.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:N,migratedFiles:b.sort(),leftovers:I.slice(0,J)}))}return l.findings.sort((i,p)=>(p.leftovers[0]?.containment??0)-(i.leftovers[0]?.containment??0)||i.helperFile.localeCompare(p.helperFile)),l.findings=l.findings.slice(0,m),l}function K(e){let t=[],a=U(e.helperSymbol,e.helperFile,e.migratedFiles),o=new Set;for(let r of e.helperCallees)for(let n of e.candidateIndex.candidateIndexesByCallee.get(r)??[])o.add(n);for(let r of o){let n=e.candidateIndex.corpus[r];if(n.symbol===e.helperSymbol||e.changed.has(n.file)||n.callees.has(e.helperSymbol))continue;let c=H(e.helperCallees,n.callees);if(c<e.minContainment)continue;let m=[...e.helperCallees].filter(s=>n.callees.has(s)),g=n.callees.size===0?0:m.length/n.callees.size;if(g<e.minSiteCoverage||!m.some(s=>(e.candidateIndex.docFreq.get(s)??0)<=e.candidateIndex.ubiquityThreshold))continue;let f=W(a,n.symbol,n.file);t.push({symbol:n.symbol,shortName:C(n.symbol),file:n.file,...f,containment:c,siteCoverage:g,uniqueSiteCalleeCount:Math.max(0,n.callees.size-m.length),sharedCallees:m.map(C).sort()})}return t}function z(e){return e==="same-scope"?2:e==="unknown"?1:0}function U(e,t,a){let o=new Set([...y(t),...v(F(e))]);for(let r of a)for(let n of y(r))o.add(n);return o}function W(e,t,a){let o=new Set([...y(a),...v(F(t))]);if(e.size===0||o.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...o].filter(n=>e.has(n)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var X=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function y(e){return v(e.replace(/\.[^.]+$/,""))}function v(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!X.has(t))}function Y(e,t){let a=0;for(let o of e)(t.docFreq.get(o)??0)<=t.ubiquityThreshold&&(a+=1);return a}function Z(e,t,a,o){return e.productionCallableDefinitions({files:[...t],requireFunctionLikeSymbol:!0}).filter(r=>{if(!t.has(r.relativePath))return!1;let n=a.get(r.relativePath)??r.relativePath,c=o(n);return c===null||!new RegExp(`\\b${w(r.leaf)}\\b`).test(c)})}function Q(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
1
+ import{a as T,c as E,g as L,h as D}from"./chunk-EUMETOTD.js";import{j as O,o as A}from"./chunk-2DUWNJKE.js";import{d as H}from"./chunk-KMVGRIO2.js";import{a as _}from"./chunk-BTYDBDX5.js";import{d as C,e as F}from"./chunk-7XP7ZRSI.js";import{a as w}from"./chunk-JLZUM476.js";var J=5;function ae(e,t={}){let{base:a="HEAD",minContainment:o=.7,minCallees:r=3,minSiteCoverage:n=.4,maxHelpers:c=Number.POSITIVE_INFINITY,limit:m=20,scanLimit:g}=t,f=t.semantic!==!1,s=t.diffPlan??E(e,{base:a}),l={available:s.note!==T,base:a,changedFiles:s.changedFiles,helpersChecked:0,skipped:[],findings:[]};if(!l.available||s.changedFiles.length===0)return l;let x=new _(e),k=new Set(s.changedFiles),$=new Map(s.renamedFiles.map(i=>[i.to,i.from])),j=t.baseContentAt??L(e.config.projectRoot,a,D(s)),h=Z(x,k,$,j);if(h.length===0)return l;let R=h.slice(0,c);h.length>c&&(l.note=`helper scoring capped at ${c} of ${h.length} new symbols`);let q=x.calleeMap(R,{semantic:f}),B=R.map(i=>({def:i,callees:A((q.get(i.symbolId)??[]).map(p=>p.symbol))})),V=O(e),M,G=()=>(M??=V.calleeIndex({minCallees:Math.min(3,r),scanLimit:g,semantic:f}),M);for(let{def:i,callees:p}of B){let d=C(i.symbol);if(p.size<r){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let P=G(),N=Y(p,P);if(N===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let b=Q(e,i.symbolId);if(b.length===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}l.helpersChecked+=1;let I=K({candidateIndex:P,changed:k,helperCallees:p,helperFile:i.relativePath,helperSymbol:i.symbol,minContainment:o,minSiteCoverage:n,migratedFiles:b});I.length!==0&&(I.sort((u,S)=>z(S.migrationScope)-z(u.migrationScope)||S.containment-u.containment||S.siteCoverage-u.siteCoverage||u.file.localeCompare(S.file)),l.findings.push({helperSymbol:i.symbol,helperShortName:d,helperFile:i.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:N,migratedFiles:b.sort(),leftovers:I.slice(0,J)}))}return l.findings.sort((i,p)=>(p.leftovers[0]?.containment??0)-(i.leftovers[0]?.containment??0)||i.helperFile.localeCompare(p.helperFile)),l.findings=l.findings.slice(0,m),l}function K(e){let t=[],a=U(e.helperSymbol,e.helperFile,e.migratedFiles),o=new Set;for(let r of e.helperCallees)for(let n of e.candidateIndex.candidateIndexesByCallee.get(r)??[])o.add(n);for(let r of o){let n=e.candidateIndex.corpus[r];if(n.symbol===e.helperSymbol||e.changed.has(n.file)||n.callees.has(e.helperSymbol))continue;let c=H(e.helperCallees,n.callees);if(c<e.minContainment)continue;let m=[...e.helperCallees].filter(s=>n.callees.has(s)),g=n.callees.size===0?0:m.length/n.callees.size;if(g<e.minSiteCoverage||!m.some(s=>(e.candidateIndex.docFreq.get(s)??0)<=e.candidateIndex.ubiquityThreshold))continue;let f=W(a,n.symbol,n.file);t.push({symbol:n.symbol,shortName:C(n.symbol),file:n.file,...f,containment:c,siteCoverage:g,uniqueSiteCalleeCount:Math.max(0,n.callees.size-m.length),sharedCallees:m.map(C).sort()})}return t}function z(e){return e==="same-scope"?2:e==="unknown"?1:0}function U(e,t,a){let o=new Set([...y(t),...v(F(e))]);for(let r of a)for(let n of y(r))o.add(n);return o}function W(e,t,a){let o=new Set([...y(a),...v(F(t))]);if(e.size===0||o.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...o].filter(n=>e.has(n)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var X=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function y(e){return v(e.replace(/\.[^.]+$/,""))}function v(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!X.has(t))}function Y(e,t){let a=0;for(let o of e)(t.docFreq.get(o)??0)<=t.ubiquityThreshold&&(a+=1);return a}function Z(e,t,a,o){return e.productionCallableDefinitions({files:[...t],requireFunctionLikeSymbol:!0}).filter(r=>{if(!t.has(r.relativePath))return!1;let n=a.get(r.relativePath)??r.relativePath,c=o(n);return c===null||!new RegExp(`\\b${w(r.leaf)}\\b`).test(c)})}function Q(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents ref_d ON c.document_id = ref_d.id
5
5
  WHERE m.symbol_id = ?
6
6
  AND m.role != 1
7
7
  ${e.pathExclusionsFor("ref_d")}`,t).map(o=>o.relative_path)}export{ae as a};
8
- //# sourceMappingURL=chunk-42YU6TEB.js.map
8
+ //# sourceMappingURL=chunk-35DURZXI.js.map
@@ -1,4 +1,4 @@
1
- import{b as ae,c as O,d as T,e as H,k as pe,l as be}from"./chunk-MVFNACWB.js";import{d as le,e as me,f as $,g as de,i as ue,l as fe}from"./chunk-QNCVN5EH.js";import{D as ce,n as re,x as j}from"./chunk-OQRMCT2N.js";import{a as ne}from"./chunk-QEIGJJBC.js";import{d as ye,e as ge}from"./chunk-MTDBHTSF.js";import{e as P,g as te,s as oe,t as F,y as ie,z as se}from"./chunk-7XP7ZRSI.js";import{k as E,m as X,p as ee}from"./chunk-JLZUM476.js";import{B as w,c as Z}from"./chunk-TLTLJ4SW.js";import{a as Y}from"./chunk-64MNV6AB.js";import{c as V,d as z,g as B,h as x,j as Q,l as K,q,s as D,y as N}from"./chunk-M2TRDR25.js";function Mn(e,n,t={}){let o=Ce(e,[n],{additive:t.additive,semantic:t.semantic}),s=t.callableOnly?(o.get(n.symbolId)??[]).filter(a=>te(a.symbol)||a.source==="ast-callsite"):o.get(n.symbolId)??[];return typeof t.limit=="number"?s.slice(0,t.limit):s}function Se(e,n,t={}){let o=De(e)?ke(e,n,{semantic:t.semantic!==!1}):we(e).get(n.symbolId)??[];return typeof t.limit=="number"?o.slice(0,t.limit):o}var Le=z("caller-rows",{clearGroups:["whole-project"]}),_e=2e4;function De(e){return(e.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>_e}function we(e){return Le.get(e,()=>{let n=F(e),t=Ce(e,n),o=new Map;for(let i of n)o.set(i.symbol,i.symbolId);let s=new Map,a=new Map;for(let i of n){let l=t.get(i.symbolId);if(!(!l||l.length===0))for(let m of l){let c=o.get(m.symbol);if(c===void 0||c===i.symbolId)continue;let d=s.get(c);d||(d=[],s.set(c,d),a.set(c,new Set));let b=`${i.symbol}|${i.relativePath}`;a.get(c).has(b)||(a.get(c).add(b),d.push({symbol:i.symbol,file:i.relativePath,source:"caller-map-inversion"}))}}return s})}function ke(e,n,t){let o=[],s=new Set,a=l=>{if(l.symbol===n.symbol)return;let m=`${l.symbol}|${l.file}`;s.has(m)||(s.add(m),o.push(l))};for(let l of be(e,n))l.file!==n.relativePath&&a({symbol:l.enclosingSymbol??l.file,file:l.file,source:"resolved-reference"});let i=t.semantic?Ee(e,n):null;if(i)for(let l of ue(e,i)){if(l.file===n.relativePath||e.isIgnored(l.file))continue;let m=se(oe(e,l.file),l.line);a({symbol:m?.symbol??l.file,file:l.file,source:"semantic-reference"})}return o}function Ee(e,n){let t=ye().join(", "),o=ge().join(", ");return e.get(`SELECT
1
+ import{b as ae,c as O,d as T,e as H,k as pe,l as be}from"./chunk-FY6RCFDH.js";import{d as le,e as me,f as $,g as de,i as ue,l as fe}from"./chunk-KWMRY4RN.js";import{D as ce,n as re,x as j}from"./chunk-SQJ72PQW.js";import{a as ne}from"./chunk-QEIGJJBC.js";import{d as ye,e as ge}from"./chunk-MTDBHTSF.js";import{e as P,g as te,s as oe,t as F,y as ie,z as se}from"./chunk-7XP7ZRSI.js";import{k as E,m as X,p as ee}from"./chunk-JLZUM476.js";import{B as w,c as Z}from"./chunk-TLTLJ4SW.js";import{a as Y}from"./chunk-64MNV6AB.js";import{c as V,d as z,g as B,h as x,j as Q,l as K,q,s as D,y as N}from"./chunk-M2TRDR25.js";function Mn(e,n,t={}){let o=Ce(e,[n],{additive:t.additive,semantic:t.semantic}),s=t.callableOnly?(o.get(n.symbolId)??[]).filter(a=>te(a.symbol)||a.source==="ast-callsite"):o.get(n.symbolId)??[];return typeof t.limit=="number"?s.slice(0,t.limit):s}function Se(e,n,t={}){let o=De(e)?ke(e,n,{semantic:t.semantic!==!1}):we(e).get(n.symbolId)??[];return typeof t.limit=="number"?o.slice(0,t.limit):o}var Le=z("caller-rows",{clearGroups:["whole-project"]}),_e=2e4;function De(e){return(e.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>_e}function we(e){return Le.get(e,()=>{let n=F(e),t=Ce(e,n),o=new Map;for(let i of n)o.set(i.symbol,i.symbolId);let s=new Map,a=new Map;for(let i of n){let l=t.get(i.symbolId);if(!(!l||l.length===0))for(let m of l){let c=o.get(m.symbol);if(c===void 0||c===i.symbolId)continue;let d=s.get(c);d||(d=[],s.set(c,d),a.set(c,new Set));let b=`${i.symbol}|${i.relativePath}`;a.get(c).has(b)||(a.get(c).add(b),d.push({symbol:i.symbol,file:i.relativePath,source:"caller-map-inversion"}))}}return s})}function ke(e,n,t){let o=[],s=new Set,a=l=>{if(l.symbol===n.symbol)return;let m=`${l.symbol}|${l.file}`;s.has(m)||(s.add(m),o.push(l))};for(let l of be(e,n))l.file!==n.relativePath&&a({symbol:l.enclosingSymbol??l.file,file:l.file,source:"resolved-reference"});let i=t.semantic?Ee(e,n):null;if(i)for(let l of ue(e,i)){if(l.file===n.relativePath||e.isIgnored(l.file))continue;let m=se(oe(e,l.file),l.line);a({symbol:m?.symbol??l.file,file:l.file,source:"semantic-reference"})}return o}function Ee(e,n){let t=ye().join(", "),o=ge().join(", ");return e.get(`SELECT
2
2
  d.id AS documentId,
3
3
  gs.id AS symbolId,
4
4
  gs.symbol,
@@ -35,4 +35,4 @@ import{b as ae,c as O,d as T,e as H,k as pe,l as be}from"./chunk-MVFNACWB.js";im
35
35
  ) def_chunk ON def_chunk.symbol_id = gs.id
36
36
  WHERE gs.id IN (${r.map(()=>"?").join(",")})`,...r,...r)),l=J([...n.map(r=>r.documentId),...i.flatMap(r=>r.document_id===null?[]:[r.document_id])]),m=new Map(l.flatMap(r=>e.all(`SELECT id, relative_path FROM documents
37
37
  WHERE id IN (${r.map(()=>"?").join(",")})`,...r).map(y=>[y.id,y.relative_path]))),c=new Map;for(let r of i)c.has(r.symbol_id)||c.set(r.symbol_id,{symbol:r.symbol,file:r.document_id!==null?m.get(r.document_id)??"":""});let d=new Map,b=m,L=Ge(n);for(let[r,y]of L){let S=[...s.get(r)??[]].sort((u,g)=>u.start_line-g.start_line||u.end_line-g.end_line),v=[...y].sort((u,g)=>u.startLine-g.startLine||u.endLine-g.endLine),C=new Set,f=0;for(let u of v){for(;f<S.length&&S[f].start_line<=u.endLine;)C.add(S[f]),f+=1;for(let p of C)p.end_line<u.startLine&&C.delete(p);let g=new Set,k=[],R=null,G=()=>{if(R)return R;let p=b.get(u.documentId)??"",h=new Set;if(p){let I=ae(e,p),A=Math.max(0,u.startLine),W=Math.min(I.length-1,u.endLine);for(let _=A;_<=W;_+=1)for(let Ie of I[_])h.add(Ie)}return R=h,h};for(let p of C){if(p.symbol_id===u.symbolId)continue;let h=c.get(p.symbol_id);if(!h)continue;if(!(p.start_line>=u.startLine&&p.end_line<=u.endLine)){if(!(p.start_line<=u.endLine&&p.end_line>=u.startLine))continue;let _=P(h.symbol);if(!_||!G().has(_))continue}let A=`${h.symbol}|${p.chunk_id}`;g.has(A)||(g.add(A),k.push({...h,chunkId:p.chunk_id,source:"scip-chunk"}))}d.set(u.symbolId,k)}}return d}var he=500;function J(e){let n=[...new Set(e)],t=[];for(let o=0;o<n.length;o+=he)t.push(n.slice(o,o+he));return t}function Ge(e){let n=new Map;for(let t of e){let o=n.get(t.documentId);o?o.push(t):n.set(t.documentId,[t])}return n}function Be(e){let n=new Map;for(let[t,o]of e){let s=[];for(let a of o)s.push({symbol:a.symbol,file:a.file,chunkId:-1,source:"semantic-callee"});n.set(t,s)}return n}function Re(e,n,t={}){let o=new Map;if(n&&n.length===0)return o;let s=Y(e,{includeIgnored:!1}),a=H(e),i=n??F(e),l=new Set(i.map(c=>c.symbolId)),m=Qe(i);if(Ke(e,o,s,a,l,m),Je(e,o,i,l),ze(e,o,s,a,l,m),t.semantic!==!1){let c=$(e);Ze(o,c.callerMap(Ye(i)))}return o}function Ke(e,n,t,o,s,a){for(let i of t){if(!w(i))continue;let l=E(e,i);if(l)for(let m of l){if(a&&!a.has(m.calleeLeaf))continue;let c=O(i,o.get(m.calleeLeaf)??[]);if(!c||c.length===0)continue;let d=T(e,i,c,m.memberAccess);d&&s.has(d.symbolId)&&d.file!==i&&U(n,d.symbolId,i)}}}function Je(e,n,t,o){let s=We(t);for(let a of Ue(e,o))e.isIgnored(a.relative_path)||Ve(a,s.get(a.symbol_id))||U(n,a.symbol_id,a.relative_path)}function Ue(e,n){return le(e,n?[...n]:void 0)}function We(e){let n=new Map;for(let t of e)n.set(t.symbolId,{docId:t.documentId,startLine:t.startLine,endLine:t.endLine});return n}function Ve(e,n){return!!n&&n.docId===e.document_id&&e.chunk_start>=n.startLine&&e.chunk_end<=n.endLine}function ze(e,n,t,o,s,a){for(let i of t){if(w(i)!=="rust")continue;let l=X(e,i,{includeRustAttributeNames:!0});if(l.length!==0)for(let{name:m}of l){if(a&&!a.has(m))continue;let c=o.get(m);if(c)for(let d of c)s.has(d.symbolId)&&d.file!==i&&U(n,d.symbolId,i)}}}function U(e,n,t){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(t)}function Qe(e){let n=new Set;for(let t of e){let o="leaf"in t&&typeof t.leaf=="string"?t.leaf:"symbol"in t&&typeof t.symbol=="string"?P(t.symbol):"";o&&n.add(o)}return n.size>0?n:null}function Ye(e){return e.filter(n=>"relativePath"in n&&"symbol"in n&&"leaf"in n)}function Ze(e,n){for(let[t,o]of n){let s=e.get(t);s||(s=new Set,e.set(t,s));for(let a of o)s.add(a)}}function Pn(e,n,t={}){return Se(e,n,t)}function qe(e,n,t={}){return Re(e,n,t)}function Xe(e,n,t={}){return pe(e,n,t)}function Fn(e,n,t={}){let o=qe(e,n,{semantic:t.semantic});return t.sourceFallback===!1?o:en(o,Xe(e,n))}function en(e,n){let t=new Map;for(let[o,s]of e)t.set(o,new Set(s));for(let[o,s]of n){let a=t.get(o)??new Set;for(let i of s)a.add(i);t.set(o,a)}return t}export{Mn as a,Ce as b,Pn as c,qe as d,Xe as e,Fn as f,en as g};
38
- //# sourceMappingURL=chunk-TCOWAGR2.js.map
38
+ //# sourceMappingURL=chunk-3YEBIYXL.js.map
@@ -1,2 +1,2 @@
1
- import{b as A}from"./chunk-3EBDPBBU.js";import{a as _}from"./chunk-LC57FSPX.js";import{f as R,g as L}from"./chunk-VDHEX6YO.js";import{b as D}from"./chunk-B75HZHUP.js";import{a as E}from"./chunk-CYDOV3AQ.js";import{f as x,g as I}from"./chunk-5CJ6AQN7.js";import{a as w}from"./chunk-BGBBVSH4.js";import{d as N}from"./chunk-7XP7ZRSI.js";import{b as T,c as h}from"./chunk-JLZUM476.js";import{a as g}from"./chunk-64MNV6AB.js";import{y as S}from"./chunk-M2TRDR25.js";var F={caller:3,"entry-surface":2,rooted:1},O=/not\s*yet\s*implement|not\s*implement|unimplement|\bnyi\b|\btodo\b|\bstub\b|not\s*supported|coming\s*soon/i,P=/^throw\s+new\s+[\w.]*Error\s*\(([\s\S]*)\)\s*;?$/,C=/^return(\s+(null|undefined|false|0|''|""|``|\[\]|\{\}))?\s*;?$/,v=/\/\/\s*TODO\b|\/\*\s*TODO\b/i,K=/(?:=>|\))\s*(?::\s*[^{;=]+)?\s*\{\s*\}\s*;?\s*$/;function et(e,n={}){let{scope:o,limit:r=30,scanLimit:l,semantic:a=!0}=n,s=new E(e),t=D(s.productionCallableDefinitions({scope:o,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),l),c=[];for(let i of t){let m=M(e,i);m&&c.push(m)}if(c.length===0)return[];let d=j(e,c,t),f=c.filter(i=>!d.has(i.def.symbol));if(f.length===0)return[];let p=_(e,s).forDefinitions(f.map(i=>i.def),{semantic:a}),u=[];for(let i of f){let b=p.get(i.def.symbolId)?.realConsumers.length??0,y=B(e,i.def,b);y&&u.push({symbol:i.def.symbol,shortName:N(i.def.symbol),file:i.def.relativePath,startLine:i.def.startLine,endLine:i.def.endLine,loc:w(i.def),stubKind:i.stubKind,reachability:y,callerFanIn:b,stubText:i.stubText})}return u.sort((i,m)=>F[m.reachability]-F[i.reachability]||m.callerFanIn-i.callerFanIn||i.file.localeCompare(m.file)||i.startLine-m.startLine),r?u.slice(0,r):u}function B(e,n,o){return o>0?"caller":I(e,n.symbol,n.relativePath)?"rooted":x(e,n.relativePath)?"entry-surface":null}function M(e,n){let o=R(e,n);if(!o)return null;let r=L(o),l=r.trim();if(l==="")return!z(o)||!A(e,n)?null:{def:n,stubKind:"empty-body",stubText:"(empty body)"};let a=h(r),s=T(r),t=$(a,s);if(t.length!==1)return null;let c=t[0];return U(c)?{def:n,stubKind:"throw-stub",stubText:c.trim()}:v.test(r)&&C.test(c.trim())?{def:n,stubKind:"todo-return-default",stubText:l}:null}function $(e,n){let o=[],r=0,l="";for(let a=0;a<n.length;a+=1){let s=n[a];if(s==="("||s==="["||s==="{"?r+=1:(s===")"||s==="]"||s==="}")&&(r=Math.max(0,r-1)),s===";"&&r===0){o.push(l),l="";continue}l+=e[a]??""}return l.trim()&&o.push(l),o.map(a=>a.trim()).filter(a=>a.length>0)}function U(e){let n=P.exec(e.trim());return n?O.test(n[1]??""):!1}function z(e){return K.test(e.trimEnd())}function j(e,n,o){let r=new Set,l=new Set(n.map(t=>t.def.parentTypeName).filter(t=>t!==null));if(l.size===0)return r;let a=k(e,l),s=new Map;for(let t of o){if(!t.parentTypeName)continue;let c=s.get(t.leaf)??new Set;c.add(t.parentTypeName),s.set(t.leaf,c)}for(let t of n){let c=t.def.parentTypeName;if(!c)continue;let d=a.get(c);if(!d||d.size===0)continue;let f=s.get(t.def.leaf)??new Set;[...d].every(u=>f.has(u))&&r.add(t.def.symbol)}return r}var Y=/\bclass\s+([A-Za-z_$][\w$]*)\s+extends\s+([A-Za-z_$][\w$]*)/g;function k(e,n){let o=new Map;for(let r of g(e,{includeIgnored:!1})){let l=S(e,r);if(l)for(let a of l.matchAll(Y)){let s=a[1],t=a[2];if(!s||!t||!n.has(t))continue;let c=o.get(t)??new Set;c.add(s),o.set(t,c)}}return o}export{et as a};
2
- //# sourceMappingURL=chunk-H4SMB657.js.map
1
+ import{b as A}from"./chunk-BW4VDICR.js";import{a as _}from"./chunk-V7MX6YUF.js";import{f as R,g as L}from"./chunk-VDHEX6YO.js";import{b as D}from"./chunk-B75HZHUP.js";import{a as E}from"./chunk-BTYDBDX5.js";import{f as x,g as I}from"./chunk-5CJ6AQN7.js";import{a as w}from"./chunk-BGBBVSH4.js";import{d as N}from"./chunk-7XP7ZRSI.js";import{b as T,c as h}from"./chunk-JLZUM476.js";import{a as g}from"./chunk-64MNV6AB.js";import{y as S}from"./chunk-M2TRDR25.js";var F={caller:3,"entry-surface":2,rooted:1},O=/not\s*yet\s*implement|not\s*implement|unimplement|\bnyi\b|\btodo\b|\bstub\b|not\s*supported|coming\s*soon/i,P=/^throw\s+new\s+[\w.]*Error\s*\(([\s\S]*)\)\s*;?$/,C=/^return(\s+(null|undefined|false|0|''|""|``|\[\]|\{\}))?\s*;?$/,v=/\/\/\s*TODO\b|\/\*\s*TODO\b/i,K=/(?:=>|\))\s*(?::\s*[^{;=]+)?\s*\{\s*\}\s*;?\s*$/;function et(e,n={}){let{scope:o,limit:r=30,scanLimit:l,semantic:a=!0}=n,s=new E(e),t=D(s.productionCallableDefinitions({scope:o,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),l),c=[];for(let i of t){let m=M(e,i);m&&c.push(m)}if(c.length===0)return[];let d=j(e,c,t),f=c.filter(i=>!d.has(i.def.symbol));if(f.length===0)return[];let p=_(e,s).forDefinitions(f.map(i=>i.def),{semantic:a}),u=[];for(let i of f){let b=p.get(i.def.symbolId)?.realConsumers.length??0,y=B(e,i.def,b);y&&u.push({symbol:i.def.symbol,shortName:N(i.def.symbol),file:i.def.relativePath,startLine:i.def.startLine,endLine:i.def.endLine,loc:w(i.def),stubKind:i.stubKind,reachability:y,callerFanIn:b,stubText:i.stubText})}return u.sort((i,m)=>F[m.reachability]-F[i.reachability]||m.callerFanIn-i.callerFanIn||i.file.localeCompare(m.file)||i.startLine-m.startLine),r?u.slice(0,r):u}function B(e,n,o){return o>0?"caller":I(e,n.symbol,n.relativePath)?"rooted":x(e,n.relativePath)?"entry-surface":null}function M(e,n){let o=R(e,n);if(!o)return null;let r=L(o),l=r.trim();if(l==="")return!z(o)||!A(e,n)?null:{def:n,stubKind:"empty-body",stubText:"(empty body)"};let a=h(r),s=T(r),t=$(a,s);if(t.length!==1)return null;let c=t[0];return U(c)?{def:n,stubKind:"throw-stub",stubText:c.trim()}:v.test(r)&&C.test(c.trim())?{def:n,stubKind:"todo-return-default",stubText:l}:null}function $(e,n){let o=[],r=0,l="";for(let a=0;a<n.length;a+=1){let s=n[a];if(s==="("||s==="["||s==="{"?r+=1:(s===")"||s==="]"||s==="}")&&(r=Math.max(0,r-1)),s===";"&&r===0){o.push(l),l="";continue}l+=e[a]??""}return l.trim()&&o.push(l),o.map(a=>a.trim()).filter(a=>a.length>0)}function U(e){let n=P.exec(e.trim());return n?O.test(n[1]??""):!1}function z(e){return K.test(e.trimEnd())}function j(e,n,o){let r=new Set,l=new Set(n.map(t=>t.def.parentTypeName).filter(t=>t!==null));if(l.size===0)return r;let a=k(e,l),s=new Map;for(let t of o){if(!t.parentTypeName)continue;let c=s.get(t.leaf)??new Set;c.add(t.parentTypeName),s.set(t.leaf,c)}for(let t of n){let c=t.def.parentTypeName;if(!c)continue;let d=a.get(c);if(!d||d.size===0)continue;let f=s.get(t.def.leaf)??new Set;[...d].every(u=>f.has(u))&&r.add(t.def.symbol)}return r}var Y=/\bclass\s+([A-Za-z_$][\w$]*)\s+extends\s+([A-Za-z_$][\w$]*)/g;function k(e,n){let o=new Map;for(let r of g(e,{includeIgnored:!1})){let l=S(e,r);if(l)for(let a of l.matchAll(Y)){let s=a[1],t=a[2];if(!s||!t||!n.has(t))continue;let c=o.get(t)??new Set;c.add(s),o.set(t,c)}}return o}export{et as a};
2
+ //# sourceMappingURL=chunk-5QSMW5IO.js.map
@@ -1,4 +1,4 @@
1
- import{m as f}from"./chunk-MVFNACWB.js";import{a as d}from"./chunk-2HCWAL42.js";import{d as s,h as u,p as m,q as g}from"./chunk-7XP7ZRSI.js";import{y as c}from"./chunk-M2TRDR25.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(`
1
+ import{m as f}from"./chunk-FY6RCFDH.js";import{a as d}from"./chunk-2HCWAL42.js";import{d as s,h as u,p as m,q as g}from"./chunk-7XP7ZRSI.js";import{y as c}from"./chunk-M2TRDR25.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
2
  `).slice(i,n+1).join(`
3
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-AQ34B63A.js.map
4
+ //# sourceMappingURL=chunk-623AZLTE.js.map
@@ -1,2 +1,2 @@
1
- import{a as v}from"./chunk-JYBF5CPE.js";import{a as j}from"./chunk-75H6GOND.js";import{a as w}from"./chunk-AQ34B63A.js";import{a as p}from"./chunk-KAOWSWEX.js";import{a as H}from"./chunk-H4T2AST4.js";import{a as T}from"./chunk-Y3DG4J6A.js";import{a as P,b as A}from"./chunk-PA2MQKXD.js";import{b as D}from"./chunk-GRHA5NGF.js";import{a as S}from"./chunk-X566NT42.js";import{a as I}from"./chunk-ABRWGVC6.js";import{a as G}from"./chunk-HV4N3UBV.js";import{a as k}from"./chunk-7CHIAMKS.js";import{a as F}from"./chunk-IK2NG76R.js";function X(t,e,n={}){let o=n.impactDepth??3,r=n.sliceDepth??3,l=n.semantic,s=!z(e),a=s?w(t,e,{semantic:l}):{definitions:[],referencedBy:[]},m=s?k(t,e,{semantic:l}):null,f=s?I(t,e,{semantic:l}):null,h=s?T(t,e,{semantic:l}):null,y=s?p(t,e,{direction:"backward",maxDepth:r,semantic:l}):null,R=s?p(t,e,{direction:"forward",maxDepth:r,semantic:l}):null,d=s?G(t,e,{maxDepth:o,scope:n.scope}):[],i=F(t,e,{semantic:l}),C=P(t,e),g=A(t,e),u=j(t,e),x=v(t,e),c={symbol:a.definitions.length>0||a.referencedBy.length>0||m!==null||f!==null||h!==null||y!==null||R!==null||d.length>0,file:i!==null||C.length>0||g.length>0,module:u.files.length>0||u.symbols.length>0||x.length>0},b=[];!c.symbol&&!c.file&&!c.module&&b.push("No symbol, file, or module matched target.");let B=i?.file??a.definitions[0]?.relativePath??null;return{target:e,matched:c,history:O(t,B),trace:a,callGraph:m,complexity:f,dataflow:h,backwardSlice:y,forwardSlice:R,affected:d,changeSurface:i,deps:C,rdeps:g,system:u,surface:x,warnings:b}}function O(t,e){let n={available:!1,file:e,churn:null,coChangePartners:[],suppressionsInFile:0};if(!e)return n;let o=S(t).fileChurn();if(!o)return n;let r=D(t,e,{limit:5});return{available:!0,file:e,churn:o.get(e)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:r.findings.map(l=>({file:l.fileA===e?l.fileB:l.fileA,together:l.together,confidence:l.confidence,subjectContext:l.subjectContext})),suppressionsInFile:H(t).byFile.get(e)??0}}function z(t){return t.includes("/")||t.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(t)}export{X as a};
2
- //# sourceMappingURL=chunk-RZEVUYMG.js.map
1
+ import{a as v}from"./chunk-FZXN37RN.js";import{a as j}from"./chunk-75H6GOND.js";import{a as w}from"./chunk-623AZLTE.js";import{a as p}from"./chunk-KWQKWY6M.js";import{a as H}from"./chunk-H4T2AST4.js";import{a as T}from"./chunk-G4IUQW27.js";import{a as P,b as A}from"./chunk-PA2MQKXD.js";import{b as D}from"./chunk-GRHA5NGF.js";import{a as S}from"./chunk-X566NT42.js";import{a as I}from"./chunk-PPAT3XUL.js";import{a as G}from"./chunk-IHD2CHMX.js";import{a as k}from"./chunk-IKAJI4SI.js";import{a as F}from"./chunk-MBDBNQBW.js";function X(t,e,n={}){let o=n.impactDepth??3,r=n.sliceDepth??3,l=n.semantic,s=!z(e),a=s?w(t,e,{semantic:l}):{definitions:[],referencedBy:[]},m=s?k(t,e,{semantic:l}):null,f=s?I(t,e,{semantic:l}):null,h=s?T(t,e,{semantic:l}):null,y=s?p(t,e,{direction:"backward",maxDepth:r,semantic:l}):null,R=s?p(t,e,{direction:"forward",maxDepth:r,semantic:l}):null,d=s?G(t,e,{maxDepth:o,scope:n.scope}):[],i=F(t,e,{semantic:l}),C=P(t,e),g=A(t,e),u=j(t,e),x=v(t,e),c={symbol:a.definitions.length>0||a.referencedBy.length>0||m!==null||f!==null||h!==null||y!==null||R!==null||d.length>0,file:i!==null||C.length>0||g.length>0,module:u.files.length>0||u.symbols.length>0||x.length>0},b=[];!c.symbol&&!c.file&&!c.module&&b.push("No symbol, file, or module matched target.");let B=i?.file??a.definitions[0]?.relativePath??null;return{target:e,matched:c,history:O(t,B),trace:a,callGraph:m,complexity:f,dataflow:h,backwardSlice:y,forwardSlice:R,affected:d,changeSurface:i,deps:C,rdeps:g,system:u,surface:x,warnings:b}}function O(t,e){let n={available:!1,file:e,churn:null,coChangePartners:[],suppressionsInFile:0};if(!e)return n;let o=S(t).fileChurn();if(!o)return n;let r=D(t,e,{limit:5});return{available:!0,file:e,churn:o.get(e)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:r.findings.map(l=>({file:l.fileA===e?l.fileB:l.fileA,together:l.together,confidence:l.confidence,subjectContext:l.subjectContext})),suppressionsInFile:H(t).byFile.get(e)??0}}function z(t){return t.includes("/")||t.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(t)}export{X as a};
2
+ //# sourceMappingURL=chunk-6TJERPN3.js.map
@@ -1,2 +1,2 @@
1
- import{a as f}from"./chunk-CYDOV3AQ.js";import{a as L}from"./chunk-2HCWAL42.js";import{d as i,e as b,f as u,l as c}from"./chunk-7XP7ZRSI.js";import{f as l}from"./chunk-JLZUM476.js";import{B as a}from"./chunk-TLTLJ4SW.js";function S(o,s){let t=L(o,s);if(!t)return[];let e=new f(o).definitionsForFile(t.relativePath).filter(r=>r.symbol!==t.symbol).filter(r=>c(t.symbol,r.symbol)).sort((r,m)=>r.startLine-m.startLine||r.endLine-m.endLine).map(r=>({symbol:r.symbol,shortName:i(r.symbol),startLine:r.startLine,endLine:r.endLine,kind:u(r.symbol)??"unknown"}));return a(t.relativePath)!=="clojure"?e:d(e,y(o,t))}function y(o,s){let t=b(s.symbol);if(!t)return[];let n=i(s.symbol);return(l(o,s.relativePath)?.clojureMembers??[]).filter(e=>e.ownerName===t).map(e=>({symbol:`${s.symbol}${e.memberName}().`,shortName:`${n}:${e.memberName}()`,startLine:e.startLine,endLine:e.endLine,kind:e.memberKind}))}function d(o,s){let t=new Map;for(let n of[...o,...s])t.set(`${n.shortName}:${n.startLine}:${n.endLine}`,n);return[...t.values()].sort((n,e)=>n.startLine-e.startLine||n.endLine-e.endLine)}export{S as a};
2
- //# sourceMappingURL=chunk-NJBARXRO.js.map
1
+ import{a as f}from"./chunk-BTYDBDX5.js";import{a as L}from"./chunk-2HCWAL42.js";import{d as i,e as b,f as u,l as c}from"./chunk-7XP7ZRSI.js";import{f as l}from"./chunk-JLZUM476.js";import{B as a}from"./chunk-TLTLJ4SW.js";function S(o,s){let t=L(o,s);if(!t)return[];let e=new f(o).definitionsForFile(t.relativePath).filter(r=>r.symbol!==t.symbol).filter(r=>c(t.symbol,r.symbol)).sort((r,m)=>r.startLine-m.startLine||r.endLine-m.endLine).map(r=>({symbol:r.symbol,shortName:i(r.symbol),startLine:r.startLine,endLine:r.endLine,kind:u(r.symbol)??"unknown"}));return a(t.relativePath)!=="clojure"?e:d(e,y(o,t))}function y(o,s){let t=b(s.symbol);if(!t)return[];let n=i(s.symbol);return(l(o,s.relativePath)?.clojureMembers??[]).filter(e=>e.ownerName===t).map(e=>({symbol:`${s.symbol}${e.memberName}().`,shortName:`${n}:${e.memberName}()`,startLine:e.startLine,endLine:e.endLine,kind:e.memberKind}))}function d(o,s){let t=new Map;for(let n of[...o,...s])t.set(`${n.shortName}:${n.startLine}:${n.endLine}`,n);return[...t.values()].sort((n,e)=>n.startLine-e.startLine||n.endLine-e.endLine)}export{S as a};
2
+ //# sourceMappingURL=chunk-7H37Z4UO.js.map
@@ -1,2 +1,2 @@
1
- import{d as D}from"./chunk-HGO3D2JD.js";import{f as m,g as p}from"./chunk-VDHEX6YO.js";import{a as L}from"./chunk-UWR52GNZ.js";import{b as v}from"./chunk-B75HZHUP.js";import{a as E}from"./chunk-CYDOV3AQ.js";import{a as C}from"./chunk-BGBBVSH4.js";import{a as y}from"./chunk-TCOWAGR2.js";import{b}from"./chunk-2HCWAL42.js";import{d as f,s as g}from"./chunk-7XP7ZRSI.js";import{c as u,f as h}from"./chunk-JLZUM476.js";var A=/^(?:validate|verify|check|assert)(?:[A-Z].*)?$/,N=/^(?:is|has)(?:[A-Z].*)?$/,S=/[{,]\s*(?:ok|success|valid|isValid)\s*:\s*false\b/,d=/\breturn\b/g,k=/\bfunction\b|=>|\)\s*(?::\s*[^{;=]+)?\s*\{/,I=/\.(?:addIssue|push)\s*\(/;function Y(e,t={}){let{scope:n,limit:i=30,scanLimit:l}=t,a=new E(e),r=v(a.productionCallableDefinitions({scope:n,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),l),s=[];for(let o of r){let c=w(e,o);c&&s.push({symbol:o.symbol,shortName:f(o.symbol),file:o.relativePath,startLine:o.startLine,endLine:o.endLine,loc:C(o),...c})}return s.sort((o,c)=>o.file.localeCompare(c.file)||o.startLine-c.startLine||o.loc-c.loc),i?s.slice(0,i):s}function _(e){return A.test(e)?"imperative":N.test(e)?"predicate":null}function w(e,t){let n=_(t.leaf);if(!n||L(e,t))return null;let i=m(e,t);if(!i||!k.test(i))return null;let l=h(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine);if(n==="predicate"&&l?.paramCount===0)return null;if(D(i)){let r=K(e,t);return!r||T(r.body,R(r.snippet))||x(r.body)?null:{nameKind:n,resolvedVia:"one-hop-delegate",delegateTarget:r.shortName}}let a=p(i);return T(a,R(i))||x(a)?null:{nameKind:n,resolvedVia:"direct"}}var P=new Set(["if","for","while","switch","catch","function"]);function x(e){let t=u(e);for(let n of t.matchAll(/\b([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\(/g))if(!P.has(n[1]))return!0;return!1}function R(e){let t=e.indexOf("=>");return t===-1?!1:!/^\s*\{/.test(e.slice(t+2))}function T(e,t){let n=u(e);if(/\bthrow\b/.test(n)||/\.reject\s*\(/.test(n)||S.test(n)||I.test(n))return!0;let i=F(n);if(t&&i.length===0){let l=n.trim();return l!==""&&l!=="true"}for(let l of i)if(l!==""&&l!=="true")return!0;return!1}function F(e){let t=[];d.lastIndex=0;let n;for(;n=d.exec(e);){let i=n.index+n[0].length,l=0,a=e.length;for(let r=i;r<e.length;r+=1){let s=e[r];if(s==="("||s==="["||s==="{")l+=1;else if(s===")"||s==="]"||s==="}"){if(l===0){a=r;break}l-=1}else if(s===";"&&l===0){a=r;break}}t.push(e.slice(i,a).trim()),d.lastIndex=a}return t}function K(e,t){let n=y(e,t,{callableOnly:!0,limit:3}),i=[...new Set(n.map(o=>o.symbol))].filter(o=>o!==t.symbol);if(i.length!==1)return null;let a=b(e,i[0]).match;if(!a)return null;let r=g(e,a.relativePath).find(o=>o.symbolId===a.symbolId);if(!r)return null;let s=m(e,r);return s?{body:p(s),snippet:s,shortName:f(r.symbol)}:null}export{Y as a};
2
- //# sourceMappingURL=chunk-VT2KFEPG.js.map
1
+ import{d as D}from"./chunk-HGO3D2JD.js";import{f as m,g as p}from"./chunk-VDHEX6YO.js";import{a as L}from"./chunk-UWR52GNZ.js";import{b as v}from"./chunk-B75HZHUP.js";import{a as E}from"./chunk-BTYDBDX5.js";import{a as C}from"./chunk-BGBBVSH4.js";import{a as y}from"./chunk-3YEBIYXL.js";import{b}from"./chunk-2HCWAL42.js";import{d as f,s as g}from"./chunk-7XP7ZRSI.js";import{c as u,f as h}from"./chunk-JLZUM476.js";var A=/^(?:validate|verify|check|assert)(?:[A-Z].*)?$/,N=/^(?:is|has)(?:[A-Z].*)?$/,S=/[{,]\s*(?:ok|success|valid|isValid)\s*:\s*false\b/,d=/\breturn\b/g,k=/\bfunction\b|=>|\)\s*(?::\s*[^{;=]+)?\s*\{/,I=/\.(?:addIssue|push)\s*\(/;function Y(e,t={}){let{scope:n,limit:i=30,scanLimit:l}=t,a=new E(e),r=v(a.productionCallableDefinitions({scope:n,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),l),s=[];for(let o of r){let c=w(e,o);c&&s.push({symbol:o.symbol,shortName:f(o.symbol),file:o.relativePath,startLine:o.startLine,endLine:o.endLine,loc:C(o),...c})}return s.sort((o,c)=>o.file.localeCompare(c.file)||o.startLine-c.startLine||o.loc-c.loc),i?s.slice(0,i):s}function _(e){return A.test(e)?"imperative":N.test(e)?"predicate":null}function w(e,t){let n=_(t.leaf);if(!n||L(e,t))return null;let i=m(e,t);if(!i||!k.test(i))return null;let l=h(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine);if(n==="predicate"&&l?.paramCount===0)return null;if(D(i)){let r=K(e,t);return!r||T(r.body,R(r.snippet))||x(r.body)?null:{nameKind:n,resolvedVia:"one-hop-delegate",delegateTarget:r.shortName}}let a=p(i);return T(a,R(i))||x(a)?null:{nameKind:n,resolvedVia:"direct"}}var P=new Set(["if","for","while","switch","catch","function"]);function x(e){let t=u(e);for(let n of t.matchAll(/\b([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\(/g))if(!P.has(n[1]))return!0;return!1}function R(e){let t=e.indexOf("=>");return t===-1?!1:!/^\s*\{/.test(e.slice(t+2))}function T(e,t){let n=u(e);if(/\bthrow\b/.test(n)||/\.reject\s*\(/.test(n)||S.test(n)||I.test(n))return!0;let i=F(n);if(t&&i.length===0){let l=n.trim();return l!==""&&l!=="true"}for(let l of i)if(l!==""&&l!=="true")return!0;return!1}function F(e){let t=[];d.lastIndex=0;let n;for(;n=d.exec(e);){let i=n.index+n[0].length,l=0,a=e.length;for(let r=i;r<e.length;r+=1){let s=e[r];if(s==="("||s==="["||s==="{")l+=1;else if(s===")"||s==="]"||s==="}"){if(l===0){a=r;break}l-=1}else if(s===";"&&l===0){a=r;break}}t.push(e.slice(i,a).trim()),d.lastIndex=a}return t}function K(e,t){let n=y(e,t,{callableOnly:!0,limit:3}),i=[...new Set(n.map(o=>o.symbol))].filter(o=>o!==t.symbol);if(i.length!==1)return null;let a=b(e,i[0]).match;if(!a)return null;let r=g(e,a.relativePath).find(o=>o.symbolId===a.symbolId);if(!r)return null;let s=m(e,r);return s?{body:p(s),snippet:s,shortName:f(r.symbol)}:null}export{Y as a};
2
+ //# sourceMappingURL=chunk-BBTVIIOI.js.map
@@ -1,2 +1,2 @@
1
- import{b as I,f as W,g as Y}from"./chunk-5CJ6AQN7.js";import{a as x}from"./chunk-BGBBVSH4.js";import{b as U,d as X,e as Z,f as $}from"./chunk-TCOWAGR2.js";import{a as _,f as z,g as J,i as N,j as Q}from"./chunk-MVFNACWB.js";import{a as B}from"./chunk-QEIGJJBC.js";import{a as j,g as k,h as T,j as V,k as G,s as D,u as H,v as O,w as P}from"./chunk-7XP7ZRSI.js";import{m as F}from"./chunk-JLZUM476.js";import{B as R,C as E,L as K}from"./chunk-TLTLJ4SW.js";import{a as q}from"./chunk-64MNV6AB.js";import{B as h,s as w,y as A}from"./chunk-M2TRDR25.js";function ee(n,e,t){let r=e.identifierResolution==="strict"?N:Q,l=e.candidateNames?z(e.candidateNames):null,o=0,f=0,m=0,p=0,y="";for(let a of e.paths)if(o+=1,y=a,!(!R(a)&&!(e.includeVueSfc&&E(a)))&&!n.isIgnored(a)&&!e.skipPath?.(a))try{if(l&&!J(A(n,a),l))continue;f+=1;let S=(s,u,v,b)=>{if(e.candidateNames&&!e.candidateNames.has(s))return;m+=1;let g=e.resolveTargets?e.resolveTargets({sourceFile:a,name:s,kind:u,defaultTargets:b}):b();for(let L of g)p+=1,t({sourceFile:a,name:s,target:L,occurrences:v,kind:u})},M=_(n,a);for(let[s,u]of M)S(s,"identifier",u.length,()=>r(n,a,s));for(let s of F(n,a,{includeCrossLanguageDispatchNames:e.includeCrossLanguageDispatchNames,includeRustAttributeNames:e.includeRustAttributeNames})){let u=s.kind==="cross-language-dispatch"?()=>N(n,a,s.name):()=>r(n,a,s.name);S(s.name,s.kind,s.occurrences,u)}}finally{e.afterPath?.(a),o%10===0&&w("source-reference-scan.progress",()=>{},()=>({scannedPaths:o,currentPath:y,candidateMatchedPaths:f,visitedNames:m,visitedHits:p}))}}function ne(n,e={}){let{scope:t,files:r,minLoc:l=1,maxLoc:o=Number.POSITIVE_INFINITY,excludeSymbol:f,excludeEntrySurfaces:m=!1,excludeTypesFiles:p=!1,excludeRootedSymbols:y=!1,requireFunctionLikeSymbol:a=!1,requireCallableSymbol:C=!1,excludeRustTraitImplMembers:S=!1,includeSuppressed:M=!1,sortByLocDesc:s=!1}=e,u=[],v=re(n,{scope:t,files:r,requireFunctionLikeSymbol:a,requireCallableSymbol:C}),b=new Map,g=new Map,L=i=>{let c=b.get(i);if(c!==void 0)return c;let d=W(n,i);return b.set(i,d),d},ie=i=>{let c=g.get(i);if(c!==void 0)return c;let d=I(i);return g.set(i,d),d};for(let i of v){let c=i.relativePath;if(n.isIgnored(c)||m&&L(c)||!oe(i,{requireFunctionLikeSymbol:a,requireCallableSymbol:C})||f!==void 0&&i.symbol===f)continue;let d=x(i);d<l||d>o||p&&ae(c)||y&&Y(n,i.symbol,c)||S&&V(i.symbol)||ie(c)!=="test"&&(G(i.symbol)||!M&&h(n,c,i.startLine)||u.push(i))}return s?u.sort((i,c)=>x(c)-x(i)):u}function re(n,e){return e.files!==void 0?[...new Set(e.files.map(r=>r.replace(/\\/g,"/")))].sort().filter(r=>!e.scope||r.includes(e.scope)).flatMap(r=>D(n,r)):e.requireCallableSymbol?P(n,{scope:e.scope,symbolMatches:k,sqlPrefilter:"callable"}):e.requireFunctionLikeSymbol?P(n,{scope:e.scope,symbolMatches:T,sqlPrefilter:"function-like"}):O(n,e.scope)}function oe(n,e){return e.requireCallableSymbol?k(n.symbol):e.requireFunctionLikeSymbol?T(n.symbol):n.isFunctionLike}function ae(n){return(n.split("/").pop()??"").includes("types")}var te=class{constructor(e){this.db=e}db;scopedDefinitions(e){return H(this.db,e)}definitionsForFile(e){return D(this.db,e)}productionCallableDefinitions(e={}){return ne(this.db,e)}calleeMap(e,t={}){return U(this.db,e,t)}crossFileCallerMap(e,t={}){return X(this.db,e,t)}sourceFallbackCallerFiles(e,t={}){return Z(this.db,e,t)}callerFileMap(e,t={}){return $(this.db,e,t)}frameworkReferencedSymbolIds(e){let t=new Map;for(let l of e){if(!l.leaf)continue;let o=t.get(l.leaf)??[];o.push(l.symbolId),t.set(l.leaf,o)}let r=new Set;for(let l of q(this.db,{includeIgnored:!1}))if(R(l)==="rust")for(let{name:o}of F(this.db,l,{includeRustAttributeNames:!0}))for(let f of t.get(o)??[])r.add(f);return r}symbolsWithNonSelfCallees(e,t={}){if(e.length===0)return new Set;let r=new Map(e.map(o=>[o.symbolId,o.symbol])),l=this.calleeMap(e,t);return new Set([...l.entries()].filter(([o,f])=>{let m=r.get(o);return f.some(p=>p.symbol!==m)}).map(([o])=>o))}fileDependencyGraph(e){return B(this.db,e)}fileKind(e){return I(e)}hasSuppressionComment(e){return h(this.db,e.relativePath,e.startLine)}sourceFiles(){return K(this.db)}scanSourceReferences(e,t){ee(this.db,e,t)}callableSignature(e){let t=j(this.db).forFile(e.relativePath,{facts:!0}).facts?.callables.find(r=>r.startLine===e.startLine&&r.endLine===e.endLine);return t?{paramCount:t.paramCount}:null}};export{te as a};
2
- //# sourceMappingURL=chunk-CYDOV3AQ.js.map
1
+ import{b as I,f as W,g as Y}from"./chunk-5CJ6AQN7.js";import{a as x}from"./chunk-BGBBVSH4.js";import{b as U,d as X,e as Z,f as $}from"./chunk-3YEBIYXL.js";import{a as _,f as z,g as J,i as N,j as Q}from"./chunk-FY6RCFDH.js";import{a as B}from"./chunk-QEIGJJBC.js";import{a as j,g as k,h as T,j as V,k as G,s as D,u as H,v as O,w as P}from"./chunk-7XP7ZRSI.js";import{m as F}from"./chunk-JLZUM476.js";import{B as R,C as E,L as K}from"./chunk-TLTLJ4SW.js";import{a as q}from"./chunk-64MNV6AB.js";import{B as h,s as w,y as A}from"./chunk-M2TRDR25.js";function ee(n,e,t){let r=e.identifierResolution==="strict"?N:Q,l=e.candidateNames?z(e.candidateNames):null,o=0,f=0,m=0,p=0,y="";for(let a of e.paths)if(o+=1,y=a,!(!R(a)&&!(e.includeVueSfc&&E(a)))&&!n.isIgnored(a)&&!e.skipPath?.(a))try{if(l&&!J(A(n,a),l))continue;f+=1;let S=(s,u,v,b)=>{if(e.candidateNames&&!e.candidateNames.has(s))return;m+=1;let g=e.resolveTargets?e.resolveTargets({sourceFile:a,name:s,kind:u,defaultTargets:b}):b();for(let L of g)p+=1,t({sourceFile:a,name:s,target:L,occurrences:v,kind:u})},M=_(n,a);for(let[s,u]of M)S(s,"identifier",u.length,()=>r(n,a,s));for(let s of F(n,a,{includeCrossLanguageDispatchNames:e.includeCrossLanguageDispatchNames,includeRustAttributeNames:e.includeRustAttributeNames})){let u=s.kind==="cross-language-dispatch"?()=>N(n,a,s.name):()=>r(n,a,s.name);S(s.name,s.kind,s.occurrences,u)}}finally{e.afterPath?.(a),o%10===0&&w("source-reference-scan.progress",()=>{},()=>({scannedPaths:o,currentPath:y,candidateMatchedPaths:f,visitedNames:m,visitedHits:p}))}}function ne(n,e={}){let{scope:t,files:r,minLoc:l=1,maxLoc:o=Number.POSITIVE_INFINITY,excludeSymbol:f,excludeEntrySurfaces:m=!1,excludeTypesFiles:p=!1,excludeRootedSymbols:y=!1,requireFunctionLikeSymbol:a=!1,requireCallableSymbol:C=!1,excludeRustTraitImplMembers:S=!1,includeSuppressed:M=!1,sortByLocDesc:s=!1}=e,u=[],v=re(n,{scope:t,files:r,requireFunctionLikeSymbol:a,requireCallableSymbol:C}),b=new Map,g=new Map,L=i=>{let c=b.get(i);if(c!==void 0)return c;let d=W(n,i);return b.set(i,d),d},ie=i=>{let c=g.get(i);if(c!==void 0)return c;let d=I(i);return g.set(i,d),d};for(let i of v){let c=i.relativePath;if(n.isIgnored(c)||m&&L(c)||!oe(i,{requireFunctionLikeSymbol:a,requireCallableSymbol:C})||f!==void 0&&i.symbol===f)continue;let d=x(i);d<l||d>o||p&&ae(c)||y&&Y(n,i.symbol,c)||S&&V(i.symbol)||ie(c)!=="test"&&(G(i.symbol)||!M&&h(n,c,i.startLine)||u.push(i))}return s?u.sort((i,c)=>x(c)-x(i)):u}function re(n,e){return e.files!==void 0?[...new Set(e.files.map(r=>r.replace(/\\/g,"/")))].sort().filter(r=>!e.scope||r.includes(e.scope)).flatMap(r=>D(n,r)):e.requireCallableSymbol?P(n,{scope:e.scope,symbolMatches:k,sqlPrefilter:"callable"}):e.requireFunctionLikeSymbol?P(n,{scope:e.scope,symbolMatches:T,sqlPrefilter:"function-like"}):O(n,e.scope)}function oe(n,e){return e.requireCallableSymbol?k(n.symbol):e.requireFunctionLikeSymbol?T(n.symbol):n.isFunctionLike}function ae(n){return(n.split("/").pop()??"").includes("types")}var te=class{constructor(e){this.db=e}db;scopedDefinitions(e){return H(this.db,e)}definitionsForFile(e){return D(this.db,e)}productionCallableDefinitions(e={}){return ne(this.db,e)}calleeMap(e,t={}){return U(this.db,e,t)}crossFileCallerMap(e,t={}){return X(this.db,e,t)}sourceFallbackCallerFiles(e,t={}){return Z(this.db,e,t)}callerFileMap(e,t={}){return $(this.db,e,t)}frameworkReferencedSymbolIds(e){let t=new Map;for(let l of e){if(!l.leaf)continue;let o=t.get(l.leaf)??[];o.push(l.symbolId),t.set(l.leaf,o)}let r=new Set;for(let l of q(this.db,{includeIgnored:!1}))if(R(l)==="rust")for(let{name:o}of F(this.db,l,{includeRustAttributeNames:!0}))for(let f of t.get(o)??[])r.add(f);return r}symbolsWithNonSelfCallees(e,t={}){if(e.length===0)return new Set;let r=new Map(e.map(o=>[o.symbolId,o.symbol])),l=this.calleeMap(e,t);return new Set([...l.entries()].filter(([o,f])=>{let m=r.get(o);return f.some(p=>p.symbol!==m)}).map(([o])=>o))}fileDependencyGraph(e){return B(this.db,e)}fileKind(e){return I(e)}hasSuppressionComment(e){return h(this.db,e.relativePath,e.startLine)}sourceFiles(){return K(this.db)}scanSourceReferences(e,t){ee(this.db,e,t)}callableSignature(e){let t=j(this.db).forFile(e.relativePath,{facts:!0}).facts?.callables.find(r=>r.startLine===e.startLine&&r.endLine===e.endLine);return t?{paramCount:t.paramCount}:null}};export{te as a};
2
+ //# sourceMappingURL=chunk-BTYDBDX5.js.map
@@ -1,3 +1,3 @@
1
- import{a as S}from"./chunk-TAB7AWKO.js";import{a as y}from"./chunk-BGUYAA3Q.js";import{a as P}from"./chunk-B75HZHUP.js";import{a as x}from"./chunk-CYDOV3AQ.js";import{a as h,g as b}from"./chunk-5CJ6AQN7.js";import{a as v}from"./chunk-BGBBVSH4.js";import{d as l,e as p,h as d}from"./chunk-7XP7ZRSI.js";import{a as u,h as m,i as g}from"./chunk-JLZUM476.js";import{z as f}from"./chunk-M2TRDR25.js";import{basename as L,extname as D}from"path";function K(n,e){let{scope:i,maxLoc:t=15,limit:r=30,scanLimit:a}=e??{},s=new x(n);return y({candidates:()=>A(n,s,i,t),orderCandidates:P,scanLimit:a,profile:{name:"passthrough-candidates"},prepare:o=>s.calleeMap(o,{semantic:e?.semantic!==!1}),evaluate:(o,c)=>w(n,o,c.get(o.symbolId)??[]),orderResults:(o,c)=>o.loc-c.loc||o.file.localeCompare(c.file),limit:r})}function w(n,e,i){let t=j(i);if(t.size!==1||!m(n,e.relativePath,e.startLine,e.endLine))return null;let[,r]=[...t.entries()][0],a=I(n,e,r),s=T(n,e),o=a.length>0||s.length>0?"signal":"direct";return{symbol:e.symbol,shortName:l(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:v(e),forwardsTo:r.symbol,forwardsToShort:l(r.symbol),forwardsToFile:r.file,actionTier:o,boundaryEvidence:a,publicFacadeEvidence:s,recommendation:E(o,a,s)}}function I(n,e,i){return S(n,e.relativePath,e.startLine,"passthrough","explicit ignore-passthrough comment",[{label:"passthrough name",value:l(e.symbol)},{label:"callee name",value:l(i.symbol)},{label:"passthrough module",value:L(e.relativePath,D(e.relativePath))},{label:"callee module",value:L(i.file,D(i.file))}])}function E(n,e,i){if(n==="signal"){if(i.length>0)return`Review the public API before inlining; public-facade evidence: ${i.slice(0,2).join("; ")}.`;let t=e.filter(F);return t.length>0?`Review the public API before inlining; public-surface evidence: ${t.slice(0,2).join("; ")}.`:`Review the boundary before inlining; boundary evidence: ${e.slice(0,2).join("; ")}.`}return"Inline or remove this passthrough unless an external API or runtime registration depends on the forwarding name."}function T(n,e){return C(n,e)?h(n,e.relativePath)?["exported passthrough is declared on the package public surface"]:b(n,e.symbol,e.relativePath)?["exported passthrough matches configured or framework public entry surface"]:[]:[]}function C(n,e){let i=f(n,e.relativePath);if(i.length===0)return!1;let t=p(e.symbol);if(!t)return!1;let r=i.slice(Math.max(0,e.startLine-2),e.startLine+1).join(`
1
+ import{a as S}from"./chunk-TAB7AWKO.js";import{a as y}from"./chunk-BGUYAA3Q.js";import{a as P}from"./chunk-B75HZHUP.js";import{a as x}from"./chunk-BTYDBDX5.js";import{a as h,g as b}from"./chunk-5CJ6AQN7.js";import{a as v}from"./chunk-BGBBVSH4.js";import{d as l,e as p,h as d}from"./chunk-7XP7ZRSI.js";import{a as u,h as m,i as g}from"./chunk-JLZUM476.js";import{z as f}from"./chunk-M2TRDR25.js";import{basename as L,extname as D}from"path";function K(n,e){let{scope:i,maxLoc:t=15,limit:r=30,scanLimit:a}=e??{},s=new x(n);return y({candidates:()=>A(n,s,i,t),orderCandidates:P,scanLimit:a,profile:{name:"passthrough-candidates"},prepare:o=>s.calleeMap(o,{semantic:e?.semantic!==!1}),evaluate:(o,c)=>w(n,o,c.get(o.symbolId)??[]),orderResults:(o,c)=>o.loc-c.loc||o.file.localeCompare(c.file),limit:r})}function w(n,e,i){let t=j(i);if(t.size!==1||!m(n,e.relativePath,e.startLine,e.endLine))return null;let[,r]=[...t.entries()][0],a=I(n,e,r),s=T(n,e),o=a.length>0||s.length>0?"signal":"direct";return{symbol:e.symbol,shortName:l(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:v(e),forwardsTo:r.symbol,forwardsToShort:l(r.symbol),forwardsToFile:r.file,actionTier:o,boundaryEvidence:a,publicFacadeEvidence:s,recommendation:E(o,a,s)}}function I(n,e,i){return S(n,e.relativePath,e.startLine,"passthrough","explicit ignore-passthrough comment",[{label:"passthrough name",value:l(e.symbol)},{label:"callee name",value:l(i.symbol)},{label:"passthrough module",value:L(e.relativePath,D(e.relativePath))},{label:"callee module",value:L(i.file,D(i.file))}])}function E(n,e,i){if(n==="signal"){if(i.length>0)return`Review the public API before inlining; public-facade evidence: ${i.slice(0,2).join("; ")}.`;let t=e.filter(F);return t.length>0?`Review the public API before inlining; public-surface evidence: ${t.slice(0,2).join("; ")}.`:`Review the boundary before inlining; boundary evidence: ${e.slice(0,2).join("; ")}.`}return"Inline or remove this passthrough unless an external API or runtime registration depends on the forwarding name."}function T(n,e){return C(n,e)?h(n,e.relativePath)?["exported passthrough is declared on the package public surface"]:b(n,e.symbol,e.relativePath)?["exported passthrough matches configured or framework public entry surface"]:[]:[]}function C(n,e){let i=f(n,e.relativePath);if(i.length===0)return!1;let t=p(e.symbol);if(!t)return!1;let r=i.slice(Math.max(0,e.startLine-2),e.startLine+1).join(`
2
2
  `),a=u(t);return new RegExp(`^\\s*export\\s+(?:default\\s+)?(?:(?:async\\s+)?function\\s+${a}\\b|(?:const|let|var)\\s+${a}\\b)`,"m").test(r)?!0:R(i,t)}function R(n,e){if(!e)return!1;let i=new RegExp(`^\\s*export\\s*\\{[^}\\n]*\\b${u(e)}\\b`);return n.some(t=>i.test(t))}function F(n){return n.includes("public surface")}function j(n){let e=n.some(t=>d(t.symbol))?n.filter(t=>d(t.symbol)):n,i=new Map;for(let t of e)i.has(t.symbol)||i.set(t.symbol,t);return i}function A(n,e,i,t){return e.productionCallableDefinitions({scope:i,minLoc:3,maxLoc:t,requireFunctionLikeSymbol:!0,excludeRustTraitImplMembers:!0}).filter(r=>!g(n,r))}export{K as a,C as b};
3
- //# sourceMappingURL=chunk-3EBDPBBU.js.map
3
+ //# sourceMappingURL=chunk-BW4VDICR.js.map
@@ -1,7 +1,7 @@
1
- import{b as k}from"./chunk-JUADXGUH.js";import{a as D}from"./chunk-CYDOV3AQ.js";import{f as v,g as L}from"./chunk-5CJ6AQN7.js";import{l as S}from"./chunk-MVFNACWB.js";import{d as h,s as y}from"./chunk-7XP7ZRSI.js";function z(e,n={}){let{scope:s,minLoc:c=1,maxDepth:a=5,scanLimit:f}=n,t=new D(e),i=_(e,s,c,f),o=new P;for(let r of i)o.add(r);let m=[],I=[];i.length>0&&m.push(C(e,0,i,o));let b=i.map(r=>r.definition).filter(r=>r!==null),x=new Set(i.map(r=>r.symbol));for(let r=1;r<=a&&b.length>0;r++){let u=t.calleeMap(b,{semantic:!1}),E=new Set;for(let d of b)for(let l of u.get(d.symbolId)??[])x.has(l.symbol)||E.add(l.symbol);let p=[];for(let d of E){x.add(d);let l=F(e,d);if(!l||e.isIgnored(l.relativePath)||v(e,l.relativePath)||L(e,l.symbol,l.relativePath)||t.fileKind(l.relativePath)==="test"||t.hasSuppressionComment(l))continue;let g=B(e,l,o);g.removable?p.push(w(l,"cascade")):g.blockingFiles.length>0&&I.push({shortName:h(l.symbol),file:l.relativePath,blockingFiles:g.blockingFiles.slice(0,3)})}if(p.length===0)break;for(let d of p)o.add(d);m.push(C(e,r,p,o)),b=p.map(d=>d.definition).filter(d=>d!==null)}let N=m.reduce((r,u)=>r+u.loc,0),R=m.reduce((r,u)=>r+u.entries.length,0);return{batches:m,totalSymbols:R,totalLoc:N,blocked:I}}function _(e,n,s,c){let a=k(e,{scope:n,minLoc:s,skipBarrels:!0,deadCodeOnly:!0,scanLimit:c,semantic:!1}),f=[];for(let t of a.symbols)t.kind==="dead-code"&&(v(e,t.relativePath)||L(e,t.symbol,t.relativePath)||f.push({symbol:t.symbol,shortName:t.shortName,file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:t.loc,evidence:"graph-fact",definition:F(e,t.symbol)}));return f}function w(e,n){return{symbol:e.symbol,shortName:h(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1,evidence:n,definition:e}}function F(e,n){let s=e.get(`SELECT d.relative_path
1
+ import{b as k}from"./chunk-UKUISUS6.js";import{a as D}from"./chunk-BTYDBDX5.js";import{f as v,g as L}from"./chunk-5CJ6AQN7.js";import{l as S}from"./chunk-FY6RCFDH.js";import{d as h,s as y}from"./chunk-7XP7ZRSI.js";function z(e,n={}){let{scope:s,minLoc:c=1,maxDepth:a=5,scanLimit:f}=n,t=new D(e),i=_(e,s,c,f),o=new P;for(let r of i)o.add(r);let m=[],I=[];i.length>0&&m.push(C(e,0,i,o));let b=i.map(r=>r.definition).filter(r=>r!==null),x=new Set(i.map(r=>r.symbol));for(let r=1;r<=a&&b.length>0;r++){let u=t.calleeMap(b,{semantic:!1}),E=new Set;for(let d of b)for(let l of u.get(d.symbolId)??[])x.has(l.symbol)||E.add(l.symbol);let p=[];for(let d of E){x.add(d);let l=F(e,d);if(!l||e.isIgnored(l.relativePath)||v(e,l.relativePath)||L(e,l.symbol,l.relativePath)||t.fileKind(l.relativePath)==="test"||t.hasSuppressionComment(l))continue;let g=B(e,l,o);g.removable?p.push(w(l,"cascade")):g.blockingFiles.length>0&&I.push({shortName:h(l.symbol),file:l.relativePath,blockingFiles:g.blockingFiles.slice(0,3)})}if(p.length===0)break;for(let d of p)o.add(d);m.push(C(e,r,p,o)),b=p.map(d=>d.definition).filter(d=>d!==null)}let N=m.reduce((r,u)=>r+u.loc,0),R=m.reduce((r,u)=>r+u.entries.length,0);return{batches:m,totalSymbols:R,totalLoc:N,blocked:I}}function _(e,n,s,c){let a=k(e,{scope:n,minLoc:s,skipBarrels:!0,deadCodeOnly:!0,scanLimit:c,semantic:!1}),f=[];for(let t of a.symbols)t.kind==="dead-code"&&(v(e,t.relativePath)||L(e,t.symbol,t.relativePath)||f.push({symbol:t.symbol,shortName:t.shortName,file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:t.loc,evidence:"graph-fact",definition:F(e,t.symbol)}));return f}function w(e,n){return{symbol:e.symbol,shortName:h(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1,evidence:n,definition:e}}function F(e,n){let s=e.get(`SELECT d.relative_path
2
2
  FROM global_symbols gs
3
3
  JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
4
4
  JOIN documents d ON d.id = der.document_id
5
5
  WHERE gs.symbol = ?
6
6
  LIMIT 1`,n);return s?y(e,s.relative_path).find(c=>c.symbol===n)??null:null}function B(e,n,s){let c=S(e,n);if(c.length===0)return{removable:!1,blockingFiles:[]};let a=new Set;for(let f of c)f.file===n.relativePath&&f.line>=n.startLine&&f.line<=n.endLine||s.contains(f.file,f.line)||a.add(f.file);return{removable:a.size===0,blockingFiles:[...a]}}function C(e,n,s,c){let a=[...s].sort((i,o)=>i.file.localeCompare(o.file)||i.startLine-o.startLine),f=new Set(a.map(i=>i.file)),t=[];for(let i of f){let o=y(e,i);o.length>0&&o.every(m=>c.contains(i,m.startLine))&&t.push(i)}return{depth:n,entries:a.map(({definition:i,...o})=>o),loc:a.reduce((i,o)=>i+o.loc,0),filesEmptied:t.sort()}}var P=class{ranges=new Map;add(n){let s=this.ranges.get(n.file)??[];s.push({start:n.startLine,end:n.endLine}),this.ranges.set(n.file,s)}contains(n,s){let c=this.ranges.get(n);return c?c.some(a=>s>=a.start&&s<=a.end):!1}};export{z as a,P as b};
7
- //# sourceMappingURL=chunk-JVTMRIKU.js.map
7
+ //# sourceMappingURL=chunk-CKRVVBM6.js.map
@@ -1,3 +1,3 @@
1
- import{m as d}from"./chunk-MVFNACWB.js";import{a as h}from"./chunk-2HCWAL42.js";import{h as g}from"./chunk-7XP7ZRSI.js";import{a as p}from"./chunk-64MNV6AB.js";import{y as m}from"./chunk-M2TRDR25.js";function _(t,r,n={}){let e=h(t,r);if(!e)return[];let l=!g(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=d(t,e,{semantic:n.semantic}).map(o=>({relativePath:o.file,line:o.line})),s=R(t,e),f=new Set,a=[];for(let o of[...l,...c,...s]){let u=`${o.relativePath}:${o.line}`;f.has(u)||(f.add(u),a.push(o))}return a}function R(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=b(r.symbol);if(n.length===0)return[];let e=[];for(let i of p(t,{extensions:[".rb"],includeIgnored:!1})){let l=m(t,i);if(!l)continue;let c=l.split(`
1
+ import{m as d}from"./chunk-FY6RCFDH.js";import{a as h}from"./chunk-2HCWAL42.js";import{h as g}from"./chunk-7XP7ZRSI.js";import{a as p}from"./chunk-64MNV6AB.js";import{y as m}from"./chunk-M2TRDR25.js";function _(t,r,n={}){let e=h(t,r);if(!e)return[];let l=!g(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=d(t,e,{semantic:n.semantic}).map(o=>({relativePath:o.file,line:o.line})),s=R(t,e),f=new Set,a=[];for(let o of[...l,...c,...s]){let u=`${o.relativePath}:${o.line}`;f.has(u)||(f.add(u),a.push(o))}return a}function R(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=b(r.symbol);if(n.length===0)return[];let e=[];for(let i of p(t,{extensions:[".rb"],includeIgnored:!1})){let l=m(t,i);if(!l)continue;let c=l.split(`
2
2
  `);for(let s=0;s<c.length;s++){let f=c[s]??"";n.some(a=>new RegExp(`@${a}\\b|\\b${a}:`).test(f))&&e.push({relativePath:i,line:s})}}return e}function b(t){let n=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),e=n.split("_").filter(Boolean),i=new Set;return n&&i.add(n),e.length>=1&&i.add(e[e.length-1]),e.length>=2&&i.add(e.slice(-2).join("_")),[...i]}export{_ as a};
3
- //# sourceMappingURL=chunk-6G3GQWTK.js.map
3
+ //# sourceMappingURL=chunk-CSMPXDYE.js.map
@@ -1,4 +1,4 @@
1
- import{b as w}from"./chunk-3EBDPBBU.js";import{b as g}from"./chunk-2HCWAL42.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-7XP7ZRSI.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`/**
1
+ import{b as w}from"./chunk-BW4VDICR.js";import{b as g}from"./chunk-2HCWAL42.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-7XP7ZRSI.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
2
  * Generated by 'scip-query twin-ab'. scip-integrity-audit drill 5
3
3
  * ("cross-examine same-concept twins"): where one concept is computed in
4
4
  * more than one place, feed both the same input and require the same
@@ -37,4 +37,4 @@ describe.skipIf(inputs.length === 0)('twin-ab: ${t.shortName} vs ${n.shortName}'
37
37
  });
38
38
  });
39
39
  `}export{O as a,I as b};
40
- //# sourceMappingURL=chunk-KYUYAWKA.js.map
40
+ //# sourceMappingURL=chunk-E5HPTSRD.js.map
@@ -0,0 +1,2 @@
1
+ import{execFileSync as y}from"child_process";import{platform as G}from"os";var h=G()==="win32";function S(t){let e=h?"where":"which";try{return y(e,[t],{stdio:"pipe"}),!0}catch{return!1}}import{spawnSync as R}from"child_process";import{createHash as x}from"crypto";import{existsSync as b,lstatSync as w,realpathSync as v}from"fs";import{dirname as I,isAbsolute as E,join as W,resolve as d}from"path";var a={run(t,e){let r=l(t,e);return r.kind==="success"?r.output:void 0},runResult:l};function $(t,e=a){let r=C(t,e);if(r.kind!=="worktree")return;let o=r.identity,n=o.projectRoot,i=e.run(n,["rev-parse","--git-common-dir"])?.trim();if(!i)return;let s=u(p(n,i)),m=c(e.run(n,["rev-parse","--verify","HEAD"])),k=c(e.run(n,["rev-parse","--verify","HEAD^{tree}"])),f=e.run(n,["status","--porcelain=v1","-z","--untracked-files=all"]);if(f!==void 0)return{...o,commonDir:s,repositoryId:g("repository",s),headCommit:m,treeOid:k,clean:f.length===0}}function C(t,e=a){let r=e.runResult(t,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let o=r.output.trim();if(!o)return{kind:"error",message:"Git returned an empty worktree root."};let n=u(o),i=e.run(n,["rev-parse","--absolute-git-dir"])?.trim();if(!i)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=u(p(n,i));return{kind:"worktree",identity:{projectRoot:n,gitDir:s,worktreeId:g("worktree",`${n}\0${s}`)}}}function H(t,e,r=a){return c(r.run(t,e))}function p(t,e){return E(e)?e:d(t,e)}function u(t){try{return v(t)}catch{return d(t)}}function g(t,e){return x("sha256").update(`${t}\0${e}`).digest("hex").slice(0,24)}function c(t){return t?.trim()||void 0}function l(t,e){let r=R("git",["-C",t,...e],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"]});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let n=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,i=r.error?.code;return(/not a git repository/i.test(n)||i==="ENOENT"&&b(d(t)))&&!D(t)?{kind:"not-repository"}:{kind:"error",message:n}}function D(t){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let e=d(t);for(;;){try{return w(W(e,".git")),!0}catch(o){let n=o.code;if(n!=="ENOENT"&&n!=="ENOTDIR")return!0}let r=I(e);if(r===e)return!1;e=r}}export{S as a,$ as b,H as c,p as d,u as e};
2
+ //# sourceMappingURL=chunk-E7BTIEAY.js.map
@@ -1,4 +1,4 @@
1
- import{a as B}from"./chunk-WXVGNFAO.js";import{a as _}from"./chunk-CYDOV3AQ.js";import{e as N}from"./chunk-TCOWAGR2.js";import{j as M}from"./chunk-QNCVN5EH.js";import{d as R,g as y,i as F}from"./chunk-7XP7ZRSI.js";import{E as w}from"./chunk-TLTLJ4SW.js";import{execFileSync as g}from"child_process";import{existsSync as q,readFileSync as H}from"fs";import{basename as v}from"path";var J="Unable to compute git diff.";function Be(e,n={}){let i=n.plan??Z(e,n);return i.note?j(i.note,i.changedFileLines):i.changedFiles.length===0?V(i.changedFileLines):Y(i.changedFiles,[G(e,i.changedFiles,i.changedFiles,i.changedRanges)])}function Z(e,n={}){let{base:i="HEAD"}=n;try{let t=K(e.config.projectRoot,i),r=oe(e,t),o=se(e,Q(e.config.projectRoot,i));return{changedFileLines:t,changedFiles:r,changedRanges:o,renamedFiles:ne(e.config.projectRoot,i,r),note:t.length===0?"No changed files found.":void 0}}catch{return{changedFileLines:[],changedFiles:[],changedRanges:[],renamedFiles:[],note:J}}}function G(e,n,i,t=[]){let r=new _(e),o=new Set(i),s=B(t),a=[],l=new Map,d=n.flatMap(u=>r.definitionsForFile(u)).filter(Le),f=d.filter(u=>ce(u,s)),c=le(e,d,f,s),m=me([...f,...c.definitions]).sort((u,h)=>u.relativePath.localeCompare(h.relativePath)||u.startLine-h.startLine),p=m.map(u=>u.symbolId),C=ye(e,p),z=be(e,p,i),I=m.filter(u=>(C.get(u.symbolId)??0)===0),x=T(()=>M(e,I)),W=I.filter(u=>(x.get(u.symbolId)?.size??0)===0),U=T(()=>N(e,W));for(let u of m)he(e,u,o,a,l,x.get(u.symbolId)??new Set,U.get(u.symbolId)??new Set,C.get(u.symbolId)??0,z.get(u.symbolId)??new Set);return{changedSymbols:a,consumerEntries:[...l.entries()].map(([u,h])=>({file:u,symbols:[...h].sort()})),attributionNotes:c.notes}}function Y(e,n){let i=new Map,t=n.flatMap(s=>s.changedSymbols),r=n.flatMap(s=>s.attributionNotes??[]);for(let s of n)for(let a of s.consumerEntries){let l=i.get(a.file);l||(l=new Set,i.set(a.file,l));for(let d of a.symbols)l.add(d)}let o=Se(i);return{changedFiles:[...e],changedSymbols:t,affectedConsumers:o,attributionNotes:r,summary:{totalChangedFiles:e.length,totalChangedSymbols:t.length,totalAffectedFiles:o.length}}}function j(e,n=[]){return{changedFiles:n,changedSymbols:[],affectedConsumers:[],attributionNotes:[],summary:{totalChangedFiles:n.length,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function V(e){return{changedFiles:e,changedSymbols:[],affectedConsumers:[],attributionNotes:[],summary:{totalChangedFiles:e.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}}}function K(e,n){let i=g("git",["diff","--name-only",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=g("git",["diff","--name-only","--cached",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),r=g("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024});return[...new Set([i,t,r].flatMap(o=>o.split(`
1
+ import{a as B}from"./chunk-WXVGNFAO.js";import{a as _}from"./chunk-BTYDBDX5.js";import{e as N}from"./chunk-3YEBIYXL.js";import{j as M}from"./chunk-KWMRY4RN.js";import{d as R,g as y,i as F}from"./chunk-7XP7ZRSI.js";import{E as w}from"./chunk-TLTLJ4SW.js";import{execFileSync as g}from"child_process";import{existsSync as q,readFileSync as H}from"fs";import{basename as v}from"path";var J="Unable to compute git diff.";function Be(e,n={}){let i=n.plan??Z(e,n);return i.note?j(i.note,i.changedFileLines):i.changedFiles.length===0?V(i.changedFileLines):Y(i.changedFiles,[G(e,i.changedFiles,i.changedFiles,i.changedRanges)])}function Z(e,n={}){let{base:i="HEAD"}=n;try{let t=K(e.config.projectRoot,i),r=oe(e,t),o=se(e,Q(e.config.projectRoot,i));return{changedFileLines:t,changedFiles:r,changedRanges:o,renamedFiles:ne(e.config.projectRoot,i,r),note:t.length===0?"No changed files found.":void 0}}catch{return{changedFileLines:[],changedFiles:[],changedRanges:[],renamedFiles:[],note:J}}}function G(e,n,i,t=[]){let r=new _(e),o=new Set(i),s=B(t),a=[],l=new Map,d=n.flatMap(u=>r.definitionsForFile(u)).filter(Le),f=d.filter(u=>ce(u,s)),c=le(e,d,f,s),m=me([...f,...c.definitions]).sort((u,h)=>u.relativePath.localeCompare(h.relativePath)||u.startLine-h.startLine),p=m.map(u=>u.symbolId),C=ye(e,p),z=be(e,p,i),I=m.filter(u=>(C.get(u.symbolId)??0)===0),x=T(()=>M(e,I)),W=I.filter(u=>(x.get(u.symbolId)?.size??0)===0),U=T(()=>N(e,W));for(let u of m)he(e,u,o,a,l,x.get(u.symbolId)??new Set,U.get(u.symbolId)??new Set,C.get(u.symbolId)??0,z.get(u.symbolId)??new Set);return{changedSymbols:a,consumerEntries:[...l.entries()].map(([u,h])=>({file:u,symbols:[...h].sort()})),attributionNotes:c.notes}}function Y(e,n){let i=new Map,t=n.flatMap(s=>s.changedSymbols),r=n.flatMap(s=>s.attributionNotes??[]);for(let s of n)for(let a of s.consumerEntries){let l=i.get(a.file);l||(l=new Set,i.set(a.file,l));for(let d of a.symbols)l.add(d)}let o=Se(i);return{changedFiles:[...e],changedSymbols:t,affectedConsumers:o,attributionNotes:r,summary:{totalChangedFiles:e.length,totalChangedSymbols:t.length,totalAffectedFiles:o.length}}}function j(e,n=[]){return{changedFiles:n,changedSymbols:[],affectedConsumers:[],attributionNotes:[],summary:{totalChangedFiles:n.length,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function V(e){return{changedFiles:e,changedSymbols:[],affectedConsumers:[],attributionNotes:[],summary:{totalChangedFiles:e.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}}}function K(e,n){let i=g("git",["diff","--name-only",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=g("git",["diff","--name-only","--cached",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),r=g("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024});return[...new Set([i,t,r].flatMap(o=>o.split(`
2
2
  `)).map(o=>o.trim()).filter(o=>o.length>0))]}function Q(e,n){let i=g("git",["diff","--unified=0",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=g("git",["diff","--unified=0","--cached",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024});return O([...E(i),...E(t)])}function L(e,n,i){try{return g("git",["show",`${n}:./${i}`],{encoding:"utf-8",cwd:e,timeout:1e4,stdio:["ignore","pipe","ignore"]})}catch{return null}}function ve(e,n,i=[]){let t=X(e,n,i);return r=>(t.has(r)||t.set(r,L(e,n,r)),t.get(r)??null)}function Ae(e,n=e.changedFiles){let i=new Map(e.renamedFiles.map(t=>[t.to,t.from]));return[...new Set(n.map(t=>i.get(t)??t))]}function X(e,n,i){let t=[...new Set(i)],r=new Map;if(t.length===0)return r;try{let o=t.map(a=>`${n}:./${a}
3
3
  `).join(""),s=g("git",["cat-file","--batch"],{cwd:e,input:o,maxBuffer:256*1024*1024,timeout:1e4,stdio:["pipe","pipe","ignore"]});return ee(s,t)}catch{for(let o of t)r.set(o,L(e,n,o));return r}}function ee(e,n){let i=new Map,t=0;for(let r of n){let o=e.indexOf(10,t);if(o<0)throw new Error("git cat-file batch output ended before object header");let s=e.subarray(t,o).toString("utf-8");if(t=o+1,s.endsWith(" missing")){i.set(r,null);continue}let a=/^[0-9a-f]+ ([^ ]+) (\d+)$/.exec(s);if(!a)throw new Error(`unexpected git cat-file batch header: ${s}`);let[,l,d]=a,f=Number(d);if(!Number.isFinite(f)||f<0)throw new Error(`unexpected git cat-file batch size: ${s}`);if(t+f>e.length)throw new Error("git cat-file batch output ended before blob payload");let c=e.subarray(t,t+f);i.set(r,l==="blob"?c.toString("utf-8"):null),t+=f,e[t]===10&&(t+=1)}return i}function ne(e,n,i){if(i.length===0)return[];let t=new Map,r=new Set;for(let s of ie(e,n))i.includes(s.to)&&(t.set(s.to,s),r.add(s.from));let o=te(e,n);if(o.length===0)return[...t.values()].sort((s,a)=>s.to.localeCompare(a.to));for(let s of i){if(t.has(s)||!q(`${e}/${s}`))continue;let a=o.filter(f=>!r.has(f)).filter(f=>v(f)===v(s));if(a.length===0)continue;let l=H(`${e}/${s}`,"utf-8"),d=a.map(f=>({from:f,to:s,similarity:re(L(e,n,f)??"",l)})).sort((f,c)=>c.similarity-f.similarity)[0];d&&d.similarity>=.45&&(t.set(s,d),r.add(d.from))}return[...t.values()].sort((s,a)=>s.to.localeCompare(a.to))}function te(e,n){let i=g("git",["diff","--name-only","--diff-filter=D",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=g("git",["diff","--name-only","--diff-filter=D","--cached",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024});return[...new Set([...P(i),...P(t)])]}function ie(e,n){let i=g("git",["diff","--name-status","--find-renames",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=g("git",["diff","--name-status","--find-renames","--cached",n],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024});return[...i.split(`
4
4
  `),...t.split(`
@@ -18,4 +18,4 @@ import{a as B}from"./chunk-WXVGNFAO.js";import{a as _}from"./chunk-CYDOV3AQ.js";
18
18
  AND m.role != 1
19
19
  AND ref_d.relative_path NOT IN (${i.map(()=>"?").join(",")})
20
20
  ${e.pathExclusionsFor("ref_d")}`,...n,...i),r=new Map;for(let o of t){let s=r.get(o.symbol_id);s||(s=new Set,r.set(o.symbol_id,s)),s.add(o.relative_path)}return r}function S(e,n,i,t,r){if(e.isIgnored(t)||n.has(t))return;let o=i.get(t);o||(o=new Set,i.set(t,o)),o.add(r)}function Se(e){return[...e.entries()].map(([n,i])=>({file:n,consumedSymbols:i.size})).sort((n,i)=>i.consumedSymbols-n.consumedSymbols)}function Le(e){return!(F(e.symbol)||e.parentTypeName!==null&&!y(e.symbol))}function De(e,n){return y(e.symbol)||e.isTypeLike?!0:e.parentTypeName===null&&n>0}export{J as a,Be as b,Z as c,G as d,Y as e,L as f,ve as g,Ae as h,X as i,fe as j};
21
- //# sourceMappingURL=chunk-KLFCCRI7.js.map
21
+ //# sourceMappingURL=chunk-EUMETOTD.js.map
@@ -1,4 +1,4 @@
1
- import{d as A,i as T}from"./chunk-QNCVN5EH.js";import{d as I}from"./chunk-2HCWAL42.js";import{e as d,s as w,z as P}from"./chunk-7XP7ZRSI.js";import{a as v,b as F,f as h,p as y}from"./chunk-JLZUM476.js";import{B as k,L as R,a as D,c as p}from"./chunk-TLTLJ4SW.js";import{c as u,d as M,y as m}from"./chunk-M2TRDR25.js";function L(e,r,n,t={}){if(!n)return[];let i=m(e,r);return i?i.indexOf(n)===-1?[]:(x(e,r).get(n)??[]).filter(o=>!J(o,t)):[]}function J(e,r){return typeof r.excludeStartLine=="number"&&typeof r.excludeEndLine=="number"&&e>=r.excludeStartLine&&e<=r.excludeEndLine}var Y=u("file-identifiers",{clearGroups:["whole-project","source-file"]});function O(e,r){let n=h(e,r);return n?n.fileIdentifiers:Y.get(e,r,()=>new Set(x(e,r).keys()))}var W=u("file-ident-lines",{clearGroups:["whole-project","source-file"]});function x(e,r){let n=h(e,r);return n?n.identifierLineMap:W.get(e,r,()=>X(e,r))}var V=u("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function pe(e,r){let n=h(e,r);return n?n.identifiersByLine:V.get(e,r,()=>{let t=x(e,r),i=0;for(let o of t.values()){let c=o[o.length-1];c!==void 0&&c>i&&(i=c)}let a=new Array(i+1);for(let o=0;o<=i;o+=1)a[o]=new Set;for(let[o,c]of t)for(let s of c)a[s].add(o);return a})}function X(e,r){let n=new Map,t=(c,s)=>{let l=n.get(c);if(!l){n.set(c,[s]);return}l[l.length-1]!==s&&l.push(s)},i=m(e,r);if(!i)return n;let a=F(i).split(/\r?\n/),o=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<a.length;c+=1){let s=a[c]??"";for(let l of s.matchAll(o))l[1]&&t(l[1],c)}return n}function Le(e,r){let n=z(e);return n?r.filter(t=>z(t.file)===n):r}function _e(e,r,n,t){let i=n.find(a=>a.file===r);if(i)return i;if(t){let a=new Set(y(e,r).map(o=>o.sourcePath).filter(o=>!!o));for(let o of n)for(let c of a)if(p(c,o.file))return o;return null}return n.length===1?n[0]:null}function z(e){let r=k(e);return r?r==="typescript"||r==="tsx"||r==="javascript"?"javascript-family":r:null}var q=M("global-leaf-index",{clearGroups:["whole-project"]});function E(e){return q.get(e,()=>{let r=e.all(`SELECT gs.id, gs.symbol,
1
+ import{d as A,i as T}from"./chunk-KWMRY4RN.js";import{d as I}from"./chunk-2HCWAL42.js";import{e as d,s as w,z as P}from"./chunk-7XP7ZRSI.js";import{a as v,b as F,f as h,p as y}from"./chunk-JLZUM476.js";import{B as k,L as R,a as D,c as p}from"./chunk-TLTLJ4SW.js";import{c as u,d as M,y as m}from"./chunk-M2TRDR25.js";function L(e,r,n,t={}){if(!n)return[];let i=m(e,r);return i?i.indexOf(n)===-1?[]:(x(e,r).get(n)??[]).filter(o=>!J(o,t)):[]}function J(e,r){return typeof r.excludeStartLine=="number"&&typeof r.excludeEndLine=="number"&&e>=r.excludeStartLine&&e<=r.excludeEndLine}var Y=u("file-identifiers",{clearGroups:["whole-project","source-file"]});function O(e,r){let n=h(e,r);return n?n.fileIdentifiers:Y.get(e,r,()=>new Set(x(e,r).keys()))}var W=u("file-ident-lines",{clearGroups:["whole-project","source-file"]});function x(e,r){let n=h(e,r);return n?n.identifierLineMap:W.get(e,r,()=>X(e,r))}var V=u("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function pe(e,r){let n=h(e,r);return n?n.identifiersByLine:V.get(e,r,()=>{let t=x(e,r),i=0;for(let o of t.values()){let c=o[o.length-1];c!==void 0&&c>i&&(i=c)}let a=new Array(i+1);for(let o=0;o<=i;o+=1)a[o]=new Set;for(let[o,c]of t)for(let s of c)a[s].add(o);return a})}function X(e,r){let n=new Map,t=(c,s)=>{let l=n.get(c);if(!l){n.set(c,[s]);return}l[l.length-1]!==s&&l.push(s)},i=m(e,r);if(!i)return n;let a=F(i).split(/\r?\n/),o=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<a.length;c+=1){let s=a[c]??"";for(let l of s.matchAll(o))l[1]&&t(l[1],c)}return n}function Le(e,r){let n=z(e);return n?r.filter(t=>z(t.file)===n):r}function _e(e,r,n,t){let i=n.find(a=>a.file===r);if(i)return i;if(t){let a=new Set(y(e,r).map(o=>o.sourcePath).filter(o=>!!o));for(let o of n)for(let c of a)if(p(c,o.file))return o;return null}return n.length===1?n[0]:null}function z(e){let r=k(e);return r?r==="typescript"||r==="tsx"||r==="javascript"?"javascript-family":r:null}var q=M("global-leaf-index",{clearGroups:["whole-project"]});function E(e){return q.get(e,()=>{let r=e.all(`SELECT gs.id, gs.symbol,
2
2
  COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
3
3
  FROM global_symbols gs
4
4
  LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
@@ -13,4 +13,4 @@ import{d as A,i as T}from"./chunk-QNCVN5EH.js";import{d as I}from"./chunk-2HCWAL
13
13
  ) mention_doc ON mention_doc.symbol_id = gs.id
14
14
  WHERE 1 = 1
15
15
  ${e.symbolNoiseFor("gs")}`),n=new Map;for(let t of r){if(!t.relative_path||e.isIgnored(t.relative_path))continue;let i=d(t.symbol);if(!i)continue;let a=n.get(i);a||(a=[],n.set(i,a)),a.some(o=>o.symbolId===t.id)||a.push({symbol:t.symbol,symbolId:t.id,file:t.relative_path})}return n})}var K=u("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function $(e,r){let n=D(r);return K.get(e,n,()=>Q(e,n))}function Q(e,r){let n=new Map;for(let t of y(e,r)){if(!t.sourcePath)continue;let i=t.localName??t.importedName;if(i&&j(n,i,t.sourcePath),t.kind==="namespace")for(let a of t.usedMembers)j(n,a,t.sourcePath)}return n}function j(e,r,n){let t=e.get(r);t||(t=new Set,e.set(r,t)),t.add(n)}var B=/[A-Za-z_$][A-Za-z0-9_$]*/g,G=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ee=512;function C(e){let r=[],n=!1;for(let t of e)t&&(n=!0,G.test(t)||r.push(t));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:r}}function H(e,r){let n=te(r)?r:C(r);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=ee){for(let i of n.candidateNames)if(i){if(G.test(i)){if(ne(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}B.lastIndex=0;let t;for(;(t=B.exec(e))!==null;)if(n.candidateNames.has(t[0]))return!0;for(let i of n.nonIdentifierNames)if(e.includes(i))return!0;return!1}function te(e){return"candidateNames"in e}function ne(e){return new RegExp(`(?<![A-Za-z_$0-9])${v(e)}(?![A-Za-z_$0-9])`)}function N(e,r,n){let t=E(e).get(n);if(!t||t.length===0)return[];if(t.length===1)return[g(t[0])];let i=t.filter(s=>s.file===r);if(i.length>0)return i.map(g);let a=$(e,r),o=a.get(n);if(o)for(let s of o){let l=t.filter(f=>p(s,f.file));if(l.length>0)return l.map(g)}let c=new Set;for(let s of a.values())for(let l of s)c.add(l);for(let s of c){let l=t.filter(f=>p(s,f.file));if(l.length>0&&l.length===t.length)return l.map(g)}return[]}function Be(e,r,n){let t=N(e,r,n);if(t.length>0)return t;let i=E(e).get(n);return!i||i.length===0?[]:i.map(g)}function U(e,r,n={}){let t=I(e,r);if(!t)return[];let i=d(t.symbol);if(!i)return[];if(n.semantic!==!1){let o=T(e,{...t,leaf:i,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(o.length>0){let c=new Map;for(let s of o){let l=c.get(s.file)??[];l.push(s.line),c.set(s.file,l)}return _(e,c)}}let a=new Map;for(let o of R(e)){let c=m(e,o);if(!c||c.indexOf(i)===-1||o!==t.relativePath&&!N(e,o,i).some(f=>f.symbolId===t.symbolId))continue;let s=L(e,o,i,o===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{});s.length>0&&a.set(o,s)}return _(e,a)}function Ge(e,r,n={}){let t=new Map;for(let s of r){if(!s.leaf)continue;let l=t.get(s.leaf)??[];l.push(s),t.set(s.leaf,l)}if(t.size===0)return new Map;let i=new Set(r.map(s=>s.symbolId)),a=new Set(t.keys()),o=C(a),c=new Map;for(let s of R(e)){if(n.skipPath?.(s)||!H(m(e,s),o))continue;let l=O(e,s);if(l.size!==0){for(let f of l)if(t.has(f))for(let b of N(e,s,f)){if(!i.has(b.symbolId)||s===b.relativePath)continue;let S=c.get(b.symbolId);S||(S=new Set,c.set(b.symbolId,S)),S.add(s)}}}return c}function g(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function _(e,r){let n=[],t=new Set;for(let[i,a]of r){let o=w(e,i);for(let c of a){let s=P(o,c),l=`${i}|${c}|${s?.symbol??""}`;t.has(l)||(t.add(l),n.push({file:i,line:c,enclosingSymbol:s?.symbol??null}))}}return n}function re(e,r){let n=le(e,r);return n?_(e,oe(e,n.match,n.identifier)):[]}function Ve(e,r,n={}){return ie(e,r,n).map(t=>({file:t.file,line:t.line,enclosingSymbol:t.enclosingSymbol}))}function ie(e,r,n={}){let t=U(e,r,{semantic:n.semantic}),i=t.length>0?Z(t,"source-attribution"):Z(re(e,r),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(a=>!e.isIgnored(a.file))}function Z(e,r){return e.map(n=>({...n,provenance:r}))}function oe(e,r,n){let t=new Map;for(let[i,a]of se(e,r.symbolId))t.set(i,ae(e,i,a,r,n));return t}function se(e,r){let n=new Map;for(let t of A(e,[r])){if(e.isIgnored(t.relative_path))continue;let i=n.get(t.relative_path);i||(i=[],n.set(t.relative_path,i)),i.push({start_line:t.chunk_start,end_line:t.chunk_end})}return n}function ae(e,r,n,t,i){let a=r===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{},o=i?L(e,r,i,a):[];return n.flatMap(c=>ce(o,c))}function ce(e,r){let n=e.filter(t=>t>=r.start_line&&t<=r.end_line);return n.length>0?n:[r.start_line]}function le(e,r){let n=I(e,r);return n?{match:n,identifier:d(n.symbol)||null}:null}export{x as a,pe as b,Le as c,_e as d,E as e,C as f,H as g,$ as h,N as i,Be as j,Ge as k,re as l,Ve as m};
16
- //# sourceMappingURL=chunk-MVFNACWB.js.map
16
+ //# sourceMappingURL=chunk-FY6RCFDH.js.map
@@ -1,4 +1,4 @@
1
- import{b as l}from"./chunk-5N5ZC566.js";import{a}from"./chunk-CYDOV3AQ.js";import{d as i,g as n}from"./chunk-7XP7ZRSI.js";function _(e,r){let t=l(e,r);return t.length===0?[]:m([...d(e,t),...c(e,t)]).filter(o=>!e.isIgnored(o.relative_path)).map(u)}function d(e,r){let t=r.map(()=>"?").join(", ");return e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
1
+ import{b as l}from"./chunk-5N5ZC566.js";import{a}from"./chunk-BTYDBDX5.js";import{d as i,g as n}from"./chunk-7XP7ZRSI.js";function _(e,r){let t=l(e,r);return t.length===0?[]:m([...d(e,t),...c(e,t)]).filter(o=>!e.isIgnored(o.relative_path)).map(u)}function d(e,r){let t=r.map(()=>"?").join(", ");return e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents d1 ON c.document_id = d1.id
@@ -26,4 +26,4 @@ import{b as l}from"./chunk-5N5ZC566.js";import{a}from"./chunk-CYDOV3AQ.js";impor
26
26
  AND ${e.localSymbolPredicate}
27
27
  ${e.pathExclusionsFor("d1")}
28
28
  ORDER BY d1.relative_path`,...r,...r,...r)}function c(e,r){let t=new a(e);return r.flatMap(o=>t.definitionsForFile(o).filter(s=>n(s.symbol)).map(s=>({relative_path:o,symbol:s.symbol})))}function m(e){let r=new Set;return e.filter(t=>{let o=`${t.relative_path}|${t.symbol}`;return r.has(o)?!1:(r.add(o),!0)})}function u(e){return{consumer:e.relative_path,symbol:e.symbol,shortName:i(e.symbol)}}export{_ as a};
29
- //# sourceMappingURL=chunk-JYBF5CPE.js.map
29
+ //# sourceMappingURL=chunk-FZXN37RN.js.map
@@ -1,2 +1,2 @@
1
- import{c as m}from"./chunk-B75HZHUP.js";import{a as g,c as b}from"./chunk-TCOWAGR2.js";import{m as y}from"./chunk-MVFNACWB.js";import{a as c}from"./chunk-2HCWAL42.js";import{d as r}from"./chunk-7XP7ZRSI.js";function v(l,t,n={}){let o=c(l,t);if(!o)return null;let a=[{file:o.relativePath,line:o.startLine}],s=y(l,o,{semantic:n.semantic}).map(e=>({file:e.file,line:e.line,enclosingSymbol:e.enclosingSymbol??"(top-level)",enclosingShort:e.enclosingSymbol?r(e.enclosingSymbol):"(top-level)"})),{producers:f,consumers:i}=S(l,o,s,{semantic:n.semantic!==!1});return{symbol:o.symbol,shortName:r(o.symbol),relativePath:o.relativePath,definitionSites:a.filter(e=>!l.isIgnored(e.file)),usageSites:s,producers:f.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:r(e.symbol),file:e.file})),consumers:i.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:e.symbol===e.file?"(top-level)":r(e.symbol),file:e.file}))}}function S(l,t,n,o){let a=m(g(l,t,{limit:30,semantic:o.semantic}).map(i=>({symbol:i.symbol,file:i.file}))),s=m(b(l,t,{limit:30,semantic:o.semantic})),f=s.length>0?s:m(n.map(i=>({symbol:i.enclosingSymbol==="(top-level)"?i.file:i.enclosingSymbol,file:i.file})));return{producers:a,consumers:f}}export{v as a};
2
- //# sourceMappingURL=chunk-Y3DG4J6A.js.map
1
+ import{c as m}from"./chunk-B75HZHUP.js";import{a as g,c as b}from"./chunk-3YEBIYXL.js";import{m as y}from"./chunk-FY6RCFDH.js";import{a as c}from"./chunk-2HCWAL42.js";import{d as r}from"./chunk-7XP7ZRSI.js";function v(l,t,n={}){let o=c(l,t);if(!o)return null;let a=[{file:o.relativePath,line:o.startLine}],s=y(l,o,{semantic:n.semantic}).map(e=>({file:e.file,line:e.line,enclosingSymbol:e.enclosingSymbol??"(top-level)",enclosingShort:e.enclosingSymbol?r(e.enclosingSymbol):"(top-level)"})),{producers:f,consumers:i}=S(l,o,s,{semantic:n.semantic!==!1});return{symbol:o.symbol,shortName:r(o.symbol),relativePath:o.relativePath,definitionSites:a.filter(e=>!l.isIgnored(e.file)),usageSites:s,producers:f.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:r(e.symbol),file:e.file})),consumers:i.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:e.symbol===e.file?"(top-level)":r(e.symbol),file:e.file}))}}function S(l,t,n,o){let a=m(g(l,t,{limit:30,semantic:o.semantic}).map(i=>({symbol:i.symbol,file:i.file}))),s=m(b(l,t,{limit:30,semantic:o.semantic})),f=s.length>0?s:m(n.map(i=>({symbol:i.enclosingSymbol==="(top-level)"?i.file:i.enclosingSymbol,file:i.file})));return{producers:a,consumers:f}}export{v as a};
2
+ //# sourceMappingURL=chunk-G4IUQW27.js.map