scip-query 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -6
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-FG6A6ZUP.js → chunk-25HOGELX.js} +2 -2
- package/dist/{chunk-XV3XUZ3X.js → chunk-2TLYCK2L.js} +2 -2
- package/dist/chunk-3PVIYZ74.js +84 -0
- package/dist/{chunk-MO32JMOD.js → chunk-4TX5IMMK.js} +2 -2
- package/dist/{chunk-3UB2DPLP.js → chunk-6DVA22YE.js} +2 -2
- package/dist/{chunk-C5BFS23M.js → chunk-6GPFHZP3.js} +2 -2
- package/dist/{chunk-YDKWDTAW.js → chunk-7PRMSA4Z.js} +2 -2
- package/dist/{chunk-MTK3JAJT.js → chunk-7YI2M2AQ.js} +2 -2
- package/dist/{chunk-M5QTG55L.js → chunk-AADJ7MCQ.js} +2 -2
- package/dist/{chunk-A5UNS4DR.js → chunk-AV7BOODV.js} +2 -2
- package/dist/{chunk-PBFMZKXE.js → chunk-AXP4H62Q.js} +2 -2
- package/dist/{chunk-IJWIYZO5.js → chunk-C4C3T4K3.js} +2 -2
- package/dist/{chunk-ZFCQQ4B5.js → chunk-CSRPJCWO.js} +2 -2
- package/dist/{chunk-U5MVUPOO.js → chunk-CYJMOTIH.js} +2 -2
- package/dist/{chunk-URUVLDM7.js → chunk-DLWRLPKO.js} +2 -2
- package/dist/{chunk-5YYMKE3G.js → chunk-E2V5SE6M.js} +2 -2
- package/dist/{chunk-FHSD5RKF.js → chunk-GPY33RTH.js} +2 -2
- package/dist/{chunk-PFMGJ4BR.js → chunk-HVNVO6UW.js} +2 -2
- package/dist/{chunk-BNCTPTVX.js → chunk-I377UMS2.js} +2 -2
- package/dist/{chunk-F4KR22Z2.js → chunk-IKQYNTW3.js} +2 -2
- package/dist/{chunk-RT5PV5JQ.js → chunk-IZ4KV37N.js} +2 -2
- package/dist/{chunk-DRLWW74T.js → chunk-KBGFYKOJ.js} +2 -2
- package/dist/chunk-KW2F3WSV.js +5 -0
- package/dist/{chunk-FVVEIGP3.js → chunk-NIN762LD.js} +2 -2
- package/dist/{chunk-YDNCX5PF.js → chunk-O6VBAW7P.js} +2 -2
- package/dist/{chunk-EB5IVUNU.js → chunk-PIRXZGV6.js} +2 -2
- package/dist/{chunk-MKFH7QJG.js → chunk-Q4R2IYA3.js} +2 -2
- package/dist/{chunk-Z5CTXSWT.js → chunk-QFBJZHMV.js} +2 -2
- package/dist/{chunk-WHGCGENP.js → chunk-QPJG6VRT.js} +2 -2
- package/dist/{chunk-HUASU3AD.js → chunk-TBJDUS4E.js} +7 -7
- package/dist/{chunk-K6H3XJQW.js → chunk-TUV2VI7D.js} +2 -2
- package/dist/chunk-UAPNU7UP.js +2 -0
- package/dist/{chunk-WNMAH3P7.js → chunk-URCJTFOD.js} +2 -2
- package/dist/{chunk-QFCK6WV2.js → chunk-UUIWMLDX.js} +2 -2
- package/dist/{chunk-WIIZF5FP.js → chunk-VEXS3I3N.js} +2 -2
- package/dist/{chunk-ROWAEEOD.js → chunk-VRC3WKKE.js} +2 -2
- package/dist/{chunk-5LQ6CVX3.js → chunk-WFDTS7XL.js} +2 -2
- package/dist/chunk-Y4DS3MDC.js +5 -0
- package/dist/{chunk-LT2CPEQ4.js → chunk-YJODB2F5.js} +2 -2
- package/dist/{chunk-PK4U6NWP.js → chunk-YXMHTJYY.js} +2 -2
- package/dist/chunk-Z4AMQWVY.js +90 -0
- package/dist/cli.js +111 -111
- package/dist/index.d.ts +8 -5
- package/dist/index.js +11 -11
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-2ZGHRI2A.js +0 -5
- package/dist/chunk-32R4VYYA.js +0 -2
- package/dist/chunk-4X7C236P.js +0 -84
- package/dist/chunk-KTCODJNQ.js +0 -5
- package/dist/chunk-YU25IHJX.js +0 -90
package/README.md
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
# scip-query
|
|
2
2
|
|
|
3
|
-
Language-agnostic code intelligence CLI powered by [SCIP](https://github.com/sourcegraph/scip) indexes. Index
|
|
3
|
+
Language-agnostic code intelligence CLI powered by [SCIP](https://github.com/sourcegraph/scip) indexes. Index a codebase once, then ask direct questions about symbols, references, dependencies, dead code, similarity, coupling, impact, and health without keeping an IDE or language server running.
|
|
4
4
|
|
|
5
5
|
Works with every language that has a SCIP indexer: TypeScript, JavaScript, Vue, Java, Scala, Kotlin, Rust, Python, Ruby, Go, C/C++, C#, Visual Basic, Dart, PHP.
|
|
6
6
|
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
`scip-query` exists to make codebase understanding operational. A large codebase is a collection of source files, symbols, and dependency paths that people need to change without accidentally breaking users. This project turns compiler-produced code intelligence into terminal commands that answer the questions engineers and agents ask before they edit:
|
|
10
|
+
|
|
11
|
+
- What is defined here?
|
|
12
|
+
- Who uses this symbol?
|
|
13
|
+
- What depends on this file?
|
|
14
|
+
- What changes if I modify this API?
|
|
15
|
+
- Which cleanup findings are backed by real reference evidence?
|
|
16
|
+
- Where is the architecture drifting, duplicating work, or hiding complexity?
|
|
17
|
+
|
|
18
|
+
The vision is a reliable code-intelligence layer for both humans and coding agents: fast enough to use during ordinary development, accurate enough to trust for planning, and explicit about confidence when an analysis moves beyond compiler-backed facts.
|
|
19
|
+
|
|
20
|
+
## Problems It Solves
|
|
21
|
+
|
|
22
|
+
- **Navigation without IDE state.** Query definitions, references, outlines, members, call graphs, and source snippets from a terminal or automation loop.
|
|
23
|
+
- **Change planning.** Use `affected`, `change-surface`, and `diff-impact` to identify downstream consumers before and after a change.
|
|
24
|
+
- **Architecture visibility.** Use `deps`, `rdeps`, `system`, `surface`, `coupling`, `cycles`, and `deep-chains` to see how modules actually relate.
|
|
25
|
+
- **Codebase cleanup.** Use `dead`, `stale-abstractions`, `wrapper-candidates`, `passthrough-candidates`, `similar`, `similar-signatures`, `extract-candidates`, and `drift` to find removal or consolidation opportunities.
|
|
26
|
+
- **Health reporting.** Use `health` to aggregate cleanup signals into one prioritized report instead of running dozens of commands by hand.
|
|
27
|
+
- **Agent workflows.** Install the bundled Codex/Claude skills so agents can explore, plan, de-bloat, and verify changes with a consistent command vocabulary.
|
|
28
|
+
|
|
29
|
+
## Accuracy Model
|
|
30
|
+
|
|
31
|
+
A SCIP index is a database-shaped record of code facts produced by language-aware indexers: the source files they read, the symbols they define, and the references they resolve. Because these facts come from compilers, type checkers, or language servers, direct definition and reference queries are much stronger evidence than text search.
|
|
32
|
+
|
|
33
|
+
`scip-query` separates three kinds of evidence:
|
|
34
|
+
|
|
35
|
+
- **Compiler-backed facts** come from the SCIP database. Commands like `symbols`, `refs`, `trace`, `deps`, `rdeps`, `surface`, and most symbol-level counts start here.
|
|
36
|
+
- **Semantic augmentation** adds language-specific checks when available. TypeScript projects use `ts-morph` to verify references, import usage, callers, callees, and signatures when SCIP alone is incomplete.
|
|
37
|
+
- **Source-backed heuristics** use parsed source text or ASTs to keep higher-level cleanup commands useful when an indexer omits call-site details. These findings are designed as investigation leads, not blind deletion instructions.
|
|
38
|
+
|
|
39
|
+
The goal is not to replace compiler facts with regexes. The goal is to use the strongest available evidence first, fall back only when needed, and keep cleanup commands conservative enough that speed does not trade away accuracy.
|
|
40
|
+
|
|
7
41
|
## Workflows
|
|
8
42
|
|
|
9
43
|
For goal-oriented usage guides (not just command reference), see **[Agent Guide](docs/AGENT_GUIDE.md)**:
|
|
@@ -14,12 +48,15 @@ For goal-oriented usage guides (not just command reference), see **[Agent Guide]
|
|
|
14
48
|
- **[Assess code quality](docs/AGENT_GUIDE.md#workflow-4-assess-code-quality-and-risk)** — health score, complexity hotspots, coupling risks
|
|
15
49
|
- **[Verify change impact](docs/AGENT_GUIDE.md#workflow-5-understand-impact-after-making-changes)** — diff impact, transitive blast radius, consumer blast radius
|
|
16
50
|
|
|
51
|
+
Historical implementation plans and completed cleanup notes live in [`docs/plans/`](docs/plans/).
|
|
52
|
+
|
|
17
53
|
## Quick Start
|
|
18
54
|
|
|
19
55
|
```bash
|
|
20
56
|
# Install
|
|
21
57
|
npm install -g scip-query
|
|
22
|
-
scip-query
|
|
58
|
+
scip-query check-deps # verify optional indexers and parser support
|
|
59
|
+
scip-query install-skills # install built-in Codex/Claude skills
|
|
23
60
|
|
|
24
61
|
# Index your project (auto-detects language)
|
|
25
62
|
scip-query reindex
|
|
@@ -38,7 +75,7 @@ scip-query diff-impact # what did my changes affect?
|
|
|
38
75
|
## Prerequisites
|
|
39
76
|
|
|
40
77
|
- **Node.js** >= 18
|
|
41
|
-
- **scip** CLI
|
|
78
|
+
- **scip** CLI - [Install from releases](https://github.com/sourcegraph/scip/releases) (converts index data to SQLite)
|
|
42
79
|
- A language-specific SCIP indexer for your project:
|
|
43
80
|
|
|
44
81
|
| Language | Indexer | Install |
|
|
@@ -60,11 +97,11 @@ Vue single-file components (`.vue`) are handled by the JavaScript/TypeScript ind
|
|
|
60
97
|
|
|
61
98
|
## How It Works
|
|
62
99
|
|
|
63
|
-
1. A SCIP indexer analyzes your source code using the actual compiler/type checker and produces a `index.scip` protobuf file containing
|
|
100
|
+
1. A SCIP indexer analyzes your source code using the actual compiler/type checker and produces a `index.scip` protobuf file containing symbols, definitions, and references.
|
|
64
101
|
2. The `scip` CLI converts the protobuf to a SQLite database (`index.db`).
|
|
65
|
-
3. `scip-query` runs SQL queries against that database to answer questions about your codebase.
|
|
102
|
+
3. `scip-query` runs SQL queries and language-aware source augmentation against that database to answer questions about your codebase.
|
|
66
103
|
|
|
67
|
-
Because the index comes from
|
|
104
|
+
Because the index comes from real language tooling, direct symbol, definition, and reference queries are precise, not grep-based approximations. When a language index is missing enough call-site detail for higher-level analyses, `scip-query` can fall back to AST parsing, semantic providers, and identifier recovery so those commands stay useful while still reporting conservative results.
|
|
68
105
|
|
|
69
106
|
## Configuration
|
|
70
107
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as t}from"./chunk-
|
|
1
|
+
import{c as t}from"./chunk-TBJDUS4E.js";import{writeFileSync as o}from"fs";import{workerData as s}from"worker_threads";var e=s;try{let r=t({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles,tasks:e.tasks});o(e.resultPath,JSON.stringify({ok:!0,result:r}))}catch(r){o(e.resultPath,JSON.stringify({ok:!1,error:r instanceof Error?r.message:String(r)}))}finally{let r=new Int32Array(e.sharedBuffer);Atomics.add(r,0,1),Atomics.notify(r,0)}
|
|
2
2
|
//# sourceMappingURL=augment-vue-worker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d}from"./chunk-QRYEOK3M.js";import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as d}from"./chunk-QRYEOK3M.js";import{a as g}from"./chunk-TUV2VI7D.js";import{b as R}from"./chunk-AXP4H62Q.js";import{a as x}from"./chunk-NIN762LD.js";import{a as f}from"./chunk-7YI2M2AQ.js";import{a as S}from"./chunk-6DVA22YE.js";import{a as y}from"./chunk-GPY33RTH.js";import{a as C}from"./chunk-C4C3T4K3.js";import{a as h}from"./chunk-PIRXZGV6.js";import{a as p}from"./chunk-4TX5IMMK.js";import{a as b}from"./chunk-URCJTFOD.js";import{e as c,f as m}from"./chunk-YXMHTJYY.js";var H=50;function _(e,t={}){let r=v(e,t.scope),u=L(e,r),o=I(r,u);return{score:A(r,u),overview:{documents:r.statsResult.documents,symbols:r.statsResult.symbols,indexSizeBytes:r.statsResult.indexSizeBytes},findings:{deadSymbols:u.trueDeadCount,deadLoc:u.trueDeadLoc,isolatedSymbols:u.trueIsolatedCount,isolatedLoc:u.trueIsolatedLoc,cycles:u.realCycleCount,similarPairs:u.trueSimilarCount,extractionCandidates:r.extractResult.length,wrappers:r.wrapperResult.length,passthroughs:r.passthroughResult.length,staleTypes:u.trueStaleCount,driftedFiles:u.trueDriftCount,complexityHotspotCount:w(r)},actions:o,topComplexity:r.complexResult.slice(0,5).map(l=>({symbol:l.shortName,score:l.score}))}}function v(e,t){return{statsResult:d(e),deadResult:p(e,{scope:t,minLoc:3,skipBarrels:!0}),isolatedResult:f(e,{scope:t,minLoc:3}),cycleResult:h(e,{scope:t}),similarResult:R(e,{scope:t,minSimilarity:.6,limit:50,minCallees:4}),extractResult:C(e,{scope:t,minLoc:15,minCallees:5,limit:50}),wrapperResult:g(e,{scope:t,maxLoc:15,limit:50}),passthroughResult:S(e,{scope:t,maxLoc:15,limit:50}),staleResult:x(e,{scope:t,minLoc:3,limit:50}),driftResult:y(e,{scope:t}),complexResult:b(e,{scope:t,minLoc:10,limit:10})}}function L(e,t){let r=t.deadResult.symbols.filter(o=>!c(e,o.relativePath)&&!m(e,o.symbol,o.relativePath)&&o.kind==="dead-code"),u=t.isolatedResult.filter(o=>!c(e,o.relativePath)&&!m(e,o.symbol,o.relativePath));return{trueDeadCount:r.length,trueDeadLoc:r.reduce((o,i)=>o+i.loc,0),trueIsolatedCount:u.length,trueIsolatedLoc:u.reduce((o,i)=>o+i.loc,0),trueStaleCount:t.staleResult.length,trueDriftCount:t.driftResult.unusedImports+t.driftResult.layerViolations,trueSimilarCount:t.similarResult.length,realCycleCount:t.cycleResult.filter(o=>o.kind==="real").length}}function I(e,t){let r=[];if(t.trueDeadCount>0&&r.push({category:"Dead code",description:`${t.trueDeadCount} symbols with zero references anywhere \u2014 safe to delete`,effort:"low",impact:"high",count:t.trueDeadCount,locRecoverable:t.trueDeadLoc}),t.trueIsolatedCount>0&&r.push({category:"Isolated symbols",description:`${t.trueIsolatedCount} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:t.trueIsolatedCount,locRecoverable:t.trueIsolatedLoc}),t.realCycleCount>0&&r.push({category:"Circular dependencies",description:`${t.realCycleCount} cycle(s) \u2014 break with dependency inversion or module restructuring`,effort:"medium",impact:"high",count:t.realCycleCount,locRecoverable:0}),t.trueSimilarCount>0&&r.push({category:"Similar functions",description:`${t.trueSimilarCount} pairs with real logic overlap (beyond shared imports) \u2014 consolidation candidates`,effort:"medium",impact:"medium",count:t.trueSimilarCount,locRecoverable:0}),e.extractResult.length>0&&r.push({category:"Extraction candidates",description:`${e.extractResult.length} large functions with isolated callee clusters \u2014 extract method opportunities`,effort:"medium",impact:"medium",count:e.extractResult.length,locRecoverable:0}),e.wrapperResult.length>0&&r.push({category:"Wrapper functions",description:`${e.wrapperResult.length} single-consumer symbols that could be inlined`,effort:"low",impact:"low",count:e.wrapperResult.length,locRecoverable:e.wrapperResult.reduce((i,l)=>i+l.loc,0)}),e.passthroughResult.length>0&&r.push({category:"Passthrough functions",description:`${e.passthroughResult.length} functions that just forward to one callee \u2014 unnecessary indirection`,effort:"low",impact:"low",count:e.passthroughResult.length,locRecoverable:e.passthroughResult.reduce((i,l)=>i+l.loc,0)}),t.trueStaleCount>0){let i=e.staleResult.filter(n=>n.consumers===0).length,l=t.trueStaleCount-i,s=[];i>0&&s.push(`${i} unused`),l>0&&s.push(`${l} single-consumer (not in types file)`),r.push({category:"Stale abstractions",description:`${s.join(", ")} \u2014 premature abstraction`,effort:"low",impact:"medium",count:t.trueStaleCount,locRecoverable:e.staleResult.reduce((n,a)=>n+a.loc,0)})}if(t.trueDriftCount>0){let i=[];e.driftResult.unusedImports>0&&i.push(`${e.driftResult.unusedImports} unused imports`),e.driftResult.layerViolations>0&&i.push(`${e.driftResult.layerViolations} layer violations`),r.push({category:"Structural drift",description:i.join(", "),effort:e.driftResult.layerViolations>0?"medium":"low",impact:e.driftResult.layerViolations>0?"medium":"low",count:t.trueDriftCount,locRecoverable:0})}let u={high:3,medium:2,low:1},o={low:3,medium:2,high:1};return r.sort((i,l)=>{let s=u[i.impact]*o[i.effort];return u[l.impact]*o[l.effort]-s}),r}function A(e,t){let r=Math.max(e.statsResult.documents,1),u=Math.max(e.statsResult.symbols,1),o=100,i=t.trueDeadCount/u;o-=Math.min(20,Math.round(i*200));let l=t.trueIsolatedCount/u;o-=Math.min(10,Math.round(l*200)),o-=Math.min(15,t.realCycleCount*5);let s=t.trueSimilarCount/u*1e3;o-=Math.min(10,Math.round(s));let n=e.extractResult.length/u*1e3;o-=Math.min(5,Math.round(n/2)),o-=Math.min(3,e.wrapperResult.length),o-=Math.min(3,e.passthroughResult.length);let a=t.trueStaleCount/Math.max(u*.1,1);o-=Math.min(8,Math.round(a*10));let M=t.trueDriftCount/r;o-=Math.min(5,Math.round(M*50));let D=w(e);return o-=Math.min(5,D*2),Math.max(0,Math.min(100,o))}function w(e){return e.complexResult.filter(t=>t.score>H).length}export{_ as a};
|
|
2
|
+
//# sourceMappingURL=chunk-25HOGELX.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as c}from"./chunk-MO65UK5V.js";import{a as m}from"./chunk-
|
|
1
|
+
import{a as c}from"./chunk-MO65UK5V.js";import{a as m}from"./chunk-UAPNU7UP.js";import{p as l}from"./chunk-Z4AMQWVY.js";import{o as u}from"./chunk-QFZE73XF.js";function C(e,r){let n=c(e,r);if(!n)return null;let t=d(e,n);if(!t||e.isIgnored(t.relative_path))return null;let s=[],i=0;for(let o of p(e,t.relative_path)){let a=h(e,t,o);i+=a,s.push({symbol:o.symbol,shortName:u(o.symbol),startLine:o.startLine,endLine:o.endLine,externalConsumers:a,riskLevel:f(a)})}return{file:t.relative_path,symbols:s,totalExternalConsumers:i}}function d(e,r){return e.get(`SELECT id, relative_path FROM documents
|
|
2
2
|
WHERE relative_path = ?
|
|
3
3
|
${e.pathExclusionsFor("documents")}
|
|
4
4
|
LIMIT 1`,r)??null}function p(e,r){return new m(e).definitionsForFile(r).sort((n,t)=>n.startLine-t.startLine||n.endLine-t.endLine)}function h(e,r,n){let t=e.all(`SELECT DISTINCT consumer_d.relative_path
|
|
@@ -8,4 +8,4 @@ import{a as c}from"./chunk-MO65UK5V.js";import{a as m}from"./chunk-32R4VYYA.js";
|
|
|
8
8
|
WHERE m.symbol_id = ?
|
|
9
9
|
AND m.role != 1
|
|
10
10
|
AND c.document_id != ?`,n.symbolId,r.id),s=l(e,[n]).get(n.symbolId)??new Set;return new Set([...t.map(i=>i.relative_path),...[...s].filter(i=>i!==r.relative_path)]).size}function f(e){return e>10?"high":e>0?"medium":"low"}export{C as a};
|
|
11
|
-
//# sourceMappingURL=chunk-
|
|
11
|
+
//# sourceMappingURL=chunk-2TLYCK2L.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{a as H,b as $,c as J,e as N}from"./chunk-KW2F3WSV.js";import{o as B,p as j,q as z}from"./chunk-Z4AMQWVY.js";import{c as G}from"./chunk-ZHHMG4UC.js";import{A as M,B as k,E as D,a as h,b as w,d as x,f as y,h as S,i as C,k as A,m as P,p as L,r as W}from"./chunk-QFZE73XF.js";var E=new WeakMap;function _t(e,t){let n=y(t);return n==="rust"?fe(e,t):n==="typescript"||n==="tsx"||n==="javascript"?ce(e,t):[]}var le=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function ce(e,t){let n=S(e,t);if(!n)return[];let o=E.get(n);if(o)return o;let s=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(t)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(t),i=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(t),r=!1,l=n.rootNode;for(let a of l.namedChildren){if(a.type!=="expression_statement")continue;let u=a.namedChild(0);if(!u||u.type!=="call_expression")continue;let d=u.namedChild(0);if(!d)continue;let f=d.type==="member_expression"?d.namedChild(d.namedChildCount-1)?.text:d.text;if(f&&le.has(f)){r=!0;break}}let c=[];r&&c.push({startLine:0,endLine:l.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(s||i)&&c.push({startLine:0,endLine:l.endPosition.row,reason:s?"Next.js / Remix route file":"Vite/Vue route component"});for(let a of l.namedChildren){let u=null,d=null;if(a.type==="function_declaration")u=a.namedChild(0)?.text??null,d=a;else if(a.type==="export_statement"){let f=a.namedChild(0);f?.type==="function_declaration"&&(u=f.namedChild(0)?.text??null,d=f)}else if(a.type==="lexical_declaration"){let f=a.namedChild(0);if(f?.type==="variable_declarator"){let p=f.namedChild(0)?.text,g=f.namedChild(1);p&&(g?.type==="arrow_function"||g?.type==="function_expression")&&(u=p,d=f)}}u&&/^use[A-Z]/.test(u)&&d&&c.push({startLine:d.startPosition.row,endLine:d.endPosition.row,reason:"React custom hook (use*)"})}return c.push(...V(n,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),E.set(n,c),c}var ue=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function de(e){return ue.test(e)}function V(e,t,n){let o=[],s=i=>{if(t.has(i.type)&&i.parent){let l=i.parent.children,c=-1;for(let a=0;a<l.length;a+=1)if(l[a].startIndex===i.startIndex&&l[a].type===i.type){c=a;break}if(c>0)for(let a=c-1;a>=0;a-=1){let u=l[a];if(n.has(u.type)){if(de(u.text)){o.push({startLine:i.startPosition.row,endLine:i.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(u.type==="attribute_item"||u.type==="inner_attribute_item"))break}}for(let r of i.namedChildren)s(r)};return s(e.rootNode),o}function fe(e,t){let n=S(e,t);if(!n)return[];let o=E.get(n);if(o)return o;let s=[],i=me(n);return i?(E.set(n,i),i):(K(n.rootNode,s,!1,!1),s.push(...V(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),s.push(...he(n.rootNode)),E.set(n,s),s)}function me(e){return Se(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)"}]:null}function K(e,t,n,o){let s=n,i=o;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(i=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),e.type==="function_item"||e.type==="function_signature_item"?pe(e,t,n,o):o&&_e(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?ge(e,t,n):e.type==="mod_item"&&v(e).some(r=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(r))&&(s=!0);for(let r of e.namedChildren)K(r,t,s,i)}function pe(e,t,n,o){let s=v(e),i=null;o?i="trait impl method (dynamic dispatch)":n&&(i="inside #[cfg(test)] mod");for(let r of s){let l=be(r);if(l){i=l;break}if(q(r)){i="#[allow(dead_code)]";break}}i&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:i})}function ge(e,t,n){let o=v(e),s=e.namedChildren.find(i=>i.type==="type_identifier")?.text;o.some(ye)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:s}),o.some(q)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:s}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:s})}function v(e){let t=e.parent;if(!t)return[];let n=t.children,o=-1;for(let i=0;i<n.length;i+=1)if(n[i].startIndex===e.startIndex&&n[i].type===e.type){o=i;break}if(o<=0)return[];let s=[];for(let i=o-1;i>=0;i-=1){let r=n[i];if(r.type==="attribute_item"||r.type==="inner_attribute_item")s.push(r.text);else{if(r.type==="line_comment"||r.type==="block_comment")continue;break}}return s}function be(e){return/#\[\s*tauri::command\b/.test(e)?"#[tauri::command]":/#\[\s*command\b/.test(e)?"#[command]":/#\[\s*test\b/.test(e)?"#[test]":/#\[\s*bench\b/.test(e)?"#[bench]":/#\[\s*tokio::test\b/.test(e)?"#[tokio::test]":/#\[\s*async_std::test\b/.test(e)?"#[async_std::test]":/#\[\s*wasm_bindgen\b/.test(e)?"#[wasm_bindgen]":/#\[\s*no_mangle\b/.test(e)?"#[no_mangle]":/#\[\s*napi\b/.test(e)?"#[napi]":/#\[\s*pyfunction\b/.test(e)?"#[pyfunction]":/#\[\s*pymethod\b/.test(e)?"#[pymethod]":/#\[\s*pyo3\b/.test(e)?"#[pyo3]":/#\[\s*cfg\s*\(\s*test\s*\)/.test(e)?"#[cfg(test)]":/#\[\s*doc\s*\(\s*hidden\s*\)/.test(e)?"#[doc(hidden)]":null}function ye(e){return/#\[\s*derive\s*\(/.test(e)?/\bSerialize\b/.test(e)||/\bDeserialize\b/.test(e)||/\bFromRow\b/.test(e)||/\bDeriveEntityModel\b/.test(e)||/\bIntoSchema\b/.test(e)||/\bToSchema\b/.test(e)||/\bDeriveValueType\b/.test(e)||/\bsqlx::FromRow\b/.test(e)||/\bError\b/.test(e)||/\bthiserror::Error\b/.test(e):!1}function q(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function _e(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function he(e){let t=Ie(e);if(t.size===0)return[];let n=[];for(let o of e.descendantsOfType("mod_item")){let s=o.childForFieldName("name")?.text;s&&t.has(s)&&n.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:s})}return n}function Se(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var Ee=[{key:"default",re:/\bdefault\s*=\s*"([^"]+)"/g},{key:"with",re:/\bwith\s*=\s*"([^"]+)"/g},{key:"serialize_with",re:/\bserialize_with\s*=\s*"([^"]+)"/g},{key:"deserialize_with",re:/\bdeserialize_with\s*=\s*"([^"]+)"/g},{key:"skip_serializing_if",re:/\bskip_serializing_if\s*=\s*"([^"]+)"/g},{key:"getter",re:/\bgetter\s*=\s*"([^"]+)"/g},{key:"rename_all_with",re:/\brename_all_with\s*=\s*"([^"]+)"/g},{key:"schema_with",re:/\bschema_with\s*=\s*"([^"]+)"/g}],Z=/^#!?\[\s*serde\s*\(/,Re=/^#!?\[\s*schemars\s*\(/,Ce=/^#!?\[\s*validate\s*\(/,U=/\bwith\s*=\s*"([^"]+)"/g;function X(e,t){return A(e,t,Le,()=>new Set,(n,o,s)=>{if(o==="rust"){for(let i of n.rootNode.descendantsOfType("attribute_item"))Y(i.text,s);for(let i of n.rootNode.descendantsOfType("inner_attribute_item"))Y(i.text,s)}})??new Set}var Le=new WeakMap;function Y(e,t){let n=Z.test(e),o=Re.test(e),s=Ce.test(e);if(!(!n&&!o&&!s))for(let{re:i}of Ee){i.lastIndex=0;let r;for(;(r=i.exec(e))!==null;){let l=r[1],c=l.split("::").pop()??l;c==="is_none"&&/\bOption\b/.test(l)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(l)||c&&t.add(c)}}}function Ie(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){if(!Z.test(n.text))continue;U.lastIndex=0;let o;for(;(o=U.exec(n.text))!==null;){let s=o[1],i=s.split("::").pop()??s;i&&t.add(i)}}return t}var we=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function ht(e,t){return A(e,t,xe,()=>new Set,(n,o,s)=>{if(!(o!=="typescript"&&o!=="tsx"&&o!=="javascript"))for(let i of n.rootNode.descendantsOfType("call_expression")){let r=i.namedChild(0);if(!r)continue;let l=P(r);if(!l||!we.has(l))continue;let c=i.namedChildren.find(d=>d.type==="arguments");if(!c)continue;let a=c.namedChild(0);if(!a||a.type!=="string")continue;let u=a.namedChildren.find(d=>d.type==="string_fragment");u&&s.add(u.text)}})??new Set}var xe=new WeakMap;var Ae=new Set(["identifier","type_identifier","field_identifier"]),Ne=new Set(["identifier"]),Me=new Set(["identifier","property_identifier","type_identifier"]),ke=new Set(["rust","python"]),De=/\{([^{}]*)\}/g,ve=/\b([A-Za-z_][\w]*)\b/g;function ee(e,t,n,o={}){if(!n)return[];let s=x(e,t);if(!s)return[];if(s.indexOf(n)===-1)return[];if(y(t))return(O(e,t).get(n)??[]).filter(u=>!Q(u,o));let i=$(e,t,s),r=new RegExp(`\\b${J(n)}\\b`),l=[];for(let c=0;c<i.length;c++)Q(c,o)||r.test(i[c]??"")&&l.push(c);return l}function Q(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var Oe=h("file-identifiers");function It(e,t){return Oe.get(e,t,()=>new Set(O(e,t).keys()))}var Te=h("file-ident-lines");function O(e,t){return Te.get(e,t,()=>Pe(e,t))}var Fe=h("file-idents-by-line");function te(e,t){return Fe.get(e,t,()=>{let n=O(e,t),o=0;for(let i of n.values()){let r=i[i.length-1];r!==void 0&&r>o&&(o=r)}let s=new Array(o+1);for(let i=0;i<=o;i+=1)s[i]=new Set;for(let[i,r]of n)for(let l of r)s[l].add(i);return s})}function Pe(e,t){let n=new Map,o=(l,c)=>{let a=n.get(l);if(!a){n.set(l,[c]);return}a[a.length-1]!==c&&a.push(c)};if(y(t)){let l=S(e,t);if(l){let c=y(t),a=c==="rust"?Ae:c==="python"?Ne:Me,u=d=>{if(a.has(d.type)&&o(d.text,d.startPosition.row),c&&ke.has(c)&&d.type==="string_content"){let f=d.startPosition.row;for(let p of d.text.matchAll(De)){let g=p[1]??"";for(let m of g.matchAll(ve))m[1]&&o(m[1],f)}}for(let f of d.children)u(f)};return u(l.rootNode),n}}let s=x(e,t);if(!s)return n;let i=H(s).split(/\r?\n/),r=/\b([A-Za-z_$][\w$]*)\b/g;for(let l=0;l<i.length;l+=1){let c=i[l]??"";for(let a of c.matchAll(r))a[1]&&o(a[1],l)}return n}var He=h("file-dep-graph");function Ft(e,t){return He.get(e,t??"",()=>{let n=new Map,o=Je(e),s=(i,r)=>We(e,n,o,i,r);for(let i of $e(e,t))s(i.from_file,i.to_file);for(let i of o)if(!(t&&!i.includes(t)))for(let r of N(e,i))r.sourcePath&&s(i,r.sourcePath);return n})}function $e(e,t){let n=t?`AND d1.relative_path LIKE '%${t}%'`:"";return e.all(`SELECT DISTINCT
|
|
2
|
+
d1.relative_path AS from_file,
|
|
3
|
+
d2.relative_path AS to_file
|
|
4
|
+
FROM mentions m
|
|
5
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
6
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
7
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
8
|
+
JOIN (
|
|
9
|
+
SELECT m2.symbol_id, c2.document_id
|
|
10
|
+
FROM mentions m2
|
|
11
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
12
|
+
WHERE m2.role = 1
|
|
13
|
+
GROUP BY m2.symbol_id
|
|
14
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
15
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
16
|
+
WHERE d1.id != d2.id
|
|
17
|
+
AND m.role != 1
|
|
18
|
+
${e.pathExclusionsFor("d1","d2")}
|
|
19
|
+
${n}`)}function Je(e){return new Set(e.all(`SELECT relative_path
|
|
20
|
+
FROM documents
|
|
21
|
+
WHERE 1 = 1
|
|
22
|
+
${e.pathExclusionsFor("documents")}
|
|
23
|
+
ORDER BY relative_path`).map(t=>t.relative_path).filter(t=>!e.isIgnored(t)))}function We(e,t,n,o,s){if(o===s||e.isIgnored(o)||e.isIgnored(s)||!n.has(s))return;let i=t.get(o);i||(i=new Set,t.set(o,i)),i.add(s)}function Pt(e,t,n={}){let o=ie(e,[t],{additive:n.additive}),s=n.callableOnly?(o.get(t.symbolId)??[]).filter(i=>W(i.symbol)):o.get(t.symbolId)??[];return typeof n.limit=="number"?s.slice(0,n.limit):s}function Ht(e,t,n={}){let o=je(e)?Ue(e,t):ze(e).get(t.symbolId)??[];return typeof n.limit=="number"?o.slice(0,n.limit):o}var Ge=w("caller-rows"),Be=2e4;function je(e){return(e.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>Be}function ze(e){return Ge.get(e,()=>{let t=k(e),n=ie(e,t),o=new Map;for(let r of t)o.set(r.symbol,r.symbolId);let s=new Map,i=new Map;for(let r of t){let l=n.get(r.symbolId);if(!(!l||l.length===0))for(let c of l){let a=o.get(c.symbol);if(a===void 0||a===r.symbolId)continue;let u=s.get(a);u||(u=[],s.set(a,u),i.set(a,new Set));let d=`${r.symbol}|${r.relativePath}`;i.get(a).has(d)||(i.get(a).add(d),u.push({symbol:r.symbol,file:r.relativePath}))}}return s})}function Ue(e,t){let n=[],o=new Set,s=r=>{if(r.symbol===t.symbol)return;let l=`${r.symbol}|${r.file}`;o.has(l)||(o.add(l),n.push(r))};for(let r of Ve(e,t))r.file!==t.relativePath&&s({symbol:r.enclosingSymbol??r.file,file:r.file});let i=Ye(e,t);if(i)for(let r of B(e,i)){if(r.file===t.relativePath||e.isIgnored(r.file))continue;let l=D(M(e,r.file),r.line);s({symbol:l?.symbol??r.file,file:r.file})}return n}function Ye(e,t){return e.get(`SELECT
|
|
24
|
+
d.id AS documentId,
|
|
25
|
+
gs.id AS symbolId,
|
|
26
|
+
gs.symbol,
|
|
27
|
+
d.relative_path AS relativePath,
|
|
28
|
+
COALESCE(der.start_line, c.start_line) AS startLine,
|
|
29
|
+
COALESCE(der.end_line, c.end_line) AS endLine,
|
|
30
|
+
COALESCE(gs.display_name, '') AS leaf,
|
|
31
|
+
NULL AS parentTypeName,
|
|
32
|
+
CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
|
|
33
|
+
CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
|
|
34
|
+
gs.kind AS kind,
|
|
35
|
+
gs.documentation AS documentation,
|
|
36
|
+
gs.enclosing_symbol AS enclosingSymbol
|
|
37
|
+
FROM global_symbols gs
|
|
38
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
39
|
+
LEFT JOIN chunks c ON c.document_id = der.document_id
|
|
40
|
+
JOIN documents d ON d.id = COALESCE(der.document_id, c.document_id)
|
|
41
|
+
WHERE gs.id = ?
|
|
42
|
+
LIMIT 1`,t.symbolId)??null}function Ve(e,t){let n=Qe(e,t);return n?et(e,Ke(e,n.match,n.identifier)):[]}function Ke(e,t,n){let o=new Map;for(let[s,i]of qe(e,t.symbolId))o.set(s,Ze(e,s,i,t,n));return o}function qe(e,t){let n=new Map,o=e.all(`SELECT DISTINCT d.relative_path, c.start_line, c.end_line
|
|
43
|
+
FROM mentions m
|
|
44
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
45
|
+
JOIN documents d ON c.document_id = d.id
|
|
46
|
+
WHERE m.symbol_id = ?
|
|
47
|
+
AND m.role != 1
|
|
48
|
+
${e.pathExclusionsFor("d")}
|
|
49
|
+
ORDER BY d.relative_path, c.start_line`,t);for(let s of o){if(e.isIgnored(s.relative_path))continue;let i=n.get(s.relative_path);i||(i=[],n.set(s.relative_path,i)),i.push({start_line:s.start_line,end_line:s.end_line})}return n}function Ze(e,t,n,o,s){let i=t===o.relativePath?{excludeStartLine:o.startLine,excludeEndLine:o.endLine}:{},r=s?ee(e,t,s,i):[];return n.flatMap(l=>Xe(r,l))}function Xe(e,t){let n=e.filter(o=>o>=t.start_line&&o<=t.end_line);return n.length>0?n:[t.start_line]}function Qe(e,t){let n=G(e,t);return n?{match:n,identifier:L(n.symbol)||null}:null}function et(e,t){let n=[],o=new Set;for(let[s,i]of t){let r=M(e,s);for(let l of i){let c=D(r,l),a=`${s}|${l}|${c?.symbol??""}`;o.has(a)||(o.add(a),n.push({file:s,line:l,enclosingSymbol:c?.symbol??null}))}}return n}function ie(e,t,n={}){if(t.length===0)return new Map;let o=n.additive??!1,s=[],i=[];for(let u of t)y(u.relativePath)&&C(e,u.relativePath)!==null?s.push(u):i.push(u);let r=new Map,l=new Map,c=u=>{for(let[d,f]of u){let p=r.get(d);p||(p=[],r.set(d,p));let g=l.get(d);g||(g=new Set,l.set(d,g));for(let m of f){let b=`${m.symbol}|${m.chunkId}`;g.has(b)||(g.add(b),p.push(m))}}};s.length>0&&c(tt(e,s)),c(gt(z(e,t)));let a=o?t:i;return a.length>0&&c(at(e,a)),r}function tt(e,t){let n=new Map,o=nt(t,n),s=re(e);for(let[i,r]of o){let l=C(e,i);if(l)for(let c of l){let a=it(r,c.line);if(!a)continue;let u=st(e,i,s,c.calleeLeaf,c.memberAccess);u&&u.symbol!==a.symbol&&n.get(a.symbolId).push({symbol:u.symbol,file:u.file,chunkId:c.line})}}return n}function nt(e,t){let n=new Map;for(let o of e){let s=n.get(o.relativePath);s?s.push(o):n.set(o.relativePath,[o]),t.set(o.symbolId,[])}for(let o of n.values())o.sort((s,i)=>s.endLine-s.startLine-(i.endLine-i.startLine));return n}function it(e,t){return e.find(n=>t>=n.startLine&&t<=n.endLine)??null}function st(e,t,n,o,s){let i=se(t,n.get(o)??[]);return i.length===0?null:oe(e,t,i,s)}function se(e,t){let n=ne(e);return n?t.filter(o=>ne(o.file)===n):t}function oe(e,t,n,o){let s=n.find(i=>i.file===t);if(s)return s;if(o){let i=new Set(N(e,t).map(r=>r.sourcePath).filter(r=>!!r));for(let r of n)for(let l of i)if(ot(l,r.file))return r;return null}return n.length===1?n[0]:null}function ot(e,t){let n=o=>o.replace(/\\/g,"/").replace(/^\.\//,"");return n(e)===n(t)}function ne(e){let t=y(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var rt=w("global-leaf-index");function re(e){return rt.get(e,()=>{let t=e.all(`SELECT gs.id, gs.symbol,
|
|
50
|
+
COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
|
|
51
|
+
FROM global_symbols gs
|
|
52
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
53
|
+
LEFT JOIN documents der_doc ON der_doc.id = der.document_id
|
|
54
|
+
LEFT JOIN (
|
|
55
|
+
SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
|
|
56
|
+
FROM mentions m
|
|
57
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
58
|
+
JOIN documents d ON c.document_id = d.id
|
|
59
|
+
WHERE m.role = 1
|
|
60
|
+
GROUP BY m.symbol_id
|
|
61
|
+
) mention_doc ON mention_doc.symbol_id = gs.id
|
|
62
|
+
WHERE 1 = 1
|
|
63
|
+
${e.symbolNoiseFor("gs")}`),n=new Map;for(let o of t){if(!o.relative_path||e.isIgnored(o.relative_path))continue;let s=L(o.symbol);if(!s)continue;let i=n.get(s);i||(i=[],n.set(s,i)),i.some(r=>r.symbolId===o.id)||i.push({symbol:o.symbol,symbolId:o.id,file:o.relative_path})}return n})}function at(e,t){if(t.length===0)return new Map;let n=e.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
|
|
64
|
+
FROM mentions m
|
|
65
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
66
|
+
WHERE m.role != 1`),o=new Map;for(let a of n)o.has(a.document_id)||o.set(a.document_id,[]),o.get(a.document_id).push(a);let s=new Map(e.all("SELECT id, relative_path FROM documents").map(a=>[a.id,a.relative_path])),i=new Map,r=e.all(`SELECT gs.id AS symbol_id, gs.symbol,
|
|
67
|
+
COALESCE(der.document_id, def_chunk.document_id) AS document_id
|
|
68
|
+
FROM global_symbols gs
|
|
69
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
70
|
+
LEFT JOIN (
|
|
71
|
+
SELECT m.symbol_id, MIN(c.document_id) AS document_id
|
|
72
|
+
FROM mentions m
|
|
73
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
74
|
+
WHERE m.role = 1
|
|
75
|
+
GROUP BY m.symbol_id
|
|
76
|
+
) def_chunk ON def_chunk.symbol_id = gs.id`);for(let a of r)i.has(a.symbol_id)||i.set(a.symbol_id,{symbol:a.symbol,file:a.document_id!==null?s.get(a.document_id)??"":""});let l=new Map,c=s;for(let a of t){let u=o.get(a.documentId)??[],d=new Set,f=[],p=null,g=()=>{if(p)return p;let m=c.get(a.documentId)??"",b=new Set;if(m){let I=te(e,m),R=Math.max(0,a.startLine),F=Math.min(I.length-1,a.endLine);for(let _=R;_<=F;_+=1)for(let ae of I[_])b.add(ae)}return p=b,b};for(let m of u){if(m.symbol_id===a.symbolId)continue;let b=i.get(m.symbol_id);if(!b)continue;if(!(m.start_line>=a.startLine&&m.end_line<=a.endLine)){if(!(m.start_line<=a.endLine&&m.end_line>=a.startLine))continue;let _=L(b.symbol);if(!_||!g().has(_))continue}let R=`${b.symbol}|${m.chunk_id}`;d.has(R)||(d.add(R),f.push({...b,chunkId:m.chunk_id}))}l.set(a.symbolId,f)}return l}function $t(e,t){let n=new Map,o=e.all(`SELECT relative_path FROM documents
|
|
77
|
+
WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`),s=re(e),i=t??k(e);return lt(e,n,o,s),ct(e,n,i),mt(e,n,o,s),bt(n,j(e,pt(i))),n}function lt(e,t,n,o){for(let s of n){if(!y(s.relative_path)||e.isIgnored(s.relative_path))continue;let i=C(e,s.relative_path);if(i)for(let r of i){let l=se(s.relative_path,o.get(r.calleeLeaf)??[]);if(!l||l.length===0)continue;let c=oe(e,s.relative_path,l,r.memberAccess);c&&c.file!==s.relative_path&&T(t,c.symbolId,s.relative_path)}}}function ct(e,t,n){let o=dt(n);for(let s of ut(e))e.isIgnored(s.relative_path)||ft(s,o.get(s.symbol_id))||T(t,s.symbol_id,s.relative_path)}function ut(e){return e.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
|
|
78
|
+
c.start_line AS chunk_start, c.end_line AS chunk_end
|
|
79
|
+
FROM mentions m
|
|
80
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
81
|
+
JOIN documents d ON c.document_id = d.id
|
|
82
|
+
WHERE m.role != 1
|
|
83
|
+
${e.pathExclusionsFor("d")}`)}function dt(e){let t=new Map;for(let n of e)t.set(n.symbolId,{docId:n.documentId,startLine:n.startLine,endLine:n.endLine});return t}function ft(e,t){return!!t&&t.docId===e.document_id&&e.chunk_start>=t.startLine&&e.chunk_end<=t.endLine}function mt(e,t,n,o){for(let s of n){if(e.isIgnored(s.relative_path)||y(s.relative_path)!=="rust")continue;let i=X(e,s.relative_path);if(i.size!==0)for(let r of i){let l=o.get(r);if(l)for(let c of l)c.file!==s.relative_path&&T(t,c.symbolId,s.relative_path)}}}function T(e,t,n){let o=e.get(t);o||(o=new Set,e.set(t,o)),o.add(n)}function pt(e){return e.filter(t=>"relativePath"in t&&"symbol"in t&&"leaf"in t)}function gt(e){let t=new Map;for(let[n,o]of e){let s=[];for(let i of o)s.push({symbol:i.symbol,file:i.file,chunkId:-1});t.set(n,s)}return t}function bt(e,t){for(let[n,o]of t){let s=e.get(n);s||(s=new Set,e.set(n,s));for(let i of o)s.add(i)}}export{_t as a,X as b,ht as c,ee as d,It as e,O as f,Ft as g,Pt as h,Ht as i,Ve as j,ie as k,re as l,$t as m};
|
|
84
|
+
//# sourceMappingURL=chunk-3PVIYZ74.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as P}from"./chunk-
|
|
1
|
+
import{a as P}from"./chunk-UAPNU7UP.js";import{d as R,e as v,f as D,g as F,h as L}from"./chunk-YXMHTJYY.js";import{a as m,i as S}from"./chunk-3PVIYZ74.js";import{e as f}from"./chunk-KW2F3WSV.js";import{B as h,H as c,o as d,r as p,s as g,t as b,u as y,v as _}from"./chunk-QFZE73XF.js";function Q(e,n={}){let{scope:r,minLoc:t=1,includeTests:s=!1,skipBarrels:a=!1,includeMembers:i=!1}=n,l=a?new Set(R(e)):new Set,o=w(e,l);k(e,o,l);let u=x(e,{scope:r,minLoc:t,includeTests:s,includeMembers:i});return H(e,u,o,{includeTests:s,inactiveBarrelPaths:l}),M(e,E(u,o))}function w(e,n){let r=e.all(`SELECT
|
|
2
2
|
m.symbol_id,
|
|
3
3
|
d.relative_path,
|
|
4
4
|
COUNT(*) AS ref_count
|
|
@@ -9,4 +9,4 @@ import{a as P}from"./chunk-32R4VYYA.js";import{d as R,e as v,f as D,g as F,h as
|
|
|
9
9
|
${e.pathExclusionsFor("d")}
|
|
10
10
|
GROUP BY m.symbol_id, d.relative_path`),t=new Map;for(let s of r){if(e.isIgnored(s.relative_path)||n.has(s.relative_path))continue;let a=t.get(s.symbol_id);a||(a=new Map,t.set(s.symbol_id,a)),a.set(s.relative_path,s.ref_count)}return t}function x(e,n){let r=U(e);return h(e,{scope:n.scope}).filter(t=>!e.isIgnored(t.relativePath)).filter(t=>!b(t.symbol)).filter(t=>T(t.symbol)).filter(t=>t.isFunctionLike||!t.enclosingSymbol||!T(t.enclosingSymbol)).filter(t=>n.includeTests||C(t.relativePath)).filter(t=>n.includeTests||!r(t.relativePath,t.startLine,t.symbol,t.parentTypeName)).filter(t=>!y(t.symbol)).filter(t=>!_(t.symbol)).filter(t=>n.includeMembers||j(t)).filter(t=>t.endLine-t.startLine+1>=n.minLoc)}function E(e,n){return e.map(r=>I(r,n)).filter(r=>r.cross_file_refs===0).sort((r,t)=>t.loc-r.loc||r.relative_path.localeCompare(t.relative_path)||r.start_line-t.start_line)}function I(e,n){let r=n.get(e.symbolId)??new Map,t=r.get(e.relativePath)??0,s=0;for(let[a,i]of r)a!==e.relativePath&&(s+=i);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,same_file_refs:t,cross_file_refs:s}}function M(e,n){let r=[],t=0,s=0,a=0;for(let i of n){if(e.isIgnored(i.relative_path)||v(e,i.relative_path)||D(e,i.symbol,i.relative_path))continue;let l=i.same_file_refs===0?"dead-code":"file-internal";l==="dead-code"?t++:s++,a+=i.loc,r.push({relativePath:i.relative_path,startLine:i.start_line,endLine:i.end_line,loc:i.loc,symbol:i.symbol,shortName:d(i.symbol),sameFileRefs:i.same_file_refs,kind:l})}return{symbols:r,totalCount:r.length,deadCodeCount:t,fileInternalCount:s,totalLoc:a}}function k(e,n,r){let t=new P(e),s=new Set(t.sourceFiles());for(let a of N(e))s.add(a);t.scanSourceReferences({paths:s,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",skipPath:a=>r.has(a)},a=>{O(e,a)||B(n,a.target.symbolId,a.sourceFile,A(a))})}function N(e){let n=e.all(`SELECT relative_path FROM documents
|
|
11
11
|
WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`);return new Set(n.map(r=>r.relative_path))}function O(e,n){return n.kind==="cross-language-dispatch"&&n.target.relativePath===n.sourceFile?!0:n.kind==="identifier"&&$(e,n)}function A(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function B(e,n,r,t){if(t<=0)return;let s=e.get(n);s||(s=new Map,e.set(n,s)),s.set(r,(s.get(r)??0)+t)}function $(e,n){return n.occurrences>1?!1:f(e,n.sourceFile).some(r=>r.used||r.sourcePath!==n.target.relativePath?!1:r.importedName===n.name||r.localName===n.name)}function H(e,n,r,t){for(let s of n){let a=S(e,s);if(a.length===0)continue;let i=r.get(s.symbolId);i||(i=new Map,r.set(s.symbolId,i));for(let l of a){let o=l.file;o===s.relativePath||e.isIgnored(o)||t.inactiveBarrelPaths.has(o)||!t.includeTests&&!C(o)||i.set(o,Math.max(1,i.get(o)??0))}}}function U(e){let n=new Map,r=t=>{let s=n.get(t);if(s)return s;let a=m(e,t);return s={ranges:a.map(i=>({startLine:i.startLine,endLine:i.endLine})),containers:new Set(a.map(i=>i.containerName).filter(i=>!!i))},n.set(t,s),s};return(t,s,a,i)=>{let l=r(t);for(let o of l.ranges)if(s>=o.startLine&&s<=o.endLine)return!0;if(i&&l.containers.has(i))return!0;for(let o of c(a))if(l.containers.has(o))return!0;return!1}}function C(e){return[...new Set([...F,...L])].every(r=>!W(e,r))}function W(e,n){return new RegExp(`^${n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(e)}function T(e){return g(e)||e.endsWith("().")||e.endsWith(".")}function j(e){return p(e.symbol)||c(e.symbol).length===0}export{Q as a};
|
|
12
|
-
//# sourceMappingURL=chunk-
|
|
12
|
+
//# sourceMappingURL=chunk-4TX5IMMK.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as y}from"./chunk-UAPNU7UP.js";import{f as g,h,o as m,s as p}from"./chunk-QFZE73XF.js";function x(n,e,s,o){let r=g(e);if(!r)return!0;let i=h(n,e);if(!i)return!0;let a=b.get(i);return a||(a=L(i,r),b.set(i,a)),a.get(`${s}:${o}`)??!0}var b=new WeakMap;function L(n,e){let s=e==="rust"?new Set(["function_item","function_signature_item"]):e==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),o=new Map,r=i=>{s.has(i.type)&&o.set(`${i.startPosition.row}:${i.endPosition.row}`,S(i,e));for(let a of i.children)r(a)};return r(n.rootNode),o}function S(n,e){let s=n.namedChildren.find(t=>t.type==="block"||t.type==="statement_block");if(!s)return!1;let o=s.namedChildren.filter(t=>t.type!=="comment"&&t.type!=="line_comment"&&t.type!=="block_comment");if(o.length!==1)return!1;let r=o[0],i=null;if(r.type==="return_statement"||r.type==="expression_statement"?i=r.namedChild(0)??null:e==="rust"&&(r.type==="call_expression"||r.type==="macro_invocation")&&(i=r),!i)return!1;let a=e==="python"?"call":"call_expression";if(i.type!==a)return!1;let f=i.namedChildren.find(t=>t.type==="arguments"||t.type==="argument_list");if(!f)return!1;let c=f.namedChildren.filter(t=>t.type!=="comment"),u=n.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters");if(!u)return!1;let l=[];for(let t of u.namedChildren)if(t.type==="identifier")l.push(t.text);else{let d=t.namedChildren.find(C=>C.type==="identifier");d&&l.push(d.text)}if(c.length!==l.length)return!1;for(let t=0;t<l.length;t+=1){let d=c[t];if(d.type!=="identifier"||d.text!==l[t])return!1}return!0}function k(n,e){let{scope:s,maxLoc:o=15,limit:r=30}=e??{},i=new y(n),a=w(i,s,o),f=i.calleeMap(a),c=[];for(let u of a){let l=_(n,u,f.get(u.symbolId)??[]);l&&c.push(l)}return c.sort((u,l)=>u.loc-l.loc||u.file.localeCompare(l.file)),c.slice(0,r)}function _(n,e,s){let o=P(s);if(o.size!==1||!x(n,e.relativePath,e.startLine,e.endLine))return null;let[,r]=[...o.entries()][0];return{symbol:e.symbol,shortName:m(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:D(e),forwardsTo:r.symbol,forwardsToShort:m(r.symbol),forwardsToFile:r.file}}function P(n){let e=n.some(o=>p(o.symbol))?n.filter(o=>p(o.symbol)):n,s=new Map;for(let o of e)s.has(o.symbol)||s.set(o.symbol,o);return s}function w(n,e,s){return n.productionCallableDefinitions({scope:e,minLoc:3,maxLoc:s,requireFunctionLikeSymbol:!0,excludeRustTraitImplMembers:!0})}function D(n){return n.endLine-n.startLine+1}export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6DVA22YE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as S}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as S}from"./chunk-VEXS3I3N.js";import{h as c,i as y,j as g}from"./chunk-3PVIYZ74.js";import{a}from"./chunk-ZHHMG4UC.js";import{o as r}from"./chunk-QFZE73XF.js";function v(l,i){let o=a(l,i);if(!o)return null;let n=[{file:o.relativePath,line:o.startLine}],t=S(l,o),s=(t.length>0?t:g(l,o)).filter(e=>!l.isIgnored(e.file)).map(e=>({file:e.file,line:e.line,enclosingSymbol:e.enclosingSymbol??"(top-level)",enclosingShort:e.enclosingSymbol?r(e.enclosingSymbol):"(top-level)"})),{producers:u,consumers:b}=p(l,o,s);return{symbol:o.symbol,shortName:r(o.symbol),relativePath:o.relativePath,definitionSites:n.filter(e=>!l.isIgnored(e.file)),usageSites:s,producers:u.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:r(e.symbol),file:e.file})),consumers:b.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:e.symbol===e.file?"(top-level)":r(e.symbol),file:e.file}))}}function p(l,i,o){let n=m(c(l,i,{limit:30}).map(s=>({symbol:s.symbol,file:s.file}))),t=m(y(l,i,{limit:30})),f=t.length>0?t:m(o.map(s=>({symbol:s.enclosingSymbol==="(top-level)"?s.file:s.enclosingSymbol,file:s.file})));return{producers:n,consumers:f}}function m(l){let i=new Set,o=[];for(let n of l){let t=`${n.symbol}|${n.file}`;i.has(t)||(i.add(t),o.push(n))}return o}export{v as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6GPFHZP3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as h}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{g as h}from"./chunk-3PVIYZ74.js";function B(e,s={}){let{minSimilarity:t=.5,limit:n=15,scope:i,minChainLength:r=3,maxChainLength:l=8}=s,a=h(e,i),o=y(a,r,l);if(o.length===0)return[];let f=d(o);return f.length<2?[]:S(C(f,t,n),n)}function d(e){let s=m(e),t=[];for(let n of e){let i=n.filter(r=>!s.has(r));i.length>=2&&t.push({original:n,filtered:i})}return t}function m(e){let{nodeFreq:s,tailFreq:t}=p(e),n=e.length*.9,i=e.length*.8,r=new Set;for(let[a,o]of s)o>n&&r.add(a);for(let[a,o]of t)o>i&&r.add(a);let l=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let a of s.keys()){let o=a.split("/").pop()??"";l.includes(o)&&r.add(a)}return r}function p(e){let s=new Map,t=new Map;for(let n of e){let i=new Set;for(let r of n)i.has(r)||(s.set(r,(s.get(r)??0)+1),i.add(r));for(let r=Math.max(0,n.length-2);r<n.length;r++)t.set(n[r],(t.get(n[r])??0)+1)}return{nodeFreq:s,tailFreq:t}}function C(e,s,t){let n=[];for(let i=0;i<e.length;i++){for(let r=i+1;r<e.length;r++){let l=x(e[i],e[r],s);l&&n.push(l)}if(n.length>t*10)break}return n.sort((i,r)=>Math.abs(r.similarity-i.similarity)>.01?r.similarity-i.similarity:i.divergencePoints.length-r.divergencePoints.length),n}function x(e,s,t){if(!b(e.filtered,s.filtered))return null;let{distance:n,ops:i}=F(e.filtered,s.filtered),r=Math.max(e.filtered.length,s.filtered.length);if(r===0)return null;let l=1-n/r;if(l<t||n===0)return null;let a=i.filter(f=>f.type==="substitute").map(f=>({index:f.indexA,nodeA:e.filtered[f.indexA],nodeB:s.filtered[f.indexB]}));return a.length===0||i.filter(f=>f.type==="match").length<2?null:{chainA:e.original,chainB:s.original,similarity:l,editDistance:n,divergencePoints:a,commonPrefix:A(e.original,s.original),commonSuffix:M(e.original,s.original)}}function b(e,s){let t=new Set(e);return s.some(n=>t.has(n))}function S(e,s){let t=[];for(let n of e)if(t.some(r=>c(n.chainA,r.chainA)&&c(n.chainB,r.chainB))||t.push(n),t.length>=s)break;return t}function y(e,s,t){let n=[];for(let r of e.keys()){if(n.length>=500)break;g(e,r,[r],new Set([r]),s,t,n,500)}return n}function g(e,s,t,n,i,r,l,a){if(l.length>=a)return;if(t.length>=r){t.length>=i&&l.push([...t]);return}let o=e.get(s);if(!o||o.size===0){t.length>=i&&l.push([...t]);return}let f=!1;for(let u of o)if(!n.has(u)&&(n.add(u),t.push(u),g(e,u,t,n,i,r,l,a),t.pop(),n.delete(u),f=!0,l.length>=a))return;!f&&t.length>=i&&l.push([...t])}function F(e,s){let t=e.length,n=s.length,i=Array.from({length:t+1},()=>Array(n+1).fill(0));for(let o=0;o<=t;o++)i[o][0]=o;for(let o=0;o<=n;o++)i[0][o]=o;for(let o=1;o<=t;o++)for(let f=1;f<=n;f++)e[o-1]===s[f-1]?i[o][f]=i[o-1][f-1]:i[o][f]=1+Math.min(i[o-1][f],i[o][f-1],i[o-1][f-1]);let r=[],l=t,a=n;for(;l>0||a>0;)l>0&&a>0&&e[l-1]===s[a-1]?(r.unshift({type:"match",indexA:l-1,indexB:a-1}),l--,a--):l>0&&a>0&&i[l][a]===i[l-1][a-1]+1?(r.unshift({type:"substitute",indexA:l-1,indexB:a-1}),l--,a--):a>0&&i[l][a]===i[l][a-1]+1?(r.unshift({type:"insert",indexA:l,indexB:a-1}),a--):(r.unshift({type:"delete",indexA:l-1,indexB:a}),l--);return{distance:i[t][n],ops:r}}function A(e,s){let t=[];for(let n=0;n<Math.min(e.length,s.length)&&e[n]===s[n];n++)t.push(e[n]);return t}function M(e,s){let t=[],n=e.length-1,i=s.length-1;for(;n>=0&&i>=0&&e[n]===s[i];)t.unshift(e[n]),n--,i--;return t}function c(e,s){if(e.length>s.length)return!1;let t=s.join("\u2192"),n=e.join("\u2192");return t.includes(n)}export{B as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7PRMSA4Z.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as d}from"./chunk-UAPNU7UP.js";import{b as m}from"./chunk-3PVIYZ74.js";import{f as i,o as p,p as u}from"./chunk-QFZE73XF.js";function E(a,y={}){let{scope:b,minLoc:f=3}=y,r=new d(a),s=r.productionCallableDefinitions({scope:b,minLoc:f,excludeEntrySurfaces:!0,excludeRustTraitImplMembers:!0,includeSuppressed:!0}),L=r.crossFileCallerMap(s),h=r.sourceFallbackCallerFiles(s),c=new Set([...L.keys(),...h.keys()]),l=new Map;for(let e of s){let t=u(e.symbol);if(!t)continue;let o=l.get(t)??[];o.push(e.symbolId),l.set(t,o)}let v=a.all(`SELECT relative_path FROM documents WHERE 1 = 1 ${a.pathExclusionsFor("documents")}`);for(let e of v){if(a.isIgnored(e.relative_path)||i(e.relative_path)!=="rust")continue;let t=m(a,e.relative_path);for(let o of t){let n=l.get(o);if(n)for(let M of n)c.add(M)}}let I=new Map(s.map(e=>[e.symbolId,e.symbol])),S=r.calleeMap(s,{additive:!0}),C=new Set([...S.entries()].filter(([e,t])=>{let o=I.get(e);return t.some(n=>n.symbol!==o)}).map(([e])=>e));return s.filter(e=>!c.has(e.symbolId)).filter(e=>!C.has(e.symbolId)).sort((e,t)=>t.endLine-t.startLine-(e.endLine-e.startLine)||e.relativePath.localeCompare(t.relativePath)||e.startLine-t.startLine).map(e=>({symbol:e.symbol,shortName:p(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1}))}export{E as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7YI2M2AQ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as w}from"./chunk-UAPNU7UP.js";import{i as S}from"./chunk-3PVIYZ74.js";import{a as g,b as I}from"./chunk-ZHHMG4UC.js";import{E as p,o as h,q as d}from"./chunk-QFZE73XF.js";function $(s,l,r={}){let{maxDepth:y=5,scope:b}=r,m=g(s,l);if(!m)return[];let f=[],c=new Set([m.symbolId]),u=new Set,i=[m];for(let n=1;n<=y&&i.length!==0;n++){let e=[];for(let t of i)for(let o of M(s,t,b)){let a=`${o.file}|${o.shortName}`;if(o.symbolId!==null){if(c.has(o.symbolId))continue;c.add(o.symbolId)}else if(u.has(a))continue;u.add(a),f.push({symbol:o.symbol,shortName:o.shortName,file:o.file,depth:n}),o.symbolId!==null&&o.symbolMatch&&e.push(o.symbolMatch)}i=e}return f.sort((n,e)=>n.depth-e.depth||n.file.localeCompare(e.file)),f}function M(s,l,r){let y=new w(s),b=S(s,l,{limit:500}).filter(e=>!s.isIgnored(e.file)).filter(e=>!r||e.file.includes(r)),m=new Set(b.map(e=>e.file)),f=y.crossFileCallerMap().get(l.symbolId)??new Set,c=[];for(let e of f){if(m.has(e)||s.isIgnored(e)||r&&!e.includes(r))continue;let t=y.definitionsForFile(e),o=t.length>0?p(t,t[0].startLine):null;c.push({symbol:o?.symbol??e,file:e})}let u=[...b,...c],i=[],n=new Set;for(let e of u){let t=I(s,e.symbol);if(!t){let a=`${e.file}|${e.symbol}`;if(n.has(a))continue;n.add(a),i.push({symbolId:null,symbol:e.symbol,shortName:h(e.symbol),file:e.file,symbolMatch:null});continue}if(t.symbolId===l.symbolId||s.isIgnored(t.relativePath)||!R(t.symbol))continue;let o=`${t.symbolId}|${t.relativePath}`;n.has(o)||(n.add(o),i.push({symbolId:t.symbolId,symbol:t.symbol,shortName:h(t.symbol),file:t.relativePath,symbolMatch:t}))}return i}function R(s){let l=d(s);return l==="method"||l==="type"||s.endsWith("().")}export{$ as a};
|
|
2
|
+
//# sourceMappingURL=chunk-AADJ7MCQ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as S}from"./chunk-
|
|
1
|
+
import{c as S}from"./chunk-VEXS3I3N.js";import{j as d}from"./chunk-3PVIYZ74.js";import{a as f}from"./chunk-ZHHMG4UC.js";import{d as a,o as s,s as u,y as m,z as g}from"./chunk-QFZE73XF.js";function _(n,o){let e=f(n,o);if(!e)return{definitions:[],referencedBy:[]};let i=n.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",e.symbolId),t=g(i?.documentation??null),c=n.isIgnored(e.relativePath)?[]:[{relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,signature:b(t,i?.display_name??null,e.symbol),source:y(n,e.relativePath,e.startLine,e.endLine)}],l=S(n,e),p=(l.length>0?l:d(n,e)).filter(r=>!n.isIgnored(r.file)).map(r=>({relativePath:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol,enclosingShort:r.enclosingSymbol?s(r.enclosingSymbol):"(top-level)"}));return{definitions:c,referencedBy:p}}function y(n,o,e,i){let t=a(n,o);if(!t)return null;let l=t.split(`
|
|
2
2
|
`).slice(e,i+1).join(`
|
|
3
3
|
`).trimEnd();return l.length>0?l:null}function b(n,o,e){let i=m(n);if(i&&!h(i))return i;let t=(o??"").trim();return t?u(e)&&!t.endsWith("()")?`${t}()`:t:s(e)}function h(n){return n.startsWith("undefined")||n.includes("|")||n.includes("```")}export{_ as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-AV7BOODV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as F,b as d,d as R,e as $}from"./chunk-RKTDEIHF.js";import{a as k}from"./chunk-
|
|
1
|
+
import{a as F,b as d,d as R,e as $}from"./chunk-RKTDEIHF.js";import{a as k}from"./chunk-UAPNU7UP.js";import{h as B}from"./chunk-3PVIYZ74.js";import{a as x}from"./chunk-ZHHMG4UC.js";import{d as P,o as p,p as M,s as w,v as q}from"./chunk-QFZE73XF.js";function ne(t,i,e={}){let{minSimilarity:r=.4,limit:a=20}=e,s=V(t,i);if(!s)return[];if(!w(s.symbol))return[];let n=_(t,s,r);return n.length>0?n.slice(0,a):U(t,i,{minSimilarity:r,limit:a})}function _(t,i,e){let r=E(t,{minCallees:3,excludeSymbol:i.symbol}),a=R([i,...r].map(n=>n.callees)),s=[];for(let n of r){if(n.callees.size<3)continue;let l=v(i,n,a,{minSimilarity:e,requireSignificantShared:1,requireSharedCount:0});l&&s.push(l)}return s.sort((n,l)=>l.similarity-n.similarity),s}function v(t,i,e,r){let{similarity:a,significantShared:s}=$(t.callees,i.callees,e);if(a<r.minSimilarity)return null;let n=F(t.callees,i.callees).size;if(s.length<r.requireSignificantShared&&n<r.requireSharedCount)return null;let l=s.length>0?s:[...F(t.callees,i.callees)];return{symbolA:t.symbol,shortNameA:p(t.symbol),fileA:t.file,symbolB:i.symbol,shortNameB:p(i.symbol),fileB:i.file,similarity:a,similarityBasis:"callees",sharedCallees:l.map(p),uniqueToA:[...d(t.callees,i.callees)].map(p),uniqueToB:[...d(i.callees,t.callees)].map(p)}}function re(t,i={}){let{minSimilarity:e=.5,limit:r=20,scope:a,minCallees:s=4,crossFileOnly:n=!1}=i,l=E(t,{minCallees:s,scope:a}),o=R(l.map(c=>c.callees)),u=new Map;for(let c of l)for(let m of c.callees)u.set(m,(u.get(m)??0)+1);let f=Math.max(8,Math.ceil(Math.sqrt(l.length))),S=new Map;for(let c=0;c<l.length;c+=1)for(let m of l[c].callees){if((u.get(m)??0)>f)continue;let g=S.get(m);g||(g=[],S.set(m,g)),g.push(c)}let C=[],A=new Set;e:for(let c=0;c<l.length;c+=1){let m=l[c],g=new Set;for(let D of m.callees){let y=S.get(D);if(y)for(let b of y)b>c&&g.add(b)}for(let D of g){let y=`${c}|${D}`;if(A.has(y))continue;A.add(y);let b=l[D];if(n&&m.file===b.file)continue;if(m.paramCount>=0&&b.paramCount>=0){let j=Math.abs(m.paramCount-b.paramCount),L=Math.max(2,Math.ceil(Math.max(m.paramCount,b.paramCount)*.5));if(j>L)continue}let z=v(m,b,o,{minSimilarity:e,requireSignificantShared:2,requireSharedCount:4});if(z&&(C.push(z),C.length>r*5))break e}}return C.sort((c,m)=>m.similarity-c.similarity),C.slice(0,r)}var O=["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 V(t,i){let e=x(t,i),r=new k(t);if(!e)return null;let a=B(t,e);return{symbol:e.symbol,file:e.relativePath,callees:I(a.map(s=>s.symbol)),paramCount:r.callableSignature(e)?.paramCount??-1}}function E(t,i){let{minCallees:e,scope:r,excludeSymbol:a}=i,s=new k(t),n=s.productionCallableDefinitions({scope:r,minLoc:5,excludeSymbol:a}),l=s.calleeMap(n);return n.map(o=>({symbol:o.symbol,file:o.relativePath,callees:I((l.get(o.symbolId)??[]).map(u=>u.symbol)),paramCount:s.callableSignature(o)?.paramCount??-1})).filter(o=>o.callees.size>=e)}function I(t){return new Set([...t].filter(i=>!Z(i)))}function Z(t){return O.some(i=>t.includes(i))}function U(t,i,e){let r=W(t,i);if(!r||r.tokens.size<3)return[];let a=e.minSimilarity>=.5?e.minSimilarity:.3,s=[];for(let n of G(t)){if(n.symbol===r.symbol||n.tokens.size<3)continue;let l=F(r.tokens,n.tokens);if(l.size<2)continue;let o=new Set([...r.tokens,...n.tokens]),u=o.size>0?l.size/o.size:0;u<a||s.push({symbolA:r.symbol,shortNameA:p(r.symbol),fileA:r.file,symbolB:n.symbol,shortNameB:p(n.symbol),fileB:n.file,similarity:u,similarityBasis:"source-tokens",sharedCallees:[...l].sort(),uniqueToA:[...d(r.tokens,n.tokens)].sort(),uniqueToB:[...d(n.tokens,r.tokens)].sort()})}return s.sort((n,l)=>l.similarity-n.similarity||n.shortNameB.localeCompare(l.shortNameB)),s.slice(0,e.limit)}function W(t,i){let e=x(t,i);if(!e||!w(e.symbol))return null;let r=K(t,e);return r?{symbol:e.symbol,file:e.relativePath,tokens:r}:null}function K(t,i){let e=M(i.symbol),r=N(t,i.relativePath,i.startLine,i.endLine,e),a=T(r,e);return a.size>0?a:null}function G(t){let i=new k(t);return i.scopedDefinitions().filter(e=>e.isFunctionLike).filter(e=>i.fileKind(e.relativePath)!=="test").filter(e=>!q(e.symbol)).map(e=>({symbol:e.symbol,file:e.relativePath,tokens:T(N(t,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)})).filter(e=>e.tokens.size>0)}function N(t,i,e,r,a){let s=P(t,i);if(!s)return"";let n=s.split(`
|
|
2
2
|
`);if(r>=e&&r-e<=12)return n.slice(e,r+1).join(`
|
|
3
3
|
`);let l=[new RegExp(`\\bdef\\s+${h(a)}\\b`),new RegExp(`\\bfun\\s+${h(a)}\\b`),new RegExp(`\\bfn\\s+${h(a)}\\b`),new RegExp(`\\bfunction\\s+${h(a)}\\b`),new RegExp(`\\b${h(a)}\\s*\\(`)],o=n.findIndex(u=>l.some(f=>f.test(u)));if(o>=0){let u=o;for(let f=o+1;f<n.length&&f<=o+8;f++){let S=n[f]??"";if(f>o&&J(S)||(u=f,S.trim()===""&&f>o+1))break}return n.slice(o,u+1).join(`
|
|
4
4
|
`)}return n.slice(e,Math.min(n.length,e+8)).join(`
|
|
5
5
|
`)}function T(t,i){if(!t)return new Set;let e=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"]),r=H(i),s=t.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(n=>n.trim()).filter(n=>n.length>1).filter(n=>!e.has(n)).filter(n=>!r.has(n));return new Set(s)}function H(t){return new Set(t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(i=>i.toLowerCase()).filter(i=>i.length>1))}function J(t){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(t)}function h(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{ne as a,re as b};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-AXP4H62Q.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as g}from"./chunk-UAPNU7UP.js";import{o as f}from"./chunk-QFZE73XF.js";function L(e,i={}){let{scope:t,minLoc:o=10,minCallees:r=6,limit:n=20}=i,l=new g(e),s=l.productionCallableDefinitions({scope:t,minLoc:o,excludeTypesFiles:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:!0}),c=l.calleeMap(s),d=[];for(let a of s){let u=m(a,c.get(a.symbolId)??[],r);u&&d.push(u)}return d.sort((a,u)=>u.clusters.length-a.clusters.length||u.loc-a.loc),d.slice(0,n)}function m(e,i,t){let o=new Set(i.map(s=>s.symbol));if(o.size<t)return null;let r=p(o,i),n=h(o,r);if(n.length<2)return null;let l=C(n,r);return l.length===0?null:{symbol:e.symbol,shortName:f(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:b(e),totalCallees:o.size,clusters:l}}function p(e,i){let t=new Map;for(let r of e)t.set(r,new Set);let o=new Map;for(let r of i){let n=o.get(r.chunkId);n||(n=new Set,o.set(r.chunkId,n)),n.add(r.symbol)}for(let r of o.values()){let n=[...r];for(let l=0;l<n.length;l++)for(let s=l+1;s<n.length;s++)t.get(n[l]).add(n[s]),t.get(n[s]).add(n[l])}return t}function h(e,i){let t=new Set,o=[];for(let r of e){if(t.has(r))continue;let n=new Set,l=[r];for(;l.length>0;){let s=l.pop();if(!t.has(s)){t.add(s),n.add(s);for(let c of i.get(s)??[])t.has(c)||l.push(c)}}o.push(n)}return o}function C(e,i){return e.filter(t=>t.size>=3).map(t=>S(t,e,i)).filter(t=>t.isolation>.5).sort((t,o)=>o.isolation-t.isolation)}function S(e,i,t){let o=new Set;for(let s of i)if(s!==e)for(let c of s)o.add(c);let r=0;for(let s of e)for(let c of t.get(s)??[])o.has(c)&&r++;let n=e.size*o.size,l=n>0?1-r/n:1;return{callees:[...e].map(f),isolation:l}}function b(e){return e.endLine-e.startLine+1}export{L as a};
|
|
2
|
+
//# sourceMappingURL=chunk-C4C3T4K3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-UAPNU7UP.js";import{a as l}from"./chunk-ZHHMG4UC.js";import{p as r,r as a}from"./chunk-QFZE73XF.js";import{basename as d}from"path";function g(t,c){let o=l(t,c);if(!o)return[];let s=r(o.symbol),i=new m(t).definitionsForFile(o.relativePath).filter(e=>a(e.symbol)),n=i.filter(e=>e.parentTypeName===s||e.symbol.includes(s));return(n.length>0?n:p(d(o.relativePath))===s?i.filter(e=>e.symbol.includes("<invalid-global-code>")):[]).map(e=>({startLine:e.startLine,endLine:e.endLine,name:r(e.symbol)}))}function p(t){return t.replace(/\.[^.]+$/,"")}export{g as a};
|
|
2
|
+
//# sourceMappingURL=chunk-CSRPJCWO.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{h as g}from"./chunk-3PVIYZ74.js";import{a as m}from"./chunk-ZHHMG4UC.js";import{o as r}from"./chunk-QFZE73XF.js";function w(i,f,p){let s=m(i,f),n=m(i,p);if(!s||!n)return null;let c=new Set(g(i,s).map(e=>e.symbol)),h=new Set(g(i,n).map(e=>e.symbol)),l=[];for(let e of c)h.has(e)&&l.push(e);let o=[];for(let e of c)h.has(e)||o.push(e);let a=[];for(let e of h)c.has(e)||a.push(e);let u=new Set([...c,...h]),d=u.size>0?l.length/u.size:0,t;u.size===0?t="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":l.length===0?t="These functions do not share any callees. They are not a callee-based consolidation candidate.":o.length===0&&a.length===0?t="These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.":o.length===0?t="A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.":a.length===0?t="B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.":o.length<=2&&a.length<=2?t=`Create a shared function with the ${l.length} common callees. Pass the ${o.length+a.length} divergent callees as parameters or strategy callbacks.`:t=`Extract the ${l.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${o.length} callees in A, ${a.length} in B).`;let y=s.endLine-s.startLine+1,b=n.endLine-n.startLine+1;return{symbolA:{symbol:s.symbol,shortName:r(s.symbol),file:s.relativePath,loc:y},symbolB:{symbol:n.symbol,shortName:r(n.symbol),file:n.relativePath,loc:b},similarity:d,sharedCallees:l.map(r),uniqueToA:o.map(r),uniqueToB:a.map(r),consolidationStrategy:t}}export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-CYJMOTIH.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as l}from"./chunk-MO65UK5V.js";import{a as n}from"./chunk-
|
|
1
|
+
import{b as l}from"./chunk-MO65UK5V.js";import{a as n}from"./chunk-UAPNU7UP.js";import{o as i,r as a}from"./chunk-QFZE73XF.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-MO65UK5V.js";import{a as n}from"./chunk-32R4VYYA.js";
|
|
|
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 n(e);return r.flatMap(o=>t.definitionsForFile(o).filter(s=>a(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-
|
|
29
|
+
//# sourceMappingURL=chunk-DLWRLPKO.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
1
|
+
import{a as m}from"./chunk-UAPNU7UP.js";import{c as u}from"./chunk-YXMHTJYY.js";import{e as l,f as a}from"./chunk-KW2F3WSV.js";import{o as d,q as c}from"./chunk-QFZE73XF.js";function C(e,t={}){let{scope:o,limit:r}=t,n=new m(e),i=x([...p(e,o),...f(e,n,o)]);return N(i),r?i.slice(0,r):i}function p(e,t){let o=[];for(let r of R(e,t)){if(e.isIgnored(r.barrel_path)||e.isIgnored(r.original_path)||u(e,r.barrel_path))continue;let n=b(e,r),i=n?.barrel_consumers??0,s=n?.direct_consumers??0;i!==0||s!==0||o.push({barrelFile:r.barrel_path,symbol:r.symbol,shortName:d(r.symbol),originalFile:r.original_path,barrelConsumers:i,directConsumers:s})}return o}function R(e,t){let o=t?`AND barrel_d.relative_path LIKE '%${t}%'`:"";return e.all(`SELECT DISTINCT
|
|
2
2
|
barrel_d.id AS barrel_doc_id,
|
|
3
3
|
barrel_d.relative_path AS barrel_path,
|
|
4
4
|
gs.id AS symbol_id,
|
|
@@ -67,4 +67,4 @@ import{a as m}from"./chunk-32R4VYYA.js";import{c as u}from"./chunk-PK4U6NWP.js";
|
|
|
67
67
|
WHERE 1 = 1
|
|
68
68
|
${e.pathExclusionsFor("documents")}
|
|
69
69
|
ORDER BY relative_path`),n=new Set;for(let i of r)if(!(e.isIgnored(i.relative_path)||i.relative_path===o))for(let s of l(e,i.relative_path))s.sourcePath===t&&n.add(i.relative_path);return n.size}function S(e,t){let o=e.definitionsForFile(t);return o.find(r=>c(r.symbol)==="method")??o[0]??null}function x(e){let t=new Set,o=[];for(let r of e){let n=`${r.barrelFile}|${r.symbol}|${r.originalFile}`;t.has(n)||(t.add(n),o.push(r))}return o}function N(e){e.sort((t,o)=>o.directConsumers-t.directConsumers||t.barrelFile.localeCompare(o.barrelFile)||t.shortName.localeCompare(o.shortName))}export{C as a};
|
|
70
|
-
//# sourceMappingURL=chunk-
|
|
70
|
+
//# sourceMappingURL=chunk-E2V5SE6M.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as u,b as g,c as S}from"./chunk-LJ2YWNQF.js";import{a as p}from"./chunk-
|
|
1
|
+
import{a as u,b as g,c as S}from"./chunk-LJ2YWNQF.js";import{a as p}from"./chunk-UAPNU7UP.js";import{a as y}from"./chunk-YXMHTJYY.js";import{e as d}from"./chunk-KW2F3WSV.js";import{n as m}from"./chunk-Z4AMQWVY.js";import l from"path";function q(t,n){let{scope:r,minDeviation:i=5}=n??{},s=new p(t).fileDependencyGraph(r),c=M(t,r);return R([...D(t,s,c),...v(s),...b(s,i)])}function D(t,n,r){let i=[];for(let[e,s]of n){if(a(e))continue;let c=r.get(e)??new Set;for(let o of s)if(!a(o)&&!c.has(o)){if(F(t,e,o)||w(t,e,o)||L(t,e,o)||$(o)||x(t,e,o)||P(o))continue;i.push({file:e,kind:"unused-import",description:`Depends on ${o} but references none of its symbols`,dep:o})}}return i}function v(t){let n=[],r=N(t);for(let[i,e]of t){if(a(i))continue;let s=u(i);for(let c of e){if(a(c))continue;let o=u(c);if(s===o)continue;(g(s,o)??r.get(`${s}->${o}`))==="violation"&&n.push({file:i,kind:"layer-violation",description:`Imports from ${o}/ (${c}) \u2014 may cross architectural boundary`,dep:c,detail:`${s}/ should not depend on ${o}/`})}}return n}function b(t,n){let r=[];for(let[i,e]of _(t)){let s=e.filter(o=>!a(o));if(s.length<n)continue;let c=k(t,s);for(let o of s)for(let f of t.get(o)??[])a(f)||(c.get(f)??0)===1&&l.dirname(f)!==i&&l.dirname(f)!==l.dirname(i)&&(S(o,f)||r.push({file:o,kind:"pattern-deviation",description:`Only file in ${i}/ that depends on ${f}`,dep:f}))}return r}function R(t){return{results:t,unusedImports:t.filter(n=>n.kind==="unused-import").length,layerViolations:t.filter(n=>n.kind==="layer-violation").length,patternDeviations:t.filter(n=>n.kind==="pattern-deviation").length}}function _(t){let n=new Map;for(let r of t.keys()){let i=l.dirname(r),e=n.get(i);e||(e=[],n.set(i,e)),e.push(r)}return n}function k(t,n){let r=new Map;for(let i of n)for(let e of t.get(i)??[])a(e)||r.set(e,(r.get(e)??0)+1);return r}function M(t,n){let r=new Map;return E(t,r,n),O(t,r),r}function E(t,n,r){for(let i of I(t,r))h(t,n,i.from_file,i.to_file)}function I(t,n){let r=n?`AND d1.relative_path LIKE '%${n}%'`:"";return t.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
|
|
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
|
|
@@ -16,4 +16,4 @@ import{a as u,b as g,c as S}from"./chunk-LJ2YWNQF.js";import{a as p}from"./chunk
|
|
|
16
16
|
${t.pathExclusionsFor("d1","d2")}
|
|
17
17
|
${r}`)}function O(t,n){let r=new p(t),i=t.all(`SELECT relative_path FROM documents
|
|
18
18
|
WHERE 1 = 1 ${t.pathExclusionsFor("documents")}`);r.scanSourceReferences({paths:i.map(e=>e.relative_path),includeRustAttributeNames:!0,identifierResolution:"permissive"},e=>{e.target.relativePath!==e.sourceFile&&(t.isIgnored(e.target.relativePath)||h(t,n,e.sourceFile,e.target.relativePath))})}function h(t,n,r,i){if(t.isIgnored(r)||t.isIgnored(i))return;let e=n.get(r);e||(e=new Set,n.set(r,e)),e.add(i)}function N(t){let n=new Map;for(let[i,e]of t){if(a(i))continue;let s=u(i);for(let c of e){if(a(c))continue;let o=u(c);if(s===o||g(s,o))continue;let f=`${s}->${o}`;n.set(f,(n.get(f)??0)+1)}}let r=new Map;for(let[i,e]of n)r.set(i,e<=2?"violation":"ok");return r}function $(t){return t.includes("types")||t.endsWith(".d.ts")}function F(t,n,r){let i=m(t,n).filter(e=>e.sourcePath===r);return i.length>0&&i.some(e=>e.isUsed)}function w(t,n,r){let i=d(t,n).filter(e=>e.sourcePath===r);return i.length>0&&i.some(e=>e.used)}function L(t,n,r){let i=d(t,n).filter(e=>e.sourcePath===r);return i.length>0&&i.every(e=>e.isTypeOnly===!0)}function P(t){return t.endsWith(".vue")}function x(t,n,r){let i=d(t,n).filter(e=>e.sourcePath===r);return i.length===0?!1:i.every(e=>e.kind==="side-effect"||e.kind==="namespace"&&e.usedMembers.length===0&&!e.used)}function a(t){let n=y(t);return!!(n==="entry"||n==="barrel"||n==="test"||n==="worker"||T(l.basename(t)))}function T(t){return!!(t==="index.ts"||t==="index.js"||t==="cli.ts"||t==="main.ts"||t==="main.rs"||t.includes("worker.")||t.includes("postinstall.")||t==="health.ts"||t==="health.js")}export{q as a};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-GPY33RTH.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as r}from"./chunk-MO65UK5V.js";import{g as l}from"./chunk-
|
|
1
|
+
import{a as r}from"./chunk-MO65UK5V.js";import{g as l}from"./chunk-3PVIYZ74.js";import{a as c}from"./chunk-ZHHMG4UC.js";import{o as d}from"./chunk-QFZE73XF.js";function f(e,t){let o=c(e,t);if(!o)return[];let i=e.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
WHERE m.symbol_id = ?
|
|
@@ -59,4 +59,4 @@ import{a as r}from"./chunk-MO65UK5V.js";import{g as l}from"./chunk-4X7C236P.js";
|
|
|
59
59
|
GROUP BY d.id
|
|
60
60
|
ORDER BY symbol_count DESC
|
|
61
61
|
LIMIT ?`,o).filter(s=>!e.isIgnored(s.relative_path)).map(s=>({name:s.relative_path,count:s.symbol_count}))}export{f as a,y as b,b as c,I as d};
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-HVNVO6UW.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as g}from"./chunk-UAPNU7UP.js";import{c as h}from"./chunk-VEXS3I3N.js";import{h as u,j as p}from"./chunk-3PVIYZ74.js";import{a as d,b as y}from"./chunk-ZHHMG4UC.js";import{E as S,o as f}from"./chunk-QFZE73XF.js";function j(e,o,r={}){let{direction:c="backward",maxDepth:s=3}=r,t=d(e,o);return t?c==="backward"?w(e,t,s):R(e,t):null}function w(e,o,r){let c=[],s=new Set([o.symbol]),t=[o];for(let a=1;a<=r&&t.length!==0;a++){let n=[];for(let l of t){let i=u(e,l);for(let m of i){if(s.has(m.symbol))continue;s.add(m.symbol),c.push({symbol:m.symbol,shortName:f(m.symbol),file:m.file,relationship:a===1?"referenced within definition (callee)":`depth ${a} callee`});let b=y(e,m.symbol);b&&!e.isIgnored(b.relativePath)&&n.push(b)}}t=n}return{symbol:o.symbol,shortName:f(o.symbol),direction:"backward",connectedSymbols:c}}function R(e,o){let r=h(e,o),c=r.length>0?r:p(e,o),s=new Set,t=[],a=new g(e);for(let n of c){if(t.length>=30)break;if(e.isIgnored(n.file))continue;let l=n.enclosingSymbol??S(a.definitionsForFile(n.file),n.line)?.symbol??null;if(!l||l===o.symbol)continue;let i=y(e,l);!i||e.isIgnored(i.relativePath)||s.has(i.symbol)||(s.add(i.symbol),t.push({symbol:i.symbol,shortName:f(i.symbol),file:i.relativePath,relationship:`references target at ${n.file}:${n.line+1}`}))}return t.sort((n,l)=>n.file.localeCompare(l.file)),{symbol:o.symbol,shortName:f(o.symbol),direction:"forward",connectedSymbols:t}}export{j as a};
|
|
2
|
+
//# sourceMappingURL=chunk-I377UMS2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as l}from"./chunk-UAPNU7UP.js";import{a as i}from"./chunk-ZHHMG4UC.js";import{o as s,q as m,w as n}from"./chunk-QFZE73XF.js";function c(r,a){let t=i(r,a);return t?new l(r).definitionsForFile(t.relativePath).filter(e=>e.symbol!==t.symbol).filter(e=>n(t.symbol,e.symbol)).sort((e,o)=>e.startLine-o.startLine||e.endLine-o.endLine).map(e=>({symbol:e.symbol,shortName:s(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:m(e.symbol)??"unknown"})):[]}export{c as a};
|
|
2
|
+
//# sourceMappingURL=chunk-IKQYNTW3.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{c as m}from"./chunk-
|
|
1
|
+
import{c as m}from"./chunk-VEXS3I3N.js";import{j as g}from"./chunk-3PVIYZ74.js";import{a as R}from"./chunk-ZHHMG4UC.js";import{d as u,s as h}from"./chunk-QFZE73XF.js";function $(t,a){let e=R(t,a);if(!e)return[];let i=!h(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],r=m(t,e),l=(r.length>0?r:g(t,e)).filter(n=>!t.isIgnored(n.file)).map(n=>({relativePath:n.file,line:n.line})),c=S(t,e),s=new Set,f=[];for(let n of[...i,...l,...c]){let p=`${n.relativePath}:${n.line}`;s.has(p)||(s.add(p),f.push(n))}return f}function S(t,a){if(!a.relativePath.endsWith(".rb"))return[];let e=d(a.symbol);if(e.length===0)return[];let o=t.all(`SELECT relative_path
|
|
2
2
|
FROM documents
|
|
3
3
|
WHERE relative_path LIKE '%.rb'
|
|
4
4
|
${t.pathExclusionsFor("documents")}
|
|
5
5
|
ORDER BY relative_path`),i=[];for(let r of o){if(t.isIgnored(r.relative_path))continue;let l=u(t,r.relative_path);if(!l)continue;let c=l.split(`
|
|
6
6
|
`);for(let s=0;s<c.length;s++){let f=c[s]??"";e.some(n=>new RegExp(`@${n}\\b|\\b${n}:`).test(f))&&i.push({relativePath:r.relative_path,line:s})}}return i}function d(t){let e=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),o=e.split("_").filter(Boolean),i=new Set;return e&&i.add(e),o.length>=1&&i.add(o[o.length-1]),o.length>=2&&i.add(o.slice(-2).join("_")),[...i]}export{$ as a};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-IZ4KV37N.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as d}from"./chunk-RKTDEIHF.js";import{g as a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as d}from"./chunk-RKTDEIHF.js";import{g as a}from"./chunk-3PVIYZ74.js";function F(t,i={}){let{minSimilarity:f=.5,limit:n=20,scope:o,filePattern:s}=i,u=i.minDeps??(s?1:3),e=g(t,{scope:o,minDeps:u}),p=[];if(s){let r=e.find(l=>l.file.includes(s));if(!r)return[];for(let l of e){if(l.file===r.file)continue;let c=m(r,l,f);c&&p.push(c)}}else for(let r=0;r<e.length;r++){for(let l=r+1;l<e.length;l++){let c=m(e[r],e[l],f);c&&p.push(c)}if(p.length>n*5)break}return p.sort((r,l)=>l.similarity-r.similarity),p.slice(0,n)}function g(t,i){let{scope:f,minDeps:n}=i,o=a(t,f),s=h(o),u=[];for(let[e,p]of o)p.size>=n&&u.push({file:e,deps:new Set([...p].filter(r=>!s.has(r)))});return u}function h(t){let i=new Set,f=t.size;if(f===0)return i;let n=new Map;for(let o of t.values())for(let s of o)n.set(s,(n.get(s)??0)+1);for(let[o,s]of n)s>=5&&s/f>.3&&i.add(o);return i}function m(t,i,f){let n=new Set;for(let e of t.deps)i.deps.has(e)&&n.add(e);if(n.size<3||t.deps.size<4||i.deps.size<4)return null;let o=d(t.deps,i.deps);if(o<f)return null;let s=[];for(let e of t.deps)i.deps.has(e)||s.push(e);let u=[];for(let e of i.deps)t.deps.has(e)||u.push(e);return{fileA:t.file,fileB:i.file,similarity:o,sharedDeps:[...n],uniqueToA:s,uniqueToB:u}}export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-KBGFYKOJ.js.map
|