scip-query 0.6.4 → 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 +74 -35
- package/dist/augment-vue-worker.js +2 -0
- package/dist/chunk-25HOGELX.js +2 -0
- package/dist/chunk-2TLYCK2L.js +11 -0
- package/dist/chunk-3PVIYZ74.js +84 -0
- package/dist/chunk-4TX5IMMK.js +12 -0
- package/dist/chunk-6DVA22YE.js +2 -0
- package/dist/{chunk-CGAO6FHN.js → chunk-6GPFHZP3.js} +2 -2
- package/dist/chunk-7LSCW7NF.js +6 -0
- package/dist/chunk-7PRMSA4Z.js +2 -0
- package/dist/chunk-7X7FLQC5.js +2 -0
- package/dist/chunk-7YI2M2AQ.js +2 -0
- package/dist/chunk-AADJ7MCQ.js +2 -0
- package/dist/chunk-AV7BOODV.js +4 -0
- package/dist/chunk-AXP4H62Q.js +6 -0
- package/dist/chunk-C4C3T4K3.js +2 -0
- package/dist/chunk-CSRPJCWO.js +2 -0
- package/dist/chunk-CYJMOTIH.js +2 -0
- package/dist/chunk-DLWRLPKO.js +29 -0
- package/dist/chunk-E2V5SE6M.js +70 -0
- package/dist/{chunk-ZE3BTHTS.js → chunk-ERRUE5G4.js} +4 -4
- package/dist/chunk-GBDZY73J.js +2 -0
- package/dist/chunk-GPY33RTH.js +19 -0
- package/dist/{chunk-4TYGGOLO.js → chunk-H4DXD2FB.js} +1 -1
- package/dist/{chunk-LAXFZ3UW.js → chunk-HVNVO6UW.js} +4 -4
- package/dist/chunk-I377UMS2.js +2 -0
- package/dist/chunk-IKQYNTW3.js +2 -0
- package/dist/chunk-IZ4KV37N.js +7 -0
- package/dist/{chunk-KYT47WU2.js → chunk-KAM4C6ZD.js} +1 -1
- package/dist/{chunk-OOMAS234.js → chunk-KBGFYKOJ.js} +2 -2
- package/dist/chunk-KW2F3WSV.js +5 -0
- package/dist/chunk-LJ2YWNQF.js +2 -0
- package/dist/chunk-MO65UK5V.js +6 -0
- package/dist/{chunk-6UJ5PXER.js → chunk-MXWC53GJ.js} +4 -4
- package/dist/chunk-NIN762LD.js +5 -0
- package/dist/{chunk-5OVBASGY.js → chunk-O6VBAW7P.js} +2 -2
- package/dist/{chunk-IVT2U2BV.js → chunk-OQZF2DQJ.js} +3 -3
- package/dist/chunk-PIRXZGV6.js +2 -0
- package/dist/{chunk-GALIM3IE.js → chunk-Q2ALKKSE.js} +4 -4
- package/dist/chunk-Q4R2IYA3.js +7 -0
- package/dist/{chunk-AW3QJT4O.js → chunk-QFBJZHMV.js} +3 -3
- package/dist/chunk-QFZE73XF.js +84 -0
- package/dist/chunk-QPJG6VRT.js +16 -0
- package/dist/chunk-QRYEOK3M.js +2 -0
- package/dist/{chunk-LORWXBOO.js → chunk-RKTDEIHF.js} +1 -1
- package/dist/chunk-TBJDUS4E.js +71 -0
- package/dist/chunk-TLRA5TR6.js +2 -0
- package/dist/chunk-TUV2VI7D.js +7 -0
- package/dist/chunk-UAPNU7UP.js +2 -0
- package/dist/chunk-URCJTFOD.js +2 -0
- package/dist/chunk-UUIWMLDX.js +39 -0
- package/dist/chunk-VEXS3I3N.js +2 -0
- package/dist/chunk-VRC3WKKE.js +2 -0
- package/dist/chunk-WFDTS7XL.js +2 -0
- package/dist/chunk-Y4DS3MDC.js +5 -0
- package/dist/chunk-YJODB2F5.js +2 -0
- package/dist/{chunk-QID23O53.js → chunk-YXMHTJYY.js} +2 -2
- package/dist/chunk-Z4AMQWVY.js +90 -0
- package/dist/chunk-ZHHMG4UC.js +114 -0
- package/dist/cli.js +487 -388
- package/dist/{db-DKhNQ75l.d.ts → db-BZPa7dzJ.d.ts} +19 -9
- package/dist/index.d.ts +224 -13
- package/dist/index.js +45 -31
- package/dist/postinstall.js +1 -1
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/deep-chains.d.ts +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/drift-policy.d.ts +6 -0
- package/dist/queries/drift-policy.js +2 -0
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/stats.js +1 -1
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +10 -63
- package/package.json +5 -3
- package/dist/chunk-2DQK2IDZ.js +0 -19
- package/dist/chunk-4HCKXL7T.js +0 -6
- package/dist/chunk-4Q2D5BMS.js +0 -2
- package/dist/chunk-5IM4IQ6N.js +0 -2
- package/dist/chunk-5NSYCQWM.js +0 -6
- package/dist/chunk-6QKHOBC6.js +0 -2
- package/dist/chunk-6U5UHIRD.js +0 -5
- package/dist/chunk-AQFXC7CF.js +0 -2
- package/dist/chunk-BSONDC3H.js +0 -7
- package/dist/chunk-ECT6SOBO.js +0 -2
- package/dist/chunk-FFE3RZ65.js +0 -2
- package/dist/chunk-FT4WPAEX.js +0 -65
- package/dist/chunk-G6HYVVRV.js +0 -2
- package/dist/chunk-GVVKLMXG.js +0 -10
- package/dist/chunk-HVM6SQPQ.js +0 -2
- package/dist/chunk-IDCWMWWP.js +0 -5
- package/dist/chunk-IJO2HZFL.js +0 -2
- package/dist/chunk-INPQVQ6O.js +0 -12
- package/dist/chunk-JSBWVSES.js +0 -39
- package/dist/chunk-MFVPKCS5.js +0 -2
- package/dist/chunk-MWCN46ZX.js +0 -89
- package/dist/chunk-N3Z2SJCR.js +0 -2
- package/dist/chunk-NKU7Z242.js +0 -8
- package/dist/chunk-P6IUCZA3.js +0 -24
- package/dist/chunk-PM3GTZ4I.js +0 -2
- package/dist/chunk-QL5MJOVA.js +0 -84
- package/dist/chunk-QWFK4QOQ.js +0 -2
- package/dist/chunk-RBYC6PHE.js +0 -2
- package/dist/chunk-TS7E5XBZ.js +0 -29
- package/dist/chunk-TUC6IWTY.js +0 -2
- package/dist/chunk-USMVRM6F.js +0 -2
- package/dist/chunk-VTZPTRKS.js +0 -7
- package/dist/chunk-WUYKGQSK.js +0 -2
- package/dist/chunk-X7LOLGYY.js +0 -2
- package/dist/chunk-XGOEZVMA.js +0 -7
- package/dist/chunk-Y6NOLG4X.js +0 -70
- package/dist/chunk-YVQ7CIKO.js +0 -6
- package/dist/chunk-ZIFKQQW2.js +0 -4
- package/dist/chunk-ZOR6FW74.js +0 -2
- package/dist/chunk-ZPZLVFJQ.js +0 -41
- package/dist/chunk-ZZ3F6P3X.js +0 -2
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
|
|
|
@@ -253,11 +290,11 @@ Show a symbol's definition (with signature) and every file that references it. L
|
|
|
253
290
|
```bash
|
|
254
291
|
scip-query trace parseSymbol
|
|
255
292
|
# ═══ DEFINITION ═══
|
|
256
|
-
# src/symbol-parser.ts:35-99 — parseSymbol(raw: string): ScipSymbol | ScipLocalSymbol
|
|
293
|
+
# src/symbols/symbol-parser.ts:35-99 — parseSymbol(raw: string): ScipSymbol | ScipLocalSymbol
|
|
257
294
|
#
|
|
258
295
|
# ═══ REFERENCED BY ═══
|
|
259
296
|
# src/index.ts
|
|
260
|
-
# src/symbol-parser.ts
|
|
297
|
+
# src/symbols/symbol-parser.ts
|
|
261
298
|
```
|
|
262
299
|
|
|
263
300
|
**Value:** End-to-end symbol investigation. Answers "where is this defined, what's its signature, and who uses it?" in one command.
|
|
@@ -339,8 +376,8 @@ List all internal files that this file depends on (forward dependencies).
|
|
|
339
376
|
|
|
340
377
|
```bash
|
|
341
378
|
scip-query deps cli.ts
|
|
342
|
-
# src/config.ts
|
|
343
|
-
# src/db.ts
|
|
379
|
+
# src/runtime/config.ts
|
|
380
|
+
# src/storage/db.ts
|
|
344
381
|
# src/queries/index.ts
|
|
345
382
|
# src/reindex/index.ts
|
|
346
383
|
```
|
|
@@ -382,11 +419,11 @@ scip-query system queries
|
|
|
382
419
|
# ...
|
|
383
420
|
#
|
|
384
421
|
# ═══ DEPENDS ON (internal) ═══
|
|
385
|
-
# src/db.ts
|
|
386
|
-
# src/symbol-parser.ts
|
|
422
|
+
# src/storage/db.ts
|
|
423
|
+
# src/symbols/symbol-parser.ts
|
|
387
424
|
#
|
|
388
425
|
# ═══ DEPENDED ON BY ═══
|
|
389
|
-
# src/cli.ts
|
|
426
|
+
# src/runtime/cli.ts
|
|
390
427
|
# src/index.ts
|
|
391
428
|
```
|
|
392
429
|
|
|
@@ -399,9 +436,9 @@ scip-query system queries
|
|
|
399
436
|
What symbols do external consumers actually use from this module? The true public API — not what's exported, but what's actually imported and referenced by other modules.
|
|
400
437
|
|
|
401
438
|
```bash
|
|
402
|
-
scip-query surface db.ts
|
|
403
|
-
# src/cli.ts → ScipDatabase
|
|
404
|
-
# src/cli.ts → ScipDatabase:close()
|
|
439
|
+
scip-query surface storage/db.ts
|
|
440
|
+
# src/runtime/cli.ts → ScipDatabase
|
|
441
|
+
# src/runtime/cli.ts → ScipDatabase:close()
|
|
405
442
|
# src/queries/dead.ts → ScipDatabase:all()
|
|
406
443
|
# src/queries/dead.ts → ScipDatabase:isIgnored()
|
|
407
444
|
```
|
|
@@ -547,14 +584,14 @@ scip-query fan-in -n 10
|
|
|
547
584
|
How many external symbols a file references. Without an argument, shows the top N files by fan-out. High fan-out files are fragile — they depend on many things, so upstream changes are more likely to break them.
|
|
548
585
|
|
|
549
586
|
```bash
|
|
550
|
-
scip-query fan-out cli.ts
|
|
551
|
-
# 23 symbols src/cli.ts
|
|
587
|
+
scip-query fan-out runtime/cli.ts
|
|
588
|
+
# 23 symbols src/runtime/cli.ts
|
|
552
589
|
|
|
553
590
|
scip-query fan-out -n 10
|
|
554
591
|
# symbols file
|
|
555
592
|
# ─────── ────
|
|
556
593
|
# 68 src/queries/index.ts
|
|
557
|
-
# 23 src/cli.ts
|
|
594
|
+
# 23 src/runtime/cli.ts
|
|
558
595
|
```
|
|
559
596
|
|
|
560
597
|
**Options:**
|
|
@@ -574,7 +611,7 @@ scip-query bottlenecks -n 10
|
|
|
574
611
|
# score fan-in fan-out symbol
|
|
575
612
|
# ───── ────── ─────── ──────
|
|
576
613
|
# 136 2 68 src:queries:index
|
|
577
|
-
# 124 31 4 src:db:ScipDatabase
|
|
614
|
+
# 124 31 4 src:storage:db:ScipDatabase
|
|
578
615
|
```
|
|
579
616
|
|
|
580
617
|
**Options:**
|
|
@@ -592,13 +629,13 @@ scip-query bottlenecks -n 10
|
|
|
592
629
|
Measure coupling between two specific files (how many symbols they share), or find the most coupled file pairs across the codebase.
|
|
593
630
|
|
|
594
631
|
```bash
|
|
595
|
-
scip-query coupling db.ts cli.ts
|
|
596
|
-
# db.ts ↔ cli.ts: 4 shared symbols
|
|
632
|
+
scip-query coupling storage/db.ts runtime/cli.ts
|
|
633
|
+
# storage/db.ts ↔ runtime/cli.ts: 4 shared symbols
|
|
597
634
|
|
|
598
635
|
scip-query coupling -n 10
|
|
599
636
|
# shared file1 → file2
|
|
600
637
|
# ────── ─────────────
|
|
601
|
-
# 5 src/db.ts → src/queries/stats.ts
|
|
638
|
+
# 5 src/storage/db.ts → src/queries/stats.ts
|
|
602
639
|
```
|
|
603
640
|
|
|
604
641
|
**Options:**
|
|
@@ -639,11 +676,11 @@ Find the longest transitive dependency chains in the codebase. A chain A → B
|
|
|
639
676
|
```bash
|
|
640
677
|
scip-query deep-chains -n 5 --min-depth 4
|
|
641
678
|
# Chain 1 (depth 5):
|
|
642
|
-
# → src/cli.ts
|
|
679
|
+
# → src/runtime/cli.ts
|
|
643
680
|
# → src/queries/index.ts
|
|
644
681
|
# → src/queries/surface.ts
|
|
645
|
-
# → src/db.ts
|
|
646
|
-
# → src/types.ts
|
|
682
|
+
# → src/storage/db.ts
|
|
683
|
+
# → src/domain/types.ts
|
|
647
684
|
```
|
|
648
685
|
|
|
649
686
|
**Options:**
|
|
@@ -868,16 +905,20 @@ scip-query diff-impact --base main
|
|
|
868
905
|
|
|
869
906
|
#### `drift [module]`
|
|
870
907
|
|
|
871
|
-
Detect
|
|
908
|
+
Detect unused imports, layer violations, and dependency-pattern deviations.
|
|
872
909
|
|
|
873
910
|
```bash
|
|
874
|
-
scip-query drift
|
|
875
|
-
#
|
|
876
|
-
#
|
|
877
|
-
#
|
|
911
|
+
scip-query drift --min-deviation 6
|
|
912
|
+
#
|
|
913
|
+
# src/services/legacy-auth.ts
|
|
914
|
+
# [LAYER] Imports from infra/ (infra/raw-sql.ts) — may cross architectural boundary
|
|
915
|
+
# app/ should not depend on infra/
|
|
878
916
|
```
|
|
879
917
|
|
|
880
|
-
**
|
|
918
|
+
**Options:**
|
|
919
|
+
- `--min-deviation <n>` — Minimum sibling files before reporting unique dependency deviations (default: 5)
|
|
920
|
+
|
|
921
|
+
**Value:** Finds unused imports, layer-policy violations, and files that don't follow their neighbors' dependency conventions. The outliers are either legacy code needing migration or intentional exceptions needing documentation.
|
|
881
922
|
|
|
882
923
|
---
|
|
883
924
|
|
|
@@ -1096,9 +1137,7 @@ Find barrel file re-exports that nobody imports through.
|
|
|
1096
1137
|
|
|
1097
1138
|
```bash
|
|
1098
1139
|
scip-query redundant-reexports
|
|
1099
|
-
#
|
|
1100
|
-
# resolveCacheDir() (from src/config.ts)
|
|
1101
|
-
# barrel: 0 consumer(s) | direct: 0 consumer(s)
|
|
1140
|
+
# No redundant re-exports found.
|
|
1102
1141
|
```
|
|
1103
1142
|
|
|
1104
1143
|
**Options:**
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
+
//# sourceMappingURL=augment-vue-worker.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
WHERE relative_path = ?
|
|
3
|
+
${e.pathExclusionsFor("documents")}
|
|
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
|
|
5
|
+
FROM mentions m
|
|
6
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
7
|
+
JOIN documents consumer_d ON consumer_d.id = c.document_id
|
|
8
|
+
WHERE m.symbol_id = ?
|
|
9
|
+
AND m.role != 1
|
|
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-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
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
m.symbol_id,
|
|
3
|
+
d.relative_path,
|
|
4
|
+
COUNT(*) AS ref_count
|
|
5
|
+
FROM mentions m
|
|
6
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
7
|
+
JOIN documents d ON c.document_id = d.id
|
|
8
|
+
WHERE m.role != 1
|
|
9
|
+
${e.pathExclusionsFor("d")}
|
|
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
|
+
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-4TX5IMMK.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
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
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as m}from"./chunk-MO65UK5V.js";import{a as h}from"./chunk-ZHHMG4UC.js";import{o as g}from"./chunk-QFZE73XF.js";import{readFileSync as f}from"fs";import{extname as b,join as d}from"path";function M(t,e,a={}){let{context:s=0}=a,r=R(e);if(r)return L(t,r.filePath,r.startLine,r.endLine,s);let l=h(t,e);return l?j(t,l,s):null}function R(t){let e=t.match(/^(.+\.\w+):(\d+)-(\d+)$/);return e?{filePath:e[1],startLine:parseInt(e[2],10),endLine:parseInt(e[3],10)}:null}function j(t,e,a){let s=t.get("SELECT language FROM documents WHERE relative_path = ?",e.relativePath),r=d(t.config.projectRoot,e.relativePath),l;try{l=f(r,"utf-8")}catch{return null}let n=l.split(`
|
|
2
|
+
`),c=Math.max(0,e.startLine-a),i=Math.min(n.length-1,e.endLine+a),o=n.slice(c,i+1).join(`
|
|
3
|
+
`);return{symbol:e.symbol,shortName:g(e.symbol),relativePath:e.relativePath,startLine:c,endLine:i,language:s?.language??v(e.relativePath),source:o}}function L(t,e,a,s,r){let l=m(t,e);if(!l)return null;let n=t.get("SELECT relative_path, language FROM documents WHERE relative_path = ?",l);if(!n)return null;let c=d(t.config.projectRoot,n.relative_path),i;try{i=f(c,"utf-8")}catch{return null}let o=i.split(`
|
|
4
|
+
`),u=Math.max(0,a-1-r),p=Math.min(o.length-1,s-1+r),y=o.slice(u,p+1).join(`
|
|
5
|
+
`);return{symbol:`${n.relative_path}:${a}-${s}`,shortName:`${n.relative_path}:${a}-${s}`,relativePath:n.relative_path,startLine:u,endLine:p,language:n.language??v(n.relative_path),source:y}}function v(t){switch(b(t).toLowerCase()){case".ts":case".tsx":case".mts":case".cts":return"typescript";case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".py":case".pyi":return"python";case".rs":return"rust";case".go":return"go";case".java":return"java";case".kt":case".kts":return"kotlin";case".scala":return"scala";case".rb":return"ruby";case".php":return"php";case".cs":return"csharp";case".vb":return"vb";case".dart":return"dart";case".c":case".h":return"c";case".cc":case".cpp":case".cxx":case".hpp":case".hh":case".hxx":return"cpp";case".vue":return"vue";default:return null}}export{M as a};
|
|
6
|
+
//# sourceMappingURL=chunk-7LSCW7NF.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as p,n as d,o as f,q as u}from"./chunk-QFZE73XF.js";var m={0:"UnspecifiedKind",1:"AbstractMethod",2:"Accessor",3:"Array",4:"Assertion",5:"AssociatedType",6:"Attribute",7:"Axiom",8:"Boolean",9:"Class",10:"Constant",11:"Constructor",12:"Contract",13:"DataFamily",14:"DefinitionMacro",15:"Delegate",16:"Enum",17:"EnumMember",18:"Error",19:"Event",20:"Fact",21:"Field",22:"File",23:"Function",24:"Getter",25:"Grammar",26:"Instance",27:"Interface",28:"Key",29:"Lang",30:"Lemma",31:"Library",32:"Macro",33:"Method",34:"MethodAlias",35:"MethodReceiver",36:"MethodSpecification",37:"Message",38:"Modifier",39:"Module",40:"Namespace",41:"Null",42:"Number",43:"Object",44:"Operator",45:"Package",46:"PackageObject",47:"Parameter",48:"ParameterLabel",49:"Pattern",50:"Predicate",51:"Property",52:"Protocol",53:"ProtocolMethod",54:"PureVirtualMethod",55:"Quasiquoter",56:"SelfParameter",57:"Setter",58:"Signature",59:"SingletonClass",60:"SingletonMethod",61:"StaticDataMember",62:"StaticEvent",63:"StaticField",64:"StaticMethod",65:"StaticProperty",66:"StaticVariable",67:"String",68:"Struct",69:"Subscript",70:"Tactic",71:"Theorem",72:"ThisParameter",73:"Trait",74:"TraitMethod",75:"Type",76:"TypeAlias",77:"TypeClass",78:"TypeClassMethod",79:"TypeFamily",80:"TypeParameter",81:"Union",82:"Value",83:"Variable"},c=new Map;for(let[e,i]of Object.entries(m))c.set(i.toLowerCase(),Number(e));function g(e){let i=parseInt(e,10);if(!isNaN(i))return i;let s=e.toLowerCase(),n=c.get(s);if(n!==void 0)return n;for(let[r,o]of c)if(r.includes(s))return o;return null}function N(e,i,s={}){let{scope:n,limit:r=100}=s,o=g(i);return o===null?[]:b(e,n).map(t=>({row:t,resolvedKind:y(t)})).filter(t=>t.resolvedKind===o).slice(0,r).map(({row:t,resolvedKind:l})=>({symbol:t.symbol,shortName:f(t.symbol),kind:l,kindName:m[l]??"Unknown",relativePath:t.relative_path,startLine:t.start_line,endLine:t.end_line}))}function P(e,i={}){let s=new Map;for(let n of b(e,i.scope)){let r=y(n);r===null||r===0||s.set(r,(s.get(r)??0)+1)}return[...s.entries()].sort((n,r)=>r[1]-n[1]||n[0]-r[0]).map(([n,r])=>({kind:n,kindName:m[n]??"Unknown",count:r}))}function b(e,i){return p(e,{scope:i}).map(S)}function S(e){return{symbol:e.symbol,kind:e.kind,documentation:e.documentation,enclosing_symbol:e.enclosingSymbol,relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine}}function y(e){return e.kind!==null&&e.kind!==0?h(e.kind,e.symbol,e.documentation):M(e.symbol,e.documentation,e.enclosing_symbol)}function h(e,i,s){let n=(s??"").toLowerCase();if(u(i)==="type"){if(n.includes("type "))return 76;if(n.includes("interface "))return 27;if(n.includes("struct "))return 68;if(n.includes("trait "))return 73;if(n.includes("class "))return 9}return e}function M(e,i,s){let n=d(e);if("kind"in n)return null;let r=n.descriptors,o=r[r.length-2]??null,a=u(e),t=(i??"").toLowerCase();return a==="type"?t.includes("type ")?76:t.includes("interface ")?27:t.includes("struct ")?68:t.includes("trait ")?73:(t.includes("class "),9):a==="method"?o?.suffix==="type"?33:23:a==="namespace"?39:a!=="term"?null:t.includes("async def ")||t.includes("def ")?23:(s?u(s):o?.suffix??null)==="type"?21:83}export{N as a,P as b};
|
|
2
|
+
//# sourceMappingURL=chunk-7X7FLQC5.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|
+
`).slice(e,i+1).join(`
|
|
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-AV7BOODV.js.map
|
|
@@ -0,0 +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-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
|
+
`);if(r>=e&&r-e<=12)return n.slice(e,r+1).join(`
|
|
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
|
+
`)}return n.slice(e,Math.min(n.length,e+8)).join(`
|
|
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-AXP4H62Q.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
5
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
6
|
+
WHERE d1.relative_path NOT IN (${t})
|
|
7
|
+
AND (
|
|
8
|
+
EXISTS (
|
|
9
|
+
SELECT 1
|
|
10
|
+
FROM defn_enclosing_ranges der
|
|
11
|
+
JOIN documents d2 ON der.document_id = d2.id
|
|
12
|
+
WHERE der.symbol_id = gs.id
|
|
13
|
+
AND d2.relative_path IN (${t})
|
|
14
|
+
)
|
|
15
|
+
OR EXISTS (
|
|
16
|
+
SELECT 1
|
|
17
|
+
FROM mentions def_m
|
|
18
|
+
JOIN chunks def_c ON def_m.chunk_id = def_c.id
|
|
19
|
+
JOIN documents d2 ON def_c.document_id = d2.id
|
|
20
|
+
WHERE def_m.symbol_id = gs.id
|
|
21
|
+
AND def_m.role = 1
|
|
22
|
+
AND d2.relative_path IN (${t})
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
AND m.role != 1
|
|
26
|
+
AND ${e.localSymbolPredicate}
|
|
27
|
+
${e.pathExclusionsFor("d1")}
|
|
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-DLWRLPKO.js.map
|