scip-query 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +14 -7
  2. package/dist/{chunk-FCC3XJTI.js → chunk-26LSAIEP.js} +2 -2
  3. package/dist/{chunk-SG35Y7J2.js → chunk-2HEJQBMS.js} +2 -2
  4. package/dist/chunk-3FG3VLK3.js +65 -0
  5. package/dist/{chunk-DE5ZBHMK.js → chunk-3J463LOK.js} +2 -2
  6. package/dist/{chunk-XVDASCN7.js → chunk-3QJ2NOYG.js} +2 -2
  7. package/dist/{chunk-AJ5PWKD4.js → chunk-3T53QAUS.js} +2 -2
  8. package/dist/chunk-435YC4OF.js +2 -0
  9. package/dist/chunk-4LBOHXT7.js +6 -0
  10. package/dist/chunk-5IM4IQ6N.js +2 -0
  11. package/dist/{chunk-BDBRZPX3.js → chunk-5NRGSXZQ.js} +2 -2
  12. package/dist/chunk-5V76WMMZ.js +5 -0
  13. package/dist/{chunk-HMKJTAZD.js → chunk-5VU2RVKI.js} +2 -2
  14. package/dist/{chunk-NTDA4A2D.js → chunk-5W22HCSF.js} +2 -2
  15. package/dist/{chunk-IBGBI3VU.js → chunk-67UXTIFZ.js} +2 -2
  16. package/dist/{chunk-SDX6MDBL.js → chunk-6ALIV5SZ.js} +2 -2
  17. package/dist/{chunk-K5FQFCSN.js → chunk-6CTMG3IF.js} +2 -2
  18. package/dist/{chunk-BQ3INTYT.js → chunk-6XP3KWHC.js} +2 -2
  19. package/dist/chunk-7DKDFRXQ.js +7 -0
  20. package/dist/{chunk-LX4H4LLG.js → chunk-7NEBSLI3.js} +2 -2
  21. package/dist/chunk-AEMTUHQ7.js +2 -0
  22. package/dist/{chunk-Y7LOQSWY.js → chunk-AVLUWGXG.js} +2 -2
  23. package/dist/chunk-AZQ3ENHU.js +2 -0
  24. package/dist/{chunk-ZXKURFVB.js → chunk-AZTWY4OT.js} +2 -2
  25. package/dist/{chunk-BE6EQIWY.js → chunk-CHW7433E.js} +2 -2
  26. package/dist/chunk-CW5K3KIF.js +12 -0
  27. package/dist/{chunk-ZSRXMNMK.js → chunk-F6F2QUIH.js} +3 -3
  28. package/dist/{chunk-D7KLLMPB.js → chunk-FJV7QT4G.js} +2 -2
  29. package/dist/chunk-FPDWFGBQ.js +19 -0
  30. package/dist/chunk-G2SX5EHW.js +2 -0
  31. package/dist/{chunk-RWE6FHG3.js → chunk-GK6VXKLY.js} +2 -2
  32. package/dist/{chunk-STOGKRJH.js → chunk-HS5LX75F.js} +2 -2
  33. package/dist/{chunk-D7YBWSON.js → chunk-HS65NNKP.js} +2 -2
  34. package/dist/{chunk-DHYIJHXZ.js → chunk-LKCPNPHH.js} +2 -2
  35. package/dist/{chunk-JS2RNIC7.js → chunk-MQ5FKM2F.js} +2 -2
  36. package/dist/{chunk-WTSTDJZ7.js → chunk-NFOSOUH6.js} +2 -2
  37. package/dist/{chunk-4QJ7LVW5.js → chunk-NLWXQMKR.js} +2 -2
  38. package/dist/{chunk-YIPCV7M7.js → chunk-ORD3HEWI.js} +2 -2
  39. package/dist/{chunk-2RLP74AO.js → chunk-OU2D2T4A.js} +2 -2
  40. package/dist/{chunk-NXMYYHDO.js → chunk-P6IUCZA3.js} +2 -2
  41. package/dist/{chunk-2DSS2NGF.js → chunk-PU7P5NPE.js} +2 -2
  42. package/dist/chunk-QSTMORTI.js +2 -0
  43. package/dist/{chunk-QXE6EDY2.js → chunk-RC2PKZSS.js} +2 -2
  44. package/dist/chunk-S65VVU3R.js +2 -0
  45. package/dist/{chunk-IYFZS4PV.js → chunk-SPMLGXCE.js} +5 -5
  46. package/dist/{chunk-GXVB36TG.js → chunk-T26XHATT.js} +2 -2
  47. package/dist/chunk-TWYHFB5K.js +2 -0
  48. package/dist/{chunk-XAZTIDST.js → chunk-TXADWK4I.js} +2 -2
  49. package/dist/chunk-YRUHPGC3.js +7 -0
  50. package/dist/chunk-ZJM2HD2Z.js +2 -0
  51. package/dist/chunk-ZORIMKQO.js +2 -0
  52. package/dist/cli.js +218 -169
  53. package/dist/{db-BSTtBG_H.d.ts → db-DKhNQ75l.d.ts} +15 -1
  54. package/dist/index.d.ts +36 -3
  55. package/dist/index.js +60 -12
  56. package/dist/queries/affected.d.ts +1 -1
  57. package/dist/queries/affected.js +1 -1
  58. package/dist/queries/bottlenecks.d.ts +1 -1
  59. package/dist/queries/bottlenecks.js +1 -1
  60. package/dist/queries/by-kind.d.ts +1 -1
  61. package/dist/queries/by-kind.js +1 -1
  62. package/dist/queries/call-graph.d.ts +1 -1
  63. package/dist/queries/call-graph.js +1 -1
  64. package/dist/queries/change-surface.d.ts +1 -1
  65. package/dist/queries/change-surface.js +1 -1
  66. package/dist/queries/code.d.ts +1 -1
  67. package/dist/queries/code.js +1 -1
  68. package/dist/queries/complexity-hotspots.d.ts +1 -1
  69. package/dist/queries/complexity-hotspots.js +1 -1
  70. package/dist/queries/complexity.d.ts +1 -1
  71. package/dist/queries/complexity.js +1 -1
  72. package/dist/queries/convergence.d.ts +1 -1
  73. package/dist/queries/convergence.js +1 -1
  74. package/dist/queries/coupling.d.ts +1 -1
  75. package/dist/queries/coupling.js +1 -1
  76. package/dist/queries/cycles.d.ts +1 -1
  77. package/dist/queries/cycles.js +1 -1
  78. package/dist/queries/dataflow.d.ts +1 -1
  79. package/dist/queries/dataflow.js +1 -1
  80. package/dist/queries/dead.d.ts +1 -1
  81. package/dist/queries/dead.js +1 -1
  82. package/dist/queries/deep-chains.d.ts +1 -1
  83. package/dist/queries/deep-chains.js +1 -1
  84. package/dist/queries/deps.d.ts +1 -1
  85. package/dist/queries/deps.js +1 -1
  86. package/dist/queries/diff-impact.d.ts +1 -1
  87. package/dist/queries/diff-impact.js +1 -1
  88. package/dist/queries/drift.d.ts +1 -1
  89. package/dist/queries/drift.js +1 -1
  90. package/dist/queries/extract-candidates.d.ts +1 -1
  91. package/dist/queries/extract-candidates.js +1 -1
  92. package/dist/queries/fan.d.ts +1 -1
  93. package/dist/queries/fan.js +1 -1
  94. package/dist/queries/files.d.ts +1 -1
  95. package/dist/queries/health.d.ts +1 -1
  96. package/dist/queries/health.js +1 -1
  97. package/dist/queries/hierarchy.d.ts +1 -1
  98. package/dist/queries/hierarchy.js +1 -1
  99. package/dist/queries/hotspots.d.ts +1 -1
  100. package/dist/queries/hotspots.js +1 -1
  101. package/dist/queries/imports.d.ts +1 -1
  102. package/dist/queries/imports.js +1 -1
  103. package/dist/queries/index.d.ts +1 -1
  104. package/dist/queries/index.js +1 -1
  105. package/dist/queries/isolated.d.ts +1 -1
  106. package/dist/queries/isolated.js +1 -1
  107. package/dist/queries/members.d.ts +1 -1
  108. package/dist/queries/members.js +1 -1
  109. package/dist/queries/methods.d.ts +1 -1
  110. package/dist/queries/methods.js +1 -1
  111. package/dist/queries/outline.d.ts +1 -1
  112. package/dist/queries/outline.js +1 -1
  113. package/dist/queries/passthrough-candidates.d.ts +1 -1
  114. package/dist/queries/passthrough-candidates.js +1 -1
  115. package/dist/queries/redundant-reexports.d.ts +1 -1
  116. package/dist/queries/redundant-reexports.js +1 -1
  117. package/dist/queries/refs.d.ts +1 -1
  118. package/dist/queries/refs.js +1 -1
  119. package/dist/queries/similar-chains.d.ts +1 -1
  120. package/dist/queries/similar-chains.js +1 -1
  121. package/dist/queries/similar-files.d.ts +1 -1
  122. package/dist/queries/similar-files.js +1 -1
  123. package/dist/queries/similar-signatures.d.ts +1 -1
  124. package/dist/queries/similar-signatures.js +1 -1
  125. package/dist/queries/similar.d.ts +1 -1
  126. package/dist/queries/similar.js +1 -1
  127. package/dist/queries/slice.d.ts +1 -1
  128. package/dist/queries/slice.js +1 -1
  129. package/dist/queries/stale-abstractions.d.ts +2 -1
  130. package/dist/queries/stale-abstractions.js +1 -1
  131. package/dist/queries/stats.d.ts +1 -1
  132. package/dist/queries/surface.d.ts +1 -1
  133. package/dist/queries/surface.js +1 -1
  134. package/dist/queries/symbols.d.ts +1 -1
  135. package/dist/queries/symbols.js +1 -1
  136. package/dist/queries/system.d.ts +1 -1
  137. package/dist/queries/system.js +1 -1
  138. package/dist/queries/trace.d.ts +1 -1
  139. package/dist/queries/trace.js +1 -1
  140. package/dist/queries/wrapper-candidates.d.ts +1 -1
  141. package/dist/queries/wrapper-candidates.js +1 -1
  142. package/dist/reindex-worker.js +63 -5
  143. package/package.json +15 -16
  144. package/skills/concrete-plan/SKILL.md +51 -25
  145. package/skills/scip-debloat/SKILL.md +3 -6
  146. package/skills/scip-language-playbook/SKILL.md +2 -0
  147. package/dist/chunk-5IADAU5B.js +0 -7
  148. package/dist/chunk-7754WFFV.js +0 -18
  149. package/dist/chunk-7VOF4ZG6.js +0 -2
  150. package/dist/chunk-7Z4COVMC.js +0 -2
  151. package/dist/chunk-EEF3YEHW.js +0 -2
  152. package/dist/chunk-F2LLHRRZ.js +0 -2
  153. package/dist/chunk-GNXRLK5G.js +0 -2
  154. package/dist/chunk-JH3A7HTU.js +0 -2
  155. package/dist/chunk-K6GBKEQE.js +0 -6
  156. package/dist/chunk-KO7YJRWP.js +0 -12
  157. package/dist/chunk-PZ6ESKRH.js +0 -7
  158. package/dist/chunk-RJ7SPBJ5.js +0 -5
  159. package/dist/chunk-TINPMWJK.js +0 -2
  160. package/dist/chunk-UJB62HV3.js +0 -2
  161. package/dist/chunk-VEUMRDHW.js +0 -2
  162. package/dist/chunk-WCDXJGYT.js +0 -65
  163. package/dist/chunk-Y7H6D2EV.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Language-agnostic code intelligence CLI powered by SCIP indexes",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -62,7 +62,7 @@
62
62
  "dependencies": {
63
63
  "@bufbuild/protobuf": "^2.11.0",
64
64
  "@c4312/scip": "^0.1.0",
65
- "better-sqlite3": "^11.7.0",
65
+ "better-sqlite3": "^12.9.0",
66
66
  "commander": "^13.1.0",
67
67
  "ignore": "^7.0.3"
68
68
  },
@@ -70,20 +70,19 @@
70
70
  "optionalDependencies": {
71
71
  "@sourcegraph/scip-typescript": "^0.4.0",
72
72
  "scip-python-plus": "^0.7.4",
73
- "tree-sitter": "^0.22.4",
74
- "tree-sitter-c": "^0.21.4",
75
- "tree-sitter-c-sharp": "^0.21.3",
76
- "tree-sitter-cpp": "^0.22.3",
77
- "tree-sitter-java": "^0.21.0",
78
- "tree-sitter-javascript": "^0.23.1",
79
- "tree-sitter-kotlin": "^0.3.8",
80
- "tree-sitter-php": "^0.23.11",
81
- "tree-sitter-python": "^0.23.6",
82
- "tree-sitter-ruby": "^0.23.1",
83
- "tree-sitter-rust": "^0.23.3",
84
- "tree-sitter-scala": "^0.24.0",
85
- "tree-sitter-typescript": "^0.23.2",
86
- "tree-sitter-vb-dotnet": "^0.1.9"
73
+ "tree-sitter": "0.21.1",
74
+ "tree-sitter-c": "0.23.2",
75
+ "tree-sitter-c-sharp": "0.23.1",
76
+ "tree-sitter-cpp": "0.23.4",
77
+ "tree-sitter-java": "0.23.5",
78
+ "tree-sitter-javascript": "0.23.1",
79
+ "tree-sitter-kotlin": "0.3.8",
80
+ "tree-sitter-php": "0.23.12",
81
+ "tree-sitter-python": "0.23.4",
82
+ "tree-sitter-ruby": "0.23.1",
83
+ "tree-sitter-rust": "0.23.1",
84
+ "tree-sitter-scala": "0.24.0",
85
+ "tree-sitter-typescript": "0.23.2"
87
86
  },
88
87
  "devDependencies": {
89
88
  "@eslint/js": "^10.0.1",
@@ -67,7 +67,7 @@ This skill deliberately excludes `Grep` and `Read` from its allowed tools. This
67
67
  - Using `Read` via a subagent to browse files for discovery. Subagents must also use scip-query.
68
68
  - Spawning Explore agents that fall back to grep and file reads. If a subagent's output does not cite scip-query commands, reject its findings and re-run.
69
69
 
70
- **Instead, use scip-query (48 commands — full reference at `/Users/aydansalois/Documents/GitHub/scip-query/README.md`):**
70
+ **Instead, use scip-query (full reference at `/Users/aydansalois/Documents/GitHub/scip-query/README.md`):**
71
71
 
72
72
  | You want to... | Use this |
73
73
  |---|---|
@@ -107,7 +107,7 @@ If none of these can answer your question, say so explicitly in the plan rather
107
107
 
108
108
  ### Full Documentation
109
109
 
110
- - **All 48 commands with options and examples:** `/Users/aydansalois/Documents/GitHub/scip-query/README.md`
110
+ - **Every command with options and examples:** `/Users/aydansalois/Documents/GitHub/scip-query/README.md`
111
111
  - **Goal-oriented agent workflows:** `/Users/aydansalois/Documents/GitHub/scip-query/docs/AGENT_GUIDE.md`
112
112
 
113
113
  ---
@@ -184,34 +184,58 @@ What does the user experience during and after this change? Features that disapp
184
184
 
185
185
  **Key question**: If a real user walked through this flow, would anything surprise, confuse, or frustrate them?
186
186
 
187
- ### 11. Match the existing system
187
+ ### 11. Reuse over re-implement; match what already exists
188
188
 
189
- Before designing any new code path, find 2-3 existing examples of the same problem class in the codebase. How does it already handle errors in this layer? What utilities does it already use? What's the naming convention? What abstraction level do similar modules operate at? Your implementation should be indistinguishable from the surrounding code — same patterns, same utilities, same conventions, same libraries. If you need to diverge, justify why in the plan. Two patterns for the same thing is worse than either pattern alone.
189
+ Two implementations of the same logic is worse than either alone — they drift, diverge, and slowly contradict each other until nobody knows which is canonical. Before designing any new code path, find the existing implementations of the same problem class and reuse them. The codebase already has utilities, error-handling patterns, naming conventions, and abstractions for this use them. If you genuinely need a new pattern, justify why in the plan with a citation to what existed and why it didn't fit. Your implementation should be indistinguishable from the surrounding code — same patterns, same utilities, same conventions, same libraries.
190
190
 
191
- **Key question**: Does every new code path in the plan follow the conventions already established by the codebase, and can you point to the existing examples it's matching?
192
- **Tools**: `scip-query similar <symbol>` to find functions with overlapping callee sets. `scip-query surface` to see what utilities a module already uses. `scip-query deps` to see what libraries are already adopted. `scip-query code` to read the canonical implementation.
191
+ This principle backstops the Gate C **Reuse Audit** by stress-test time, every new symbol in the plan should already be tied to a reuse target or a written justification. Use this lens to catch ones that slipped through.
192
+
193
+ **Key question**: For every new function, type, or module in the plan, does an existing one already do this — or 80% of this? If you'd be writing logic that's *similar-but-not-identical* to existing code, you are creating future drift.
194
+ **Tools**: `scip-query similar-chains` (parallel end-to-end flows). `scip-query similar-files` (structurally similar modules). `scip-query similar <symbol>` (overlapping callee sets). `scip-query similar-signatures` (same-shape functions). `scip-query convergence <a> <b>` (merge prescription for near-duplicates). `scip-query surface <module>` (what's already exposed). `scip-query deps <file>` (what libraries are already adopted). `scip-query code <symbol>` (read the canonical example).
193
195
 
194
196
  ---
195
197
 
196
198
  ## Workflow
197
199
 
198
- ### 1. Discover
200
+ ### 1. Discover — three gates before you design
201
+
202
+ You may not write a single design step until you have produced written answers to all three gates below. Each gate becomes a section in the final plan. A plan that skips any gate is rejected — it means you don't understand the problem, the system, or what already exists.
203
+
204
+ #### Gate A — Restate the goal
205
+
206
+ What is the user actually trying to accomplish? Not the literal request — the underlying job. State it in your own words, then state what "done" looks like for the user (not for the code). If the goal is ambiguous, stop and ask the user before designing. A correct plan for the wrong goal is worse than no plan.
207
+
208
+ #### Gate B — Explain the current end-to-end flow
209
+
210
+ Walk the affected slice of the system from entry point to side effect, citing scip-query at every hop. Use:
211
+
212
+ - `scip-query system <module>` — full module map of the area
213
+ - `scip-query call-graph <symbol>` — callers and callees of every entry point you'll touch
214
+ - `scip-query trace <symbol>` — definition + signature + every reference
215
+ - `scip-query dataflow <symbol>` — what feeds in, where it ends up
216
+ - `scip-query change-surface <file>` — pre-change risk briefing on each file you'll modify
217
+ - `scip-query affected <symbol>` — full transitive blast radius
218
+
219
+ If you can't explain how the code works today, you have not earned the right to change it. Surface the non-obvious invariants — what does this code handle that you'd never guess from its shape? What production failures shaped it? What edge cases does the current implementation already cover?
220
+
221
+ #### Gate C — Reuse audit (search before you write)
222
+
223
+ For every new function, type, helper, or module you are about to propose, verify the logic doesn't already exist somewhere in the codebase. **Reuse > extend > write-new.** Two implementations of the same logic is worse than either alone — they drift, diverge, and slowly contradict each other.
199
224
 
200
- Start from the user's request. Use scip-query to map the system around the change:
225
+ Run, in roughly broad-to-narrow order:
201
226
 
202
- - `scip-query system <module>` for the full module map.
203
- - `scip-query call-graph <symbol>` for callers and callees.
204
- - `scip-query rdeps` and `scip-query surface` to find all consumers.
205
- - `scip-query affected <symbol>` for the full transitive blast radius.
206
- - `scip-query change-surface <file>` for a pre-change risk briefing on each file you'll modify.
227
+ - `scip-query similar-chains` does an equivalent end-to-end flow already exist? (the most powerful reuse-finder — catches architectural duplication that function-level checks miss)
228
+ - `scip-query similar-files <closest-existing-file>` does a structurally similar module already exist?
229
+ - `scip-query similar <closest-existing-symbol>` — does a function already do most of this? (TF-IDF weighted cosine on callee fingerprints)
230
+ - `scip-query similar-signatures` does a function with this parameter+return shape already exist?
231
+ - `scip-query surface <module>` what utilities does the area you're touching already expose?
207
232
 
208
- Then find the existing conventions before designing anything new:
233
+ Once a candidate surfaces, confirm fit with:
209
234
 
210
- - `scip-query similar <symbol>` to find functions with overlapping patterns you can reuse.
211
- - `scip-query deps` to see what libraries and utilities the surrounding code already uses.
212
- - `scip-query code <symbol>` to read the canonical examples.
235
+ - `scip-query code <candidate>` read it
236
+ - `scip-query convergence <yours> <candidate>` merge prescription if it's a near-duplicate
213
237
 
214
- Write a clear problem statement: what needs to change, why, and what the target state looks like. Include a **Conventions** section listing the existing patterns the implementation must follow, with source citations.
238
+ The plan must include a **Reuse Audit** subsection. For every new symbol you're proposing, list either (a) the existing function/utility you'll reuse or extend (with scip-query citation), or (b) the specific reason existing code doesn't fit and a new symbol is justified. "I didn't find anything" is not an acceptable answer — name the queries you ran.
215
239
 
216
240
  ### 2. Design
217
241
 
@@ -255,7 +279,7 @@ When spawning any subagent for this planning process, **include the following bl
255
279
 
256
280
  You have the `scip-query` CLI for compiler-resolved code intelligence. Use it for ALL code references — do not use grep, rg, Read, or cat.
257
281
 
258
- ### scip-query commands (48 total)
282
+ ### scip-query commands
259
283
 
260
284
  Navigation:
261
285
  - `scip-query code <symbol>` — read source code (bounded to definition range)
@@ -310,9 +334,11 @@ Agent workflows guide: /Users/aydansalois/Documents/GitHub/scip-query/docs/AGENT
310
334
  The plan is a single markdown file with:
311
335
 
312
336
  1. Title and date
313
- 2. Problem statement (what, why, target state)
314
- 3. Design phases (numbered checklists with Source fields)
315
- 4. Stress-test findings (inline with the relevant phase or as addenda)
316
- 5. Execution order (dependency graph between phases)
317
- 6. Ship order (recommended deployment sequence, one-way doors flagged)
318
- 7. Summary (files modified/created/deleted, net code delta)
337
+ 2. **Goal** (Gate A — what the user is actually trying to accomplish, what "done" looks like for them)
338
+ 3. **Current state** (Gate B — end-to-end flow today with scip-query citations, plus the non-obvious invariants the current code already handles)
339
+ 4. **Reuse audit** (Gate C — for each new symbol proposed, the reuse target or the justification for writing new, with the queries that were run)
340
+ 5. Design phases (numbered checklists with Source fields)
341
+ 6. Stress-test findings (inline with the relevant phase or as addenda)
342
+ 7. Execution order (dependency graph between phases)
343
+ 8. Ship order (recommended deployment sequence, one-way doors flagged)
344
+ 9. Summary (files modified/created/deleted, net code delta)
@@ -73,7 +73,7 @@ scip-query code 'src/modules/chat/chat.service.ts:100-200'
73
73
 
74
74
  ---
75
75
 
76
- ## The 10 Angles of Bloat
76
+ ## The 12 Angles of Bloat
77
77
 
78
78
  Run every one of these. Each catches a different class of problem. Skip none.
79
79
 
@@ -108,7 +108,7 @@ Stricter than dead code — these symbols reference nothing AND are referenced b
108
108
  scip-query similar --min-similarity 0.5 --min-callees 3
109
109
  ```
110
110
 
111
- Functions that call the same set of symbols. High Jaccard similarity = doing the same work.
111
+ Functions that call the same set of symbols. Uses TF-IDF weighted cosine similarity over the callee set, so rare shared callees score higher than ubiquitous infrastructure ones — a high score means the pair shares meaningful work, not just the same `db` and `logger`.
112
112
 
113
113
  For each high-similarity pair, get the consolidation prescription:
114
114
 
@@ -263,7 +263,6 @@ scip-query deep-chains --min-depth 5 # Excessively deep dependency chains
263
263
  scip-query bottlenecks -n 10 # Coupling pressure points
264
264
  scip-query complexity-hotspots -n 10 # Riskiest symbols
265
265
  scip-query hotspots -n 10 # Most-referenced symbols
266
- scip-query doc-coverage --min-loc 5 # Documentation coverage
267
266
  ```
268
267
 
269
268
  ---
@@ -281,7 +280,7 @@ Read the health score, the findings breakdown, and the prioritized action list.
281
280
 
282
281
  ### Phase 2: Deep Scan (10-15 minutes)
283
282
 
284
- Run all 10 angles plus the structural assessment. For each:
283
+ Run all 12 angles plus the structural assessment. For each:
285
284
  1. Run the command
286
285
  2. Record the count and top findings
287
286
  3. For actionable findings, drill deeper (e.g., `convergence` for similar pairs)
@@ -349,7 +348,6 @@ The report is a markdown file with:
349
348
  - Max dependency chain depth: N
350
349
  - Coupling bottlenecks: [top 5]
351
350
  - Complexity hotspots: [top 5]
352
- - Doc coverage: N%
353
351
  ```
354
352
 
355
353
  Every finding includes the scip-query command that produced it.
@@ -402,7 +400,6 @@ Do NOT use grep, rg, or Read. Use only scip-query commands.
402
400
  | Coupling pressure | `scip-query bottlenecks -n 10` |
403
401
  | Complexity hotspots | `scip-query complexity-hotspots -n 10` |
404
402
  | Most-referenced | `scip-query hotspots -n 10` |
405
- | Doc coverage | `scip-query doc-coverage` |
406
403
  | Redundant re-exports | `scip-query redundant-reexports` |
407
404
  | Similar signatures | `scip-query similar-signatures --min-loc 5` |
408
405
  | Read source | `scip-query code <symbol>` |
@@ -62,6 +62,8 @@ scip-query redundant-reexports
62
62
 
63
63
  Why this row is strong: TypeScript has the broadest verified command surface in the current suite, especially for imports, members, call flow, change risk, and DRY analysis.
64
64
 
65
+ Vue note: `.vue` single-file components are handled by the same path. scip-query extracts the `<script>` (or `<script setup>`) block and parses it as TS/JS, so the TypeScript commands above also work on the Vue file's `<script>` symbols. Identifiers used only in `<template>`/`<style>` are tracked through a separate identifier scan so they don't show up as unused imports.
66
+
65
67
  ### Python
66
68
 
67
69
  Use first:
@@ -1,7 +0,0 @@
1
- import{c as k}from"./chunk-VEUMRDHW.js";import{c as _,d as N,j as P}from"./chunk-WCDXJGYT.js";import{e as C,p as D,r as M,t as v}from"./chunk-IYFZS4PV.js";import{b as F,c as L,f as I}from"./chunk-TINPMWJK.js";import{basename as u,extname as d}from"path";function V(e,n){let{scope:i,maxLoc:t=15,limit:s=30}=n??{},o=J(N(e,i)),l=T(e,i,t),c=j(P(e,l),k(e,l)),g=[];for(let r of l){if(C(e,r.relativePath,r.startLine))continue;let p=u(r.relativePath,d(r.relativePath)),h=[...c.get(r.symbolId)??[]].filter(m=>m!==r.relativePath).filter(m=>u(m,d(m))!==p);if(h.length!==1)continue;let f=h[0],y=e.get(`SELECT c.start_line, c.end_line
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents d ON c.document_id = d.id
5
- WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
6
- LIMIT 1`,r.symbolId,f);if(!y)continue;let R=D(e,f),w=A(e,f,r.symbol,y.start_line,y.end_line),a=v(R,w),b,E=a?.symbol??"",O=a?.isFunctionLike?F(a.symbol):u(f);if(a?.isFunctionLike&&a.symbolId!==r.symbolId){let m=[...c.get(a.symbolId)??[]].filter(W=>W!==a.relativePath);b=m.length>0?m.length:x(o,f)}else b=x(o,f);b<=3||g.push({symbol:r.symbol,shortName:F(r.symbol),file:r.relativePath,startLine:r.startLine,endLine:r.endLine,loc:S(r),singleCaller:E,singleCallerShort:O,callerFanIn:b})}return g.sort((r,p)=>p.callerFanIn-r.callerFanIn||p.loc-r.loc),g.slice(0,s)}function S(e){return e.endLine-e.startLine+1}function T(e,n,i){return M(e,n).filter(t=>!e.isIgnored(t.relativePath)).filter(t=>I(t.symbol)).filter(t=>S(t)<=i&&S(t)>=2)}function A(e,n,i,t,s){let o=L(i);if(!o)return t;let l=_(e,n).get(o);if(!l||l.length===0)return t;for(let c of l)if(c>=t&&c<=s)return c;return t}function j(...e){let n=new Map;for(let i of e)for(let[t,s]of i){let o=n.get(t);o||(o=new Set,n.set(t,o));for(let l of s)o.add(l)}return n}function J(e){let n=new Map;for(let[i,t]of e){n.has(i)||n.set(i,n.get(i)??0);for(let s of t)n.set(s,(n.get(s)??0)+1)}return n}function x(e,n){let i=e.get(n)??0;if(i>0)return i;let t=u(n,d(n)),s=0;for(let[o,l]of e)o!==n&&u(o,d(o))===t&&l>s&&(s=l);return s}export{V as a};
7
- //# sourceMappingURL=chunk-5IADAU5B.js.map
@@ -1,18 +0,0 @@
1
- import{d as y}from"./chunk-WCDXJGYT.js";import{e as h}from"./chunk-BQ3INTYT.js";import m from"path";function E(t,r){let{scope:i}=r??{},f=y(t,i),n=_(t,i),o=[];for(let[e,c]of f){if(d(e))continue;let u=n.get(e)??new Set;for(let s of c)if(!d(s)&&!u.has(s)){if(k(s)||b(t,e,s))continue;o.push({file:e,kind:"unused-import",description:`Depends on ${s} but references none of its symbols`,dep:s})}}let p=S(f);for(let[e,c]of f){if(d(e))continue;let u=g(e);for(let s of c){if(d(s))continue;let l=g(s);if(u===l)continue;p.get(`${u}->${l}`)==="violation"&&o.push({file:e,kind:"layer-violation",description:`Imports from ${l}/ (${s}) \u2014 may cross architectural boundary`,dep:s,detail:`${u}/ should not depend on ${l}/`})}}let a=new Map;for(let e of f.keys()){let c=m.dirname(e);a.has(c)||a.set(c,[]),a.get(c).push(e)}for(let[e,c]of a){if(c.length<3)continue;let u=new Map;for(let s of c)if(!d(s))for(let l of f.get(s)??[])d(l)||u.set(l,(u.get(l)??0)+1);for(let s of c)if(!d(s)){for(let l of f.get(s)??[])if(!d(l)&&(u.get(l)??0)===1){if(m.dirname(l)===e)continue;o.push({file:s,kind:"pattern-deviation",description:`Only file in ${e}/ that depends on ${l}`,dep:l})}}}return{results:o,unusedImports:o.filter(e=>e.kind==="unused-import").length,layerViolations:o.filter(e=>e.kind==="layer-violation").length,patternDeviations:o.filter(e=>e.kind==="pattern-deviation").length}}function _(t,r){let i=r?`AND d1.relative_path LIKE '%${r}%'`:"",f=t.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
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
- JOIN (
7
- SELECT m2.symbol_id, c2.document_id
8
- FROM mentions m2
9
- JOIN chunks c2 ON m2.chunk_id = c2.id
10
- WHERE m2.role = 1
11
- GROUP BY m2.symbol_id
12
- ) sym_def ON sym_def.symbol_id = gs.id
13
- JOIN documents d2 ON sym_def.document_id = d2.id
14
- WHERE d1.id != d2.id
15
- AND m.role != 1
16
- ${t.pathExclusionsFor("d1","d2")}
17
- ${i}`),n=new Map;for(let o of f)t.isIgnored(o.from_file)||t.isIgnored(o.to_file)||(n.has(o.from_file)||n.set(o.from_file,new Set),n.get(o.from_file).add(o.to_file));return n}function S(t){let r=new Map,i=new Set;for(let[n,o]of t){if(d(n))continue;let p=g(n);i.add(p);for(let a of o){if(d(a))continue;let e=g(a);if(p===e)continue;i.add(e);let c=`${p}->${e}`;r.set(c,(r.get(c)??0)+1)}}let f=new Map;for(let[n,o]of r)f.set(n,o<=2?"violation":"ok");return f}function g(t){let i=t.replace(/\\/g,"/").split("/").filter(Boolean);return i.length<=1?"(root)":i.length>=3&&["src","lib","app","server","client"].includes(i[0])?`${i[0]}/${i[1]}`:i[0]}function k(t){return t.includes("types")||t.endsWith(".d.ts")}function b(t,r,i){let f=h(t,r).filter(n=>n.sourcePath===i);return f.length===0?!1:f.every(n=>n.kind==="side-effect"||n.kind==="namespace"&&n.usedMembers.length===0&&!n.used)}function d(t){return $(m.basename(t))||v(t)}function $(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")}function v(t){let r=t.replace(/\\/g,"/"),i=m.basename(r);return r.includes("/__tests__/")||r.includes("/tests/")||r.includes("/test/")||/\.(test|spec)\.[A-Za-z0-9]+$/.test(i)||/_(test|spec)\.[A-Za-z0-9]+$/.test(i)||/^test[_-]/.test(i)||/^test\./.test(i)}export{E as a};
18
- //# sourceMappingURL=chunk-7754WFFV.js.map
@@ -1,2 +0,0 @@
1
- import{h as L}from"./chunk-WCDXJGYT.js";import{e as g,f as b,h as C,r as S}from"./chunk-IYFZS4PV.js";import{b as y,f as d}from"./chunk-TINPMWJK.js";function x(o,s,a,i){let r=b(s);if(!r)return!0;let t=C(o,s);if(!t)return!0;let l=_.get(t);return l||(l=w(t,r),_.set(t,l)),l.get(`${a}:${i}`)??!0}var _=new WeakMap;function w(o,s){let a=s==="rust"?new Set(["function_item","function_signature_item"]):s==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),i=new Map,r=t=>{a.has(t.type)&&i.set(`${t.startPosition.row}:${t.endPosition.row}`,P(t,s));for(let l of t.children)r(l)};return r(o.rootNode),i}function P(o,s){let a=o.namedChildren.find(e=>e.type==="block"||e.type==="statement_block");if(!a)return!1;let i=a.namedChildren.filter(e=>e.type!=="comment"&&e.type!=="line_comment"&&e.type!=="block_comment");if(i.length!==1)return!1;let r=i[0],t=null;if(r.type==="return_statement"||r.type==="expression_statement"?t=r.namedChild(0)??null:s==="rust"&&(r.type==="call_expression"||r.type==="macro_invocation")&&(t=r),!t)return!1;let l=s==="python"?"call":"call_expression";if(t.type!==l)return!1;let u=t.namedChildren.find(e=>e.type==="arguments"||e.type==="argument_list");if(!u)return!1;let n=u.namedChildren.filter(e=>e.type!=="comment"),f=o.namedChildren.find(e=>e.type==="parameters"||e.type==="formal_parameters");if(!f)return!1;let p=[];for(let e of f.namedChildren)if(e.type==="identifier")p.push(e.text);else{let m=e.namedChildren.find(c=>c.type==="identifier");m&&p.push(m.text)}if(n.length!==p.length)return!1;for(let e=0;e<p.length;e+=1){let m=n[e];if(m.type!=="identifier"||m.text!==p[e])return!1}return!0}function j(o,s){let{scope:a,maxLoc:i=15,limit:r=30}=s??{},t=T(o,a,i),l=L(o,t),u=[];for(let n of t){if(g(o,n.relativePath,n.startLine))continue;let f=l.get(n.symbolId)??[],p=f.some(c=>d(c.symbol))?f.filter(c=>d(c.symbol)):f,e=new Map;for(let c of p)e.has(c.symbol)||e.set(c.symbol,c);if(e.size!==1||!x(o,n.relativePath,n.startLine,n.endLine))continue;let[,m]=[...e.entries()][0];u.push({symbol:n.symbol,shortName:y(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:h(n),forwardsTo:m.symbol,forwardsToShort:y(m.symbol),forwardsToFile:m.file})}return u.sort((n,f)=>n.loc-f.loc||n.file.localeCompare(f.file)),u.slice(0,r)}function T(o,s,a){return S(o,s).filter(i=>!o.isIgnored(i.relativePath)).filter(i=>d(i.symbol)).filter(i=>h(i)>=3&&h(i)<=a)}function h(o){return o.endLine-o.startLine+1}export{j as a};
2
- //# sourceMappingURL=chunk-7VOF4ZG6.js.map
@@ -1,2 +0,0 @@
1
- import{d as i}from"./chunk-GNXRLK5G.js";import{c as n}from"./chunk-VEUMRDHW.js";import{h as o,j as m}from"./chunk-WCDXJGYT.js";import{r}from"./chunk-IYFZS4PV.js";import{b as l}from"./chunk-TINPMWJK.js";function F(t,c={}){let{scope:p,minLoc:y=3}=c,a=r(t,p).filter(e=>!t.isIgnored(e.relativePath)).filter(e=>!i(t,e.relativePath)).filter(e=>e.isFunctionLike).filter(e=>e.endLine-e.startLine+1>=y),b=m(t,a),L=n(t,a),u=new Set([...b.keys(),...L.keys()]),d=new Map(a.map(e=>[e.symbolId,e.symbol])),f=o(t,a,{additive:!0}),S=new Set([...f.entries()].filter(([e,s])=>{let h=d.get(e);return s.some(C=>C.symbol!==h)}).map(([e])=>e));return a.filter(e=>!u.has(e.symbolId)).filter(e=>!S.has(e.symbolId)).sort((e,s)=>s.endLine-s.startLine-(e.endLine-e.startLine)||e.relativePath.localeCompare(s.relativePath)||e.startLine-s.startLine).map(e=>({symbol:e.symbol,shortName:l(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1}))}export{F as a};
2
- //# sourceMappingURL=chunk-7Z4COVMC.js.map
@@ -1,2 +0,0 @@
1
- import{a as h}from"./chunk-GNXRLK5G.js";import{d as x}from"./chunk-WCDXJGYT.js";function R(s,n={}){let{scope:i,maxDepth:C=10}=n,y=x(s,i),a=[],l=new Set,f=new Set,c=[];function m(e,t){if(t>C)return;if(f.has(e)){let o=c.indexOf(e);if(o!==-1){let r=c.slice(o).concat(e),u=r.indexOf(r.reduce((b,S)=>b<S?b:S)),p=[...r.slice(u,-1),...r.slice(0,u),r[u]],k=p.join(" -> ");d.has(k)||(d.add(k),a.push({path:p,kind:D(p)}))}return}if(l.has(e))return;l.add(e),f.add(e),c.push(e);let g=y.get(e);if(g)for(let o of g)m(o,t+1);c.pop(),f.delete(e)}let d=new Set;for(let e of y.keys())l.has(e)||m(e,0);return a.sort((e,t)=>e.kind!==t.kind?e.kind==="real"?-1:1:e.path.length-t.path.length),a}function D(s){if(s.length!==3)return"real";let[n,i]=s;return!n||!i?"real":h(n)||h(i)?"module-hierarchy":"real"}export{R as a};
2
- //# sourceMappingURL=chunk-EEF3YEHW.js.map
@@ -1,2 +0,0 @@
1
- import{h as v}from"./chunk-WCDXJGYT.js";import{e as L,r as w}from"./chunk-IYFZS4PV.js";import{b,f as C}from"./chunk-TINPMWJK.js";function q(i,k={}){let{scope:x,minLoc:z=10,minCallees:D=6,limit:E=20}=k,y=w(i,x).filter(t=>!i.isIgnored(t.relativePath)).filter(t=>h(t)>=z&&C(t.symbol)).filter(t=>!(t.relativePath.split("/").pop()??"").includes("types")).filter(t=>!L(i,t.relativePath,t.startLine)).sort((t,r)=>h(r)-h(t)),F=v(i,y),d=[];for(let t of y){let r=F.get(t.symbolId)??[],c=new Set(r.map(e=>e.symbol));if(c.size<D)continue;let l=new Map;for(let e of c)l.set(e,new Set);let a=new Map;for(let e of r)a.has(e.chunkId)||a.set(e.chunkId,new Set),a.get(e.chunkId).add(e.symbol);for(let e of a.values()){let s=[...e];for(let o=0;o<s.length;o++)for(let n=o+1;n<s.length;n++)l.get(s[o]).add(s[n]),l.get(s[n]).add(s[o])}let f=new Set,m=[];for(let e of c){if(f.has(e))continue;let s=new Set,o=[e];for(;o.length>0;){let n=o.pop();if(!f.has(n)){f.add(n),s.add(n);for(let u of l.get(n)??[])f.has(u)||o.push(u)}}m.push(s)}if(m.length<2)continue;let S=m.filter(e=>e.size>=3).map(e=>{let s=new Set;for(let p of m)if(p!==e)for(let g of p)s.add(g);let o=0;for(let p of e)for(let g of l.get(p)??[])s.has(g)&&o++;let n=e.size*s.size,u=n>0?1-o/n:1;return{callees:[...e].map(b),isolation:u}}).filter(e=>e.isolation>.5).sort((e,s)=>s.isolation-e.isolation);S.length>0&&d.push({symbol:t.symbol,shortName:b(t.symbol),relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:h(t),totalCallees:c.size,clusters:S})}return d.sort((t,r)=>r.clusters.length-t.clusters.length||r.loc-t.loc),d.slice(0,E)}function h(i){return i.endLine-i.startLine+1}export{q as a};
2
- //# sourceMappingURL=chunk-F2LLHRRZ.js.map
@@ -1,2 +0,0 @@
1
- import{a as c}from"./chunk-ZSRXMNMK.js";import{d as f}from"./chunk-WCDXJGYT.js";import{b as a}from"./chunk-IYFZS4PV.js";function i(t){let r=_(t);return b(r)?"test":x(r)?"worker":S(r)?"entry":P(r)?"barrel":"source"}function l(t){return i(t)==="barrel"}function p(t){return g.get(t,()=>{let r=f(t),e=c(t).filter(s=>{let n=i(s);return n==="entry"||n==="worker"}),u=new Set,o=new Set;for(;e.length>0;){let s=e.shift();if(!u.has(s)){u.add(s),i(s)==="barrel"&&o.add(s);for(let n of r.get(s)??[])u.has(n)||e.push(n)}}return o})}var g=a("live-barrels");function h(t,r){return p(t).has(_(r))}function $(t){let r=p(t);return c(t).filter(e=>l(e)&&!r.has(e))}function k(t,r){let e=i(r);return e==="entry"||e==="worker"||h(t,r)}var v=["%/__tests__/%","%.test.%","%.spec.%","%/test/%","%/tests/%","%_test.%","%_spec.%","%/test_%.%","%/spec_%.%"],w=["%/test-utils/%"];function b(t){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(t)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(t)||/(?:^|\/)spec_[^/]+$/i.test(t)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(t)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(t)||/(?:^|\/)__tests__\//i.test(t)||/(?:^|\/)test\//i.test(t)||/(?:^|\/)tests\//i.test(t)||/(?:^|\/)__fixtures__\//i.test(t)||/(?:^|\/)__mocks__\//i.test(t)||/(?:^|\/)test-support\//i.test(t)||/(?:^|\/)test-utils\//i.test(t)||/(?:^|\/)testing\//i.test(t))}function x(t){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(t)}function S(t){let r=t.split("/"),e=r[r.length-1]??t;return e==="cli.ts"||e==="cli.js"||e==="postinstall.ts"||e==="postinstall.js"||e==="main.ts"||e==="main.js"||e==="main.rs"||e==="main.go"||e==="main.py"||e==="build.rs"||e==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(t)||/(?:^|\/)examples\/[^/]+\.rs$/.test(t)||/(?:^|\/)tests\/[^/]+\.rs$/.test(t)||/(?:^|\/)benches\/[^/]+\.rs$/.test(t)?!0:e==="index.ts"||e==="index.js"?r.length<=2:!1}function P(t){return t==="index.ts"||t==="index.js"||t.endsWith("/index.ts")||t.endsWith("/index.js")||t.endsWith("/mod.rs")||t.endsWith("/__init__.py")}function _(t){return t.replace(/\\/g,"/")}export{l as a,h as b,$ as c,k as d,v as e,w as f};
2
- //# sourceMappingURL=chunk-GNXRLK5G.js.map
@@ -1,2 +0,0 @@
1
- import{b as e}from"./chunk-WTSTDJZ7.js";import{s as o}from"./chunk-IYFZS4PV.js";function l(t,r){let s=e(t,r);return o(t,s).map(({relativePath:a,...m})=>m)}export{l as a};
2
- //# sourceMappingURL=chunk-JH3A7HTU.js.map
@@ -1,6 +0,0 @@
1
- import{a as w,b as h,d as A,e as j}from"./chunk-LORWXBOO.js";import{e as $,h as B}from"./chunk-WCDXJGYT.js";import{a as z}from"./chunk-LX4H4LLG.js";import{d as v,e as M,l as x,q as D,r as L}from"./chunk-IYFZS4PV.js";import{b,c as q,f as F}from"./chunk-TINPMWJK.js";function se(t,e,r={}){let{minSimilarity:s=.4,limit:l=20}=r,o=W(t,e);if(!o)return[];if(!F(o.symbol))return[];let n=_(t,o,s);return n.length>0?n.slice(0,l):K(t,e,{minSimilarity:s,limit:l})}function _(t,e,r){let s=T(t,{minCallees:3,excludeSymbol:e.symbol}),l=A([e,...s].map(n=>n.callees)),o=[];for(let n of s){if(n.callees.size<3)continue;let i=N(e,n,l,{minSimilarity:r,requireSignificantShared:1,requireSharedCount:0});i&&o.push(i)}return o.sort((n,i)=>i.similarity-n.similarity),o}function N(t,e,r,s){let{similarity:l,significantShared:o}=j(t.callees,e.callees,r);if(l<s.minSimilarity)return null;let n=w(t.callees,e.callees).size;if(o.length<s.requireSignificantShared&&n<s.requireSharedCount)return null;let i=o.length>0?o:[...w(t.callees,e.callees)];return{symbolA:t.symbol,shortNameA:b(t.symbol),fileA:t.file,symbolB:e.symbol,shortNameB:b(e.symbol),fileB:e.file,similarity:l,sharedCallees:i.map(b),uniqueToA:[...h(t.callees,e.callees)].map(b),uniqueToB:[...h(e.callees,t.callees)].map(b)}}function le(t,e={}){let{minSimilarity:r=.5,limit:s=20,scope:l,minCallees:o=4,crossFileOnly:n=!1}=e,i=T(t,{minCallees:o,scope:l}),c=A(i.map(a=>a.callees)),u=new Map;for(let a of i)for(let m of a.callees)u.set(m,(u.get(m)??0)+1);let f=Math.max(8,Math.ceil(Math.sqrt(i.length))),S=new Map;for(let a=0;a<i.length;a+=1)for(let m of i[a].callees){if((u.get(m)??0)>f)continue;let g=S.get(m);g||(g=[],S.set(m,g)),g.push(a)}let C=[],R=new Set;e:for(let a=0;a<i.length;a+=1){let m=i[a],g=new Set;for(let k of m.callees){let y=S.get(k);if(y)for(let p of y)p>a&&g.add(p)}for(let k of g){let y=`${a}|${k}`;if(R.has(y))continue;R.add(y);let p=i[k];if(n&&m.file===p.file)continue;if(m.paramCount>=0&&p.paramCount>=0){let O=Math.abs(m.paramCount-p.paramCount),Z=Math.max(2,Math.ceil(Math.max(m.paramCount,p.paramCount)*.5));if(O>Z)continue}let P=N(m,p,c,{minSimilarity:r,requireSignificantShared:2,requireSharedCount:4});if(P&&(C.push(P),C.length>s*5))break e}}return C.sort((a,m)=>m.similarity-a.similarity),C.slice(0,s)}function W(t,e){let r=z(t,e);if(!r)return null;let s=$(t,r);return{symbol:r.symbol,file:r.relativePath,callees:new Set(s.map(l=>l.symbol)),paramCount:x(t,r.relativePath,r.startLine,r.endLine)?.paramCount??-1}}function T(t,e){let{minCallees:r,scope:s,excludeSymbol:l}=e,o=L(t,s).filter(i=>!t.isIgnored(i.relativePath)).filter(i=>i.isFunctionLike).filter(i=>l===void 0||i.symbol!==l).filter(i=>i.endLine-i.startLine+1>=5).filter(i=>!M(t,i.relativePath,i.startLine)),n=B(t,o);return o.map(i=>({symbol:i.symbol,file:i.relativePath,callees:new Set((n.get(i.symbolId)??[]).map(c=>c.symbol)),paramCount:x(t,i.relativePath,i.startLine,i.endLine)?.paramCount??-1})).filter(i=>i.callees.size>=r)}function K(t,e,r){let s=U(t,e);if(!s||s.tokens.size<3)return[];let l=r.minSimilarity>=.5?r.minSimilarity:.3,o=[];for(let n of H(t)){if(n.symbol===s.symbol||n.tokens.size<3)continue;let i=w(s.tokens,n.tokens);if(i.size<2)continue;let c=new Set([...s.tokens,...n.tokens]),u=c.size>0?i.size/c.size:0;u<l||o.push({symbolA:s.symbol,shortNameA:b(s.symbol),fileA:s.file,symbolB:n.symbol,shortNameB:b(n.symbol),fileB:n.file,similarity:u,sharedCallees:[...i].sort(),uniqueToA:[...h(s.tokens,n.tokens)].sort(),uniqueToB:[...h(n.tokens,s.tokens)].sort()})}return o.sort((n,i)=>i.similarity-n.similarity||n.shortNameB.localeCompare(i.shortNameB)),o.slice(0,r.limit)}function U(t,e){let r=z(t,e);if(!r||!F(r.symbol))return null;let s=G(t,r);return s?{symbol:r.symbol,file:r.relativePath,tokens:s}:null}function G(t,e){let r=q(e.symbol),s=E(t,e.relativePath,e.startLine,e.endLine,r),l=I(s,r);return l.size>0?l:null}function H(t){return D(t).filter(e=>e.isFunctionLike).map(e=>({symbol:e.symbol,file:e.relativePath,tokens:I(E(t,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)})).filter(e=>e.tokens.size>0)}function E(t,e,r,s,l){let o=v(t,e);if(!o)return"";let n=o.split(`
2
- `);if(s>=r&&s-r<=12)return n.slice(r,s+1).join(`
3
- `);let i=[new RegExp(`\\bdef\\s+${d(l)}\\b`),new RegExp(`\\bfun\\s+${d(l)}\\b`),new RegExp(`\\bfn\\s+${d(l)}\\b`),new RegExp(`\\bfunction\\s+${d(l)}\\b`),new RegExp(`\\b${d(l)}\\s*\\(`)],c=n.findIndex(u=>i.some(f=>f.test(u)));if(c>=0){let u=c;for(let f=c+1;f<n.length&&f<=c+8;f++){let S=n[f]??"";if(f>c&&Q(S)||(u=f,S.trim()===""&&f>c+1))break}return n.slice(c,u+1).join(`
4
- `)}return n.slice(r,Math.min(n.length,r+8)).join(`
5
- `)}function I(t,e){if(!t)return new Set;let r=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"]),s=J(e),o=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=>!r.has(n)).filter(n=>!s.has(n));return new Set(o)}function J(t){return new Set(t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(e=>e.toLowerCase()).filter(e=>e.length>1))}function Q(t){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(t)}function d(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{se as a,le as b};
6
- //# sourceMappingURL=chunk-K6GBKEQE.js.map
@@ -1,12 +0,0 @@
1
- import{c as M,d as O,e as T,f as j}from"./chunk-GNXRLK5G.js";import{a as L}from"./chunk-VEUMRDHW.js";import{a as I}from"./chunk-ZSRXMNMK.js";import{c as F}from"./chunk-WCDXJGYT.js";import{f as b,g as P,h as x,k,m as A,q as D}from"./chunk-IYFZS4PV.js";import{b as C,f as N,g as R}from"./chunk-TINPMWJK.js";var S=new WeakMap;function $(n,u){let r=b(u);return r==="rust"?G(n,u):r==="typescript"||r==="tsx"||r==="javascript"?J(n,u):[]}var U=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function J(n,u){let r=x(n,u);if(!r)return[];let d=S.get(r);if(d)return d;let o=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(u)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(u),c=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(u),f=!1,s=r.rootNode;for(let i of s.namedChildren){if(i.type!=="expression_statement")continue;let e=i.namedChild(0);if(!e||e.type!=="call_expression")continue;let a=e.namedChild(0);if(!a)continue;let l=a.type==="member_expression"?a.namedChild(a.namedChildCount-1)?.text:a.text;if(l&&U.has(l)){f=!0;break}}let m=[];f&&m.push({startLine:0,endLine:s.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(o||c)&&m.push({startLine:0,endLine:s.endPosition.row,reason:o?"Next.js / Remix route file":"Vite/Vue route component"});for(let i of s.namedChildren){let e=null,a=null;if(i.type==="function_declaration")e=i.namedChild(0)?.text??null,a=i;else if(i.type==="export_statement"){let l=i.namedChild(0);l?.type==="function_declaration"&&(e=l.namedChild(0)?.text??null,a=l)}else if(i.type==="lexical_declaration"){let l=i.namedChild(0);if(l?.type==="variable_declarator"){let h=l.namedChild(0)?.text,y=l.namedChild(1);h&&(y?.type==="arrow_function"||y?.type==="function_expression")&&(e=h,a=l)}}e&&/^use[A-Z]/.test(e)&&a&&m.push({startLine:a.startPosition.row,endLine:a.endPosition.row,reason:"React custom hook (use*)"})}return m.push(...W(r,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),S.set(r,m),m}var q=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function z(n){return q.test(n)}function W(n,u,r){let d=[],o=c=>{if(u.has(c.type)&&c.parent){let s=c.parent.children,m=-1;for(let i=0;i<s.length;i+=1)if(s[i].startIndex===c.startIndex&&s[i].type===c.type){m=i;break}if(m>0)for(let i=m-1;i>=0;i-=1){let e=s[i];if(r.has(e.type)){if(z(e.text)){d.push({startLine:c.startPosition.row,endLine:c.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(e.type==="attribute_item"||e.type==="inner_attribute_item"))break}}for(let f of c.namedChildren)o(f)};return o(n.rootNode),d}function G(n,u){let r=x(n,u);if(!r)return[];let d=S.get(r);if(d)return d;let o=[],c=e=>{let a=e.parent;if(!a)return[];let l=a.children,h=-1;for(let p=0;p<l.length;p+=1)if(l[p].startIndex===e.startIndex&&l[p].type===e.type){h=p;break}if(h<=0)return[];let y=[];for(let p=h-1;p>=0;p-=1){let g=l[p];if(g.type==="attribute_item"||g.type==="inner_attribute_item")y.push(g.text);else{if(g.type==="line_comment"||g.type==="block_comment")continue;break}}return y},f=e=>/#\[\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,s=e=>/#\[\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):!1,m=e=>/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e),i=(e,a,l)=>{let h=a,y=l;if(e.type==="impl_item"&&e.namedChildren.filter(g=>g.type==="type_identifier").length>=2&&(y=!0),e.type==="function_item"||e.type==="function_signature_item"){let p=c(e),g=null;l?g="trait impl method (dynamic dispatch)":a&&(g="inside #[cfg(test)] mod");for(let t of p){let _=f(t);if(_){g=_;break}if(m(t)){g="#[allow(dead_code)]";break}}g&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:g})}else if(e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"){let p=c(e),g=p.some(s),t=p.some(m),_=e.namedChildren.find(E=>E.type==="type_identifier")?.text;g&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:_}),t&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:_}),a&&o.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:_})}else e.type==="mod_item"&&c(e).some(g=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(g))&&(h=!0);for(let p of e.namedChildren)i(p,h,y)};return i(r.rootNode,!1,!1),o.push(...W(r,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.set(r,o),o}var K=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function H(n,u){return k(n,u,X,()=>new Set,(r,d,o)=>{if(!(d!=="typescript"&&d!=="tsx"&&d!=="javascript"))for(let c of r.rootNode.descendantsOfType("call_expression")){let f=c.namedChild(0);if(!f)continue;let s=A(f);if(!s||!K.has(s))continue;let m=c.namedChildren.find(a=>a.type==="arguments");if(!m)continue;let i=m.namedChild(0);if(!i||i.type!=="string")continue;let e=i.namedChildren.find(a=>a.type==="string_fragment");e&&o.add(e.text)}})??new Set}var X=new WeakMap;function fe(n,u={}){let{scope:r,minLoc:d=1,includeTests:o=!1,skipBarrels:c=!1,includeMembers:f=!1}=u,s=c?new Set(M(n)):new Set,m=n.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
- ${n.pathExclusionsFor("d")}
10
- GROUP BY m.symbol_id, d.relative_path`),i=new Map;for(let t of m){if(n.isIgnored(t.relative_path)||s.has(t.relative_path))continue;let _=i.get(t.symbol_id);_||(_=new Map,i.set(t.symbol_id,_)),_.set(t.relative_path,t.ref_count)}Y(n,i,s);let e=Z(n),l=D(n,{scope:r}).filter(t=>!n.isIgnored(t.relativePath)).filter(t=>!R(t.symbol)).filter(t=>w(t.symbol)).filter(t=>t.isFunctionLike||!t.enclosingSymbol||!w(t.enclosingSymbol)).filter(t=>o||Q(t.relativePath)).filter(t=>o||!e(t.relativePath,t.startLine,t.parentTypeName)).filter(t=>f||w(t.symbol)).filter(t=>t.endLine-t.startLine+1>=d).map(t=>{let _=i.get(t.symbolId)??new Map,E=_.get(t.relativePath)??0,v=0;for(let[B,V]of _)B!==t.relativePath&&(v+=V);return{relative_path:t.relativePath,start_line:t.startLine,end_line:t.endLine,loc:t.endLine-t.startLine+1,symbol:t.symbol,same_file_refs:E,cross_file_refs:v}}).filter(t=>t.cross_file_refs===0).sort((t,_)=>_.loc-t.loc||t.relative_path.localeCompare(_.relative_path)||t.start_line-_.start_line),h=0,y=0,p=0,g=l.filter(t=>!n.isIgnored(t.relative_path)).filter(t=>!O(n,t.relative_path)).map(t=>{let _=t.same_file_refs===0?"dead-code":"file-internal";return _==="dead-code"?h++:y++,p+=t.loc,{relativePath:t.relative_path,startLine:t.start_line,endLine:t.end_line,loc:t.loc,symbol:t.symbol,shortName:C(t.symbol),sameFileRefs:t.same_file_refs,kind:_}});return{symbols:g,totalCount:g.length,deadCodeCount:h,fileInternalCount:y,totalLoc:p}}function Y(n,u,r){let d=n.all(`SELECT relative_path FROM documents
11
- WHERE 1 = 1 ${n.pathExclusionsFor("documents")}`),o=new Set(d.map(s=>s.relative_path)),c=new Set(I(n));for(let s of o)c.add(s);let f=(s,m,i)=>{if(i<=0)return;let e=u.get(s);e||(e=new Map,u.set(s,e)),e.set(m,(e.get(m)??0)+i)};for(let s of c){if(!b(s)&&!P(s)||n.isIgnored(s)||r.has(s))continue;let m=F(n,s);for(let[e,a]of m){let l=L(n,s,e);if(l.length!==0)for(let h of l){let y=h.relativePath===s?Math.max(0,a.length-1):a.length;f(h.symbolId,s,y)}}let i=H(n,s);for(let e of i){let a=L(n,s,e);for(let l of a)l.relativePath!==s&&f(l.symbolId,s,1)}}}function Z(n){let u=new Map,r=d=>{let o=u.get(d);if(o)return o;let c=$(n,d);return o={ranges:c.map(f=>({startLine:f.startLine,endLine:f.endLine})),containers:new Set(c.map(f=>f.containerName).filter(f=>!!f))},u.set(d,o),o};return(d,o,c)=>{let f=r(d);for(let s of f.ranges)if(o>=s.startLine&&o<=s.endLine)return!0;return!!(c&&f.containers.has(c))}}function Q(n){return[...new Set([...T,...j])].every(r=>!ee(n,r))}function ee(n,u){return new RegExp(`^${u.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(n)}function w(n){return N(n)||n.endsWith("().")||n.endsWith(".")}export{fe as a};
12
- //# sourceMappingURL=chunk-KO7YJRWP.js.map
@@ -1,7 +0,0 @@
1
- import{b as m}from"./chunk-VEUMRDHW.js";import{g}from"./chunk-WCDXJGYT.js";import{a as R}from"./chunk-LX4H4LLG.js";import{d as h}from"./chunk-IYFZS4PV.js";import{f as u}from"./chunk-TINPMWJK.js";function $(t,a){let e=R(t,a);if(!e)return[];let i=!u(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),o=new Set,f=[];for(let n of[...i,...l,...c]){let p=`${n.relativePath}:${n.line}`;o.has(p)||(o.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 s=t.all(`SELECT relative_path
2
- FROM documents
3
- WHERE relative_path LIKE '%.rb'
4
- ${t.pathExclusionsFor("documents")}
5
- ORDER BY relative_path`),i=[];for(let r of s){if(t.isIgnored(r.relative_path))continue;let l=h(t,r.relative_path);if(!l)continue;let c=l.split(`
6
- `);for(let o=0;o<c.length;o++){let f=c[o]??"";e.some(n=>new RegExp(`@${n}\\b|\\b${n}:`).test(f))&&i.push({relativePath:r.relative_path,line:o})}}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,""),s=e.split("_").filter(Boolean),i=new Set;return e&&i.add(e),s.length>=1&&i.add(s[s.length-1]),s.length>=2&&i.add(s.slice(-2).join("_")),[...i]}export{$ as a};
7
- //# sourceMappingURL=chunk-PZ6ESKRH.js.map
@@ -1,5 +0,0 @@
1
- import{c as I}from"./chunk-VEUMRDHW.js";import{j as A}from"./chunk-WCDXJGYT.js";import{d as M}from"./chunk-BQ3INTYT.js";import{a as P,d,e as x,f as F,h as w,j as D,r as C}from"./chunk-IYFZS4PV.js";import{b as L,c as b}from"./chunk-TINPMWJK.js";function te(t,n){let{scope:s,minLoc:i=3,limit:o=30,includeLowConfidence:a=!1}=n??{},c=k(t,s),r=C(t,s).filter(e=>e.isTypeLike&&T(e)>=i).filter(e=>!t.isIgnored(e.relativePath)).filter(e=>!x(t,e.relativePath,e.startLine)),l=A(t,r),u=I(t,r),f=G(l,u),g=new Map;for(let e of r){let m=g.get(e.relativePath);m||(m=new Map,g.set(e.relativePath,m));let p=b(e.symbol);p&&m.set(p,e)}return r.map(e=>{let p=[...f.get(e.symbolId)??new Set].filter(v=>v!==e.relativePath&&!t.isIgnored(v)),{realConsumers:h,barrelConsumers:S}=E(t,e.relativePath,e.symbol,p),_=$(t,e,f,g);return{definition:e,realConsumers:h,barrelConsumers:S,transitivelyReachable:_}}).filter(e=>!e.transitivelyReachable).filter(e=>e.realConsumers.length<=1).filter(e=>!(e.realConsumers.length===0&&e.barrelConsumers>0)).filter(e=>R(e.definition,e.realConsumers.length,c)).map(e=>{let m=B(t,e.definition.relativePath,e.definition.startLine),p=W(t,e.definition),{confidence:h,reason:S}=z(e.realConsumers.length,m,p);return{symbol:e.definition.symbol,shortName:L(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:T(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:m,definerUsesType:p,confidence:h,reason:S}}).filter(e=>a||e.confidence!=="low").sort((e,m)=>{let p={high:0,medium:1,low:2};return p[e.confidence]-p[m.confidence]||m.loc-e.loc||e.file.localeCompare(m.file)||e.startLine-m.startLine}).slice(0,o)}function k(t,n){return new Set(C(t,n).filter(s=>s.isFunctionLike).map(s=>s.relativePath))}function R(t,n,s){return!(((t.relativePath.split("/").pop()??"").includes("types")||t.relativePath.includes("/types/"))&&n>0||n===0&&s.has(t.relativePath))}function E(t,n,s,i){let o=[],a=0,c=b(s);for(let r of i)j(t,r,n,c)||U(t,r,c)?a++:o.push(r);return{realConsumers:o,barrelConsumers:a}}function $(t,n,s,i){let o=D(t,n.relativePath),a=b(n.symbol);if(!a)return!1;let c=o.get(a);if(!c||c.size===0)return!1;let r=i.get(n.relativePath);if(!r)return!1;for(let l of c){let u=r.get(l);if(!u)continue;let f=s.get(u.symbolId);if(f){for(let g of f)if(g!==n.relativePath&&!t.isIgnored(g))return!0}}return!1}var N=P("stale-abs-file-usage");function U(t,n,s){if(!s)return!1;let i=F(n);if(!i)return!1;let o=N.get(t,n,()=>O(t,n,i));return o.importedLeaves.has(s)&&!o.usedLeaves.has(s)}function O(t,n,s){let i=new Set,o=new Set,a=w(t,n);if(!a)return{importedLeaves:i,usedLeaves:o};let c=s==="rust"?new Set(["use_declaration"]):s==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),r=(l,u)=>{let f=u||c.has(l.type);(l.type==="identifier"||l.type==="type_identifier"||l.type==="property_identifier"||l.type==="field_identifier")&&(f?i.add(l.text):o.add(l.text));for(let g of l.children)r(g,f)};return r(a.rootNode,!1),{importedLeaves:i,usedLeaves:o}}function j(t,n,s,i){if(!i)return!1;let o=d(t,n);if(!o)return!1;let a=M(t,n);if(a.length===0)return!1;let c=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${c}\\b`),l=o.split(`
2
- `),u=0;for(let f=0;f<l.length;f++){if(!r.test(l[f]??""))continue;if(u++,!a.find(y=>y.startLine<=f&&f<=y.endLine))return!1}return u>0}function B(t,n,s){let i=d(t,n);if(!i)return"other";let o=i.split(`
3
- `),a=Math.max(0,s-2),c=Math.min(o.length-1,s+2);for(let r=a;r<=c;r++){let u=(o[r]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(u))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(u))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(u))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(u))return"enum"}return"other"}function W(t,n){let s=d(t,n.relativePath);if(!s)return!1;let i=b(n.symbol);if(!i)return!1;let o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${o}\\b`),c=s.split(`
4
- `);for(let r=0;r<c.length;r++)if(!(r>=n.startLine&&r<=n.endLine)&&a.test(c[r]??""))return!0;return!1}function z(t,n,s){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&n==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!s?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}function T(t){return t.endLine-t.startLine+1}function G(...t){let n=new Map;for(let s of t)for(let[i,o]of s){let a=n.get(i);a||(a=new Set,n.set(i,a));for(let c of o)a.add(c)}return n}export{te as a};
5
- //# sourceMappingURL=chunk-RJ7SPBJ5.js.map
@@ -1,2 +0,0 @@
1
- var m={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function f(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let r=e.split(" ");if(r.length<4)return{scheme:r[0]??"",manager:r[1]??"",packageName:r[2]??"",version:"",descriptors:[],raw:e};let s=r[0],i=r[1],n=e.slice(s.length+1+i.length+1),t;if(n.startsWith("`")){let a=n.indexOf("`",1);a===-1?(t=n.slice(1),n=""):(t=n.slice(1,a),n=n.slice(a+2))}else{let a=n.indexOf(" ");a===-1?(t=n,n=""):(t=n.slice(0,a),n=n.slice(a+1))}let c,o=n.indexOf(" ");o===-1?(c=n,n=""):(c=n.slice(0,o),n=n.slice(o+1));let l=u(n);return{scheme:s,manager:i,packageName:t,version:c,descriptors:l,raw:e}}function u(e){let r=[],s=0;for(;s<e.length;){if(e[s]==="["){let t=e.indexOf("]",s+1);if(t===-1){r.push({name:e.slice(s+1),suffix:"type-param"});break}r.push({name:e.slice(s+1,t),suffix:"type-param"}),s=t+1;continue}if(e[s]==="("&&(r.length===0||s===0||d(e[s-1]))){let t=e.indexOf(")",s+1);if(t!==-1&&e[t+1]!=="."){r.push({name:e.slice(s+1,t),suffix:"parameter"}),s=t+1;continue}}let i;if(e[s]==="`"){let t=e.indexOf("`",s+1);if(t===-1){i=e.slice(s+1),r.push({name:i,suffix:"term"});break}i=e.slice(s+1,t),s=t+1}else{let t=s;for(;s<e.length&&!d(e[s]);)s++;i=e.slice(t,s)}if(s>=e.length){i&&r.push({name:i,suffix:"term"});break}let n=e[s];if(n==="("){let t=e.indexOf(")",s+1);t!==-1&&e[t+1]==="."?(r.push({name:i,suffix:"method"}),s=t+2):t!==-1?(r.push({name:i,suffix:"method"}),s=t+1):(r.push({name:i,suffix:"term"}),s++)}else{let t=m[n];t&&r.push({name:i,suffix:t}),s+=1}}return r}function d(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function h(e){let r=f(e);if("kind"in r&&r.kind==="local")return`local:${r.id}`;let s=r;if(s.descriptors.length===0)return s.raw;let i=[];for(let n of s.descriptors){let t=n.name;n.suffix==="namespace"&&(t=t.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")),t&&(n.suffix==="method"?i.push(`${t}()`):i.push(t))}return i.join(":")}function g(e){let r=f(e);if("kind"in r&&r.kind==="local")return r.id;let s=r;return s.descriptors.length===0?"":s.descriptors[s.descriptors.length-1].name}function p(e){let r=f(e);if("kind"in r&&r.kind==="local")return null;let s=r;return s.descriptors[s.descriptors.length-1]?.suffix??null}function x(e){return e.endsWith("().")||p(e)==="method"}function S(e){let r=p(e);return r==="method"||r==="term"}function b(e){return p(e)==="namespace"}function y(e,r){let s=f(e),i=f(r);if("kind"in s||"kind"in i)return!1;let n=s.descriptors,t=i.descriptors;if(t.length!==n.length+1)return!1;for(let c=0;c<n.length;c++){let o=n[c],l=t[c];if(o.name!==l.name||o.suffix!==l.suffix)return!1}return!0}function k(e,r){let s=f(e),i=f(r);if("kind"in s||"kind"in i)return!1;let n=s.descriptors,t=i.descriptors;if(t.length<=n.length)return!1;for(let c=0;c<n.length;c++){let o=n[c],l=t[c];if(o.name!==l.name||o.suffix!==l.suffix)return!1}return!0}export{f as a,h as b,g as c,p as d,x as e,S as f,b as g,y as h,k as i};
2
- //# sourceMappingURL=chunk-TINPMWJK.js.map
@@ -1,2 +0,0 @@
1
- import{a as z}from"./chunk-5IADAU5B.js";import{b as B}from"./chunk-K6GBKEQE.js";import{a as E}from"./chunk-RJ7SPBJ5.js";import{a as H}from"./chunk-N3Z2SJCR.js";import{a as A}from"./chunk-7Z4COVMC.js";import{a as W}from"./chunk-7VOF4ZG6.js";import{a as V}from"./chunk-7754WFFV.js";import{a as I}from"./chunk-F2LLHRRZ.js";import{a as k}from"./chunk-EEF3YEHW.js";import{a as j}from"./chunk-KO7YJRWP.js";import{d as y}from"./chunk-GNXRLK5G.js";import{a as q}from"./chunk-Y7H6D2EV.js";function ut(e,F={}){let{scope:r}=F,a=H(e),N=j(e,{scope:r,minLoc:3,skipBarrels:!0}),x=A(e,{scope:r,minLoc:3}),b=k(e,{scope:r}),T=B(e,{scope:r,minSimilarity:.6,limit:50,minCallees:4}),m=I(e,{scope:r,minLoc:15,minCallees:5,limit:50}),c=z(e,{scope:r,maxLoc:15,limit:50}),l=W(e,{scope:r,maxLoc:15,limit:50}),R=E(e,{scope:r,minLoc:3,limit:50}),n=V(e,{scope:r}),v=q(e,{scope:r,minLoc:10,limit:10}),S=N.symbols.filter(t=>!y(e,t.relativePath)&&t.kind==="dead-code"),u=S.length,$=S.reduce((t,o)=>t+o.loc,0),h=x.filter(t=>!y(e,t.relativePath)).length,p=R.length,M=n.results.length,d=T.length,s=[];u>0&&s.push({category:"Dead code",description:`${u} symbols with zero references anywhere \u2014 safe to delete`,effort:"low",impact:"high",count:u,locRecoverable:$}),h>0&&s.push({category:"Isolated symbols",description:`${h} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:h,locRecoverable:x.filter(t=>!y(e,t.relativePath)).reduce((t,o)=>t+o.loc,0)});let C=b.filter(t=>t.kind==="real");if(C.length>0&&s.push({category:"Circular dependencies",description:`${C.length} cycle(s) \u2014 break with dependency inversion or module restructuring`,effort:"medium",impact:"high",count:C.length,locRecoverable:0}),d>0&&s.push({category:"Similar functions",description:`${d} pairs with real logic overlap (beyond shared imports) \u2014 consolidation candidates`,effort:"medium",impact:"medium",count:d,locRecoverable:0}),m.length>0&&s.push({category:"Extraction candidates",description:`${m.length} large functions with isolated callee clusters \u2014 extract method opportunities`,effort:"medium",impact:"medium",count:m.length,locRecoverable:0}),c.length>0&&s.push({category:"Wrapper functions",description:`${c.length} single-consumer symbols that could be inlined`,effort:"low",impact:"low",count:c.length,locRecoverable:c.reduce((t,o)=>t+o.loc,0)}),l.length>0&&s.push({category:"Passthrough functions",description:`${l.length} functions that just forward to one callee \u2014 unnecessary indirection`,effort:"low",impact:"low",count:l.length,locRecoverable:l.reduce((t,o)=>t+o.loc,0)}),p>0){let t=R.filter(w=>w.consumers===0).length,o=p-t,g=[];t>0&&g.push(`${t} unused`),o>0&&g.push(`${o} single-consumer (not in types file)`),s.push({category:"Stale abstractions",description:`${g.join(", ")} \u2014 premature abstraction`,effort:"low",impact:"medium",count:p,locRecoverable:R.reduce((w,Z)=>w+Z.loc,0)})}if(M>0){let t=[];n.unusedImports>0&&t.push(`${n.unusedImports} unused imports`),n.layerViolations>0&&t.push(`${n.layerViolations} layer violations`),n.patternDeviations>0&&t.push(`${n.patternDeviations} unique deps`),s.push({category:"Structural drift",description:t.join(", "),effort:n.layerViolations>0?"medium":"low",impact:n.layerViolations>0?"medium":"low",count:M,locRecoverable:0})}let P={high:3,medium:2,low:1},L={low:3,medium:2,high:1};s.sort((t,o)=>{let g=P[t.impact]*L[t.effort];return P[o.impact]*L[o.effort]-g});let U=Math.max(a.documents,1),f=Math.max(a.symbols,1),i=100,G=u/f;i-=Math.min(20,Math.round(G*200));let J=h/f;i-=Math.min(10,Math.round(J*200));let D=b.filter(t=>t.kind==="real").length;i-=Math.min(15,D*5);let K=d/f*1e3;i-=Math.min(10,Math.round(K));let O=m.length/f*1e3;i-=Math.min(5,Math.round(O/2)),i-=Math.min(3,c.length),i-=Math.min(3,l.length);let Q=p/Math.max(f*.1,1);i-=Math.min(8,Math.round(Q*10));let X=M/U;i-=Math.min(5,Math.round(X*50));let Y=v.filter(t=>t.score>50).length;return i-=Math.min(5,Y*2),i=Math.max(0,Math.min(100,i)),{score:i,overview:{documents:a.documents,symbols:a.symbols,indexSizeBytes:a.indexSizeBytes},findings:{deadSymbols:u,deadLoc:$,isolatedSymbols:h,isolatedLoc:x.filter(t=>!y(e,t.relativePath)).reduce((t,o)=>t+o.loc,0),cycles:D,similarPairs:d,extractionCandidates:m.length,wrappers:c.length,passthroughs:l.length,staleTypes:p,driftedFiles:M,complexityHotspotCount:v.length},actions:s,topComplexity:v.slice(0,5).map(t=>({symbol:t.shortName,score:t.score}))}}export{ut as a};
2
- //# sourceMappingURL=chunk-UJB62HV3.js.map
@@ -1,2 +0,0 @@
1
- import{a as u}from"./chunk-ZSRXMNMK.js";import{a as y,b as h,i as x}from"./chunk-WCDXJGYT.js";import{e as I}from"./chunk-BQ3INTYT.js";import{c as S}from"./chunk-LX4H4LLG.js";import{d,p as g,t as b}from"./chunk-IYFZS4PV.js";import{c as p}from"./chunk-TINPMWJK.js";function w(o,c,n){let t=x(o).get(n);if(!t||t.length===0)return[];if(t.length===1)return[l(t[0])];let s=t.find(f=>f.file===c);if(s)return[l(s)];let e=D(o,c),i=e.get(n);if(i)for(let f of i){let r=t.filter(m=>R(f,m.file));if(r.length>0)return r.map(l)}let a=new Set;for(let f of e.values())for(let r of f)a.add(r);for(let f of a){let r=t.filter(m=>R(f,m.file));if(r.length>0&&r.length===t.length)return r.map(l)}return[]}function j(o,c){let n=S(o,c);if(!n)return[];let t=p(n.symbol);if(!t)return[];let s=new Map;for(let e of u(o)){let i=d(o,e);if(!i||i.indexOf(t)===-1||e!==n.relativePath&&!w(o,e,t).some(r=>r.symbolId===n.symbolId))continue;let a=y(o,e,t,e===n.relativePath?{excludeStartLine:n.startLine,excludeEndLine:n.endLine}:{});a.length>0&&s.set(e,a)}return F(o,s)}function C(o,c){let n=new Map;for(let e of c){if(!e.leaf)continue;let i=n.get(e.leaf)??[];i.push(e),n.set(e.leaf,i)}if(n.size===0)return new Map;let t=new Set(c.map(e=>e.symbolId)),s=new Map;for(let e of u(o)){let i=h(o,e);if(i.size!==0){for(let a of i)if(n.has(a))for(let f of w(o,e,a)){if(!t.has(f.symbolId)||e===f.relativePath)continue;let r=s.get(f.symbolId);r||(r=new Set,s.set(f.symbolId,r)),r.add(e)}}}return s}function D(o,c){let n=new Map;for(let t of I(o,c)){if(!t.sourcePath)continue;let s=t.localName??t.importedName;if(s){let e=n.get(s);e||(e=new Set,n.set(s,e)),e.add(t.sourcePath)}if(t.kind==="namespace")for(let e of t.usedMembers){let i=n.get(e);i||(i=new Set,n.set(e,i)),i.add(t.sourcePath)}}return n}function R(o,c){let n=t=>t.replace(/\\/g,"/").replace(/^\.\//,"");return n(o)===n(c)}function l(o){return{symbolId:o.symbolId,symbol:o.symbol,relativePath:o.file}}function F(o,c){let n=[],t=new Set;for(let[s,e]of c){let i=g(o,s);for(let a of e){let f=b(i,a),r=`${s}|${a}|${f?.symbol??""}`;t.has(r)||(t.add(r),n.push({file:s,line:a,enclosingSymbol:f?.symbol??null}))}}return n}export{w as a,j as b,C as c};
2
- //# sourceMappingURL=chunk-VEUMRDHW.js.map
@@ -1,65 +0,0 @@
1
- import{a as v,b as D,c as F,e as T}from"./chunk-BQ3INTYT.js";import{c as C}from"./chunk-LX4H4LLG.js";import{a as h,b as R,d as M,f as _,h as k,i as L,p as N,q as A,t as x}from"./chunk-IYFZS4PV.js";import{c as I}from"./chunk-TINPMWJK.js";function J(n,i,o,a={}){if(!o)return[];let l=M(n,i);if(!l)return[];if(l.indexOf(o)===-1)return[];if(_(i))return(w(n,i).get(o)??[]).filter(d=>!$(d,a));let s=D(n,i,l),r=new RegExp(`\\b${F(o)}\\b`),e=[];for(let c=0;c<s.length;c++)$(c,a)||r.test(s[c]??"")&&e.push(c);return e}function $(n,i){return typeof i.excludeStartLine=="number"&&typeof i.excludeEndLine=="number"&&n>=i.excludeStartLine&&n<=i.excludeEndLine}var G=h("file-identifiers");function re(n,i){return G.get(n,i,()=>new Set(w(n,i).keys()))}var Y=h("file-ident-lines");function w(n,i){return Y.get(n,i,()=>z(n,i))}var j=h("file-idents-by-line");function H(n,i){return j.get(n,i,()=>{let o=w(n,i),a=0;for(let s of o.values()){let r=s[s.length-1];r!==void 0&&r>a&&(a=r)}let l=new Array(a+1);for(let s=0;s<=a;s+=1)l[s]=new Set;for(let[s,r]of o)for(let e of r)l[e].add(s);return l})}function z(n,i){let o=new Map,a=(e,c)=>{let t=o.get(e);if(!t){o.set(e,[c]);return}t[t.length-1]!==c&&t.push(c)};if(_(i)){let e=k(n,i);if(e){let c=_(i),t=c==="rust"?new Set(["identifier","type_identifier","field_identifier"]):c==="python"?new Set(["identifier"]):new Set(["identifier","property_identifier","type_identifier"]),d=new Set(["rust","python"]),g=/\{(?:\?\s*)?([A-Za-z_][\w]*)/g,u=m=>{if(t.has(m.type)&&a(m.text,m.startPosition.row),c&&d.has(c)&&m.type==="string_content"){let b=m.startPosition.row;for(let f of m.text.matchAll(g))f[1]&&a(f[1],b)}for(let b of m.children)u(b)};return u(e.rootNode),o}}let l=M(n,i);if(!l)return o;let s=v(l).split(/\r?\n/),r=/\b([A-Za-z_$][\w$]*)\b/g;for(let e=0;e<s.length;e+=1){let c=s[e]??"";for(let t of c.matchAll(r))t[1]&&a(t[1],e)}return o}var K=h("file-dep-graph");function be(n,i){return K.get(n,i??"",()=>{let o=i?`AND d1.relative_path LIKE '%${i}%'`:"",a=n.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
- ${n.pathExclusionsFor("d1","d2")}
19
- ${o}`),l=new Map,s=new Set(n.all(`SELECT relative_path
20
- FROM documents
21
- WHERE 1 = 1
22
- ${n.pathExclusionsFor("documents")}
23
- ORDER BY relative_path`).map(e=>e.relative_path).filter(e=>!n.isIgnored(e))),r=(e,c)=>{e!==c&&(n.isIgnored(e)||n.isIgnored(c)||s.has(c)&&(l.has(e)||l.set(e,new Set),l.get(e).add(c)))};for(let e of a)r(e.from_file,e.to_file);for(let e of s)if(!(i&&!e.includes(i)))for(let c of T(n,e))c.sourcePath&&r(e,c.sourcePath);return l})}function pe(n,i,o={}){let l=P(n,[i]).get(i.symbolId)??[];return typeof o.limit=="number"?l.slice(0,o.limit):l}function _e(n,i,o={}){let l=Z(n).get(i.symbolId)??[];return typeof o.limit=="number"?l.slice(0,o.limit):l}var U=R("caller-rows");function Z(n){return U.get(n,()=>{let i=A(n),o=P(n,i),a=new Map;for(let r of i)a.set(r.symbol,r.symbolId);let l=new Map,s=new Map;for(let r of i){let e=o.get(r.symbolId);if(!(!e||e.length===0))for(let c of e){let t=a.get(c.symbol);if(t===void 0||t===r.symbolId)continue;let d=l.get(t);d||(d=[],l.set(t,d),s.set(t,new Set));let g=`${r.symbol}|${r.relativePath}`;s.get(t).has(g)||(s.get(t).add(g),d.push({symbol:r.symbol,file:r.relativePath}))}}return l})}function ye(n,i){let o=X(n,i);return o?q(n,V(n,o.match,o.identifier)):[]}function V(n,i,o){let a=n.all(`SELECT DISTINCT d.relative_path, c.start_line, c.end_line
24
- FROM mentions m
25
- JOIN chunks c ON m.chunk_id = c.id
26
- JOIN documents d ON c.document_id = d.id
27
- WHERE m.symbol_id = ?
28
- AND m.role != 1
29
- ${n.pathExclusionsFor("d")}
30
- ORDER BY d.relative_path, c.start_line`,i.symbolId),l=new Map;for(let r of a){if(n.isIgnored(r.relative_path))continue;let e=l.get(r.relative_path);e||(e=[],l.set(r.relative_path,e)),e.push({start_line:r.start_line,end_line:r.end_line})}let s=new Map;for(let[r,e]of l){let c=r===i.relativePath?{excludeStartLine:i.startLine,excludeEndLine:i.endLine}:{},t=o?J(n,r,o,c):[],d=[];for(let g of e){let u=t.filter(b=>b>=g.start_line&&b<=g.end_line),m=u.length>0?u:[g.start_line];for(let b of m)d.push(b)}s.set(r,d)}return s}function X(n,i){let o=C(n,i);return o?{match:o,identifier:I(o.symbol)||null}:null}function q(n,i){let o=[],a=new Set;for(let[l,s]of i){let r=N(n,l);for(let e of s){let c=x(r,e),t=`${l}|${e}|${c?.symbol??""}`;a.has(t)||(a.add(t),o.push({file:l,line:e,enclosingSymbol:c?.symbol??null}))}}return o}function P(n,i,o={}){if(i.length===0)return new Map;let a=o.additive??!1,l=[],s=[];for(let t of i)_(t.relativePath)&&L(n,t.relativePath)!==null?l.push(t):s.push(t);let r=new Map,e=t=>{for(let[d,g]of t){let u=r.get(d);u||(u=[],r.set(d,u));let m=new Set(u.map(b=>`${b.symbol}|${b.chunkId}`));for(let b of g){let f=`${b.symbol}|${b.chunkId}`;m.has(f)||(m.add(f),u.push(b))}}};l.length>0&&e(Q(n,l));let c=a?i:s;return c.length>0&&e(ne(n,c)),r}function Q(n,i){let o=new Map,a=new Map;for(let s of i){let r=a.get(s.relativePath);r?r.push(s):a.set(s.relativePath,[s]),o.set(s.symbolId,[])}let l=B(n);for(let[s,r]of a){let e=L(n,s);if(!e)continue;let c=[...r].sort((t,d)=>{let g=t.endLine-t.startLine,u=d.endLine-d.startLine;return g-u});for(let t of e){let d=null;for(let f of c)if(t.line>=f.startLine&&t.line<=f.endLine){d=f;break}if(!d)continue;let g=l.get(t.calleeLeaf);if(!g||g.length===0)continue;let u=null,m=g.find(f=>f.file===s);if(m?u=m:g.length===1&&(u=g[0]),!u||u.symbol===d.symbol)continue;o.get(d.symbolId).push({symbol:u.symbol,file:u.file,chunkId:t.line})}}return o}var ee=R("global-leaf-index");function B(n){return ee.get(n,()=>{let i=n.all(`SELECT gs.id, gs.symbol,
31
- COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
32
- FROM global_symbols gs
33
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
34
- LEFT JOIN documents der_doc ON der_doc.id = der.document_id
35
- LEFT JOIN (
36
- SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
37
- FROM mentions m
38
- JOIN chunks c ON m.chunk_id = c.id
39
- JOIN documents d ON c.document_id = d.id
40
- WHERE m.role = 1
41
- GROUP BY m.symbol_id
42
- ) mention_doc ON mention_doc.symbol_id = gs.id
43
- WHERE 1 = 1
44
- ${n.symbolNoiseFor("gs")}`),o=new Map;for(let a of i){if(!a.relative_path||n.isIgnored(a.relative_path))continue;let l=I(a.symbol);if(!l)continue;let s=o.get(l);s||(s=[],o.set(l,s)),s.some(r=>r.symbolId===a.id)||s.push({symbol:a.symbol,symbolId:a.id,file:a.relative_path})}return o})}function ne(n,i){if(i.length===0)return new Map;let o=n.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
45
- FROM mentions m
46
- JOIN chunks c ON m.chunk_id = c.id
47
- WHERE m.role != 1`),a=new Map;for(let t of o)a.has(t.document_id)||a.set(t.document_id,[]),a.get(t.document_id).push(t);let l=new Map(n.all("SELECT id, relative_path FROM documents").map(t=>[t.id,t.relative_path])),s=new Map,r=n.all(`SELECT gs.id AS symbol_id, gs.symbol,
48
- COALESCE(der.document_id, def_chunk.document_id) AS document_id
49
- FROM global_symbols gs
50
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
51
- LEFT JOIN (
52
- SELECT m.symbol_id, MIN(c.document_id) AS document_id
53
- FROM mentions m
54
- JOIN chunks c ON m.chunk_id = c.id
55
- WHERE m.role = 1
56
- GROUP BY m.symbol_id
57
- ) def_chunk ON def_chunk.symbol_id = gs.id`);for(let t of r)s.has(t.symbol_id)||s.set(t.symbol_id,{symbol:t.symbol,file:t.document_id!==null?l.get(t.document_id)??"":""});let e=new Map,c=l;for(let t of i){let d=a.get(t.documentId)??[],g=new Set,u=[],m=null,b=()=>{if(m)return m;let f=c.get(t.documentId)??"",p=new Set;if(f){let E=H(n,f),S=Math.max(0,t.startLine),O=Math.min(E.length-1,t.endLine);for(let y=S;y<=O;y+=1)for(let W of E[y])p.add(W)}return m=p,p};for(let f of d){if(f.symbol_id===t.symbolId)continue;let p=s.get(f.symbol_id);if(!p)continue;if(!(f.start_line>=t.startLine&&f.end_line<=t.endLine)){if(!(f.start_line<=t.endLine&&f.end_line>=t.startLine))continue;let y=I(p.symbol);if(!y||!b().has(y))continue}let S=`${p.symbol}|${f.chunk_id}`;g.has(S)||(g.add(S),u.push({...p,chunkId:f.chunk_id}))}e.set(t.symbolId,u)}return e}function he(n,i){let o=new Map,a=n.all(`SELECT relative_path FROM documents
58
- WHERE 1 = 1 ${n.pathExclusionsFor("documents")}`),l=B(n);for(let e of a){if(!_(e.relative_path)||n.isIgnored(e.relative_path))continue;let c=L(n,e.relative_path);if(c)for(let t of c){let d=l.get(t.calleeLeaf);if(!d||d.length===0)continue;let u=d.find(b=>b.file===e.relative_path)??(d.length===1?d[0]:null);if(!u||u.file===e.relative_path)continue;let m=o.get(u.symbolId);m||(m=new Set,o.set(u.symbolId,m)),m.add(e.relative_path)}}let s=n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
59
- c.start_line AS chunk_start, c.end_line AS chunk_end
60
- FROM mentions m
61
- JOIN chunks c ON m.chunk_id = c.id
62
- JOIN documents d ON c.document_id = d.id
63
- WHERE m.role != 1
64
- ${n.pathExclusionsFor("d")}`),r=new Map;if(i)for(let e of i)r.set(e.symbolId,{docId:e.documentId,startLine:e.startLine,endLine:e.endLine});for(let e of s){if(n.isIgnored(e.relative_path))continue;let c=r.get(e.symbol_id);if(c&&c.docId===e.document_id&&e.chunk_start>=c.startLine&&e.chunk_end<=c.endLine)continue;let t=o.get(e.symbol_id);t||(t=new Set,o.set(e.symbol_id,t)),t.add(e.relative_path)}return o}export{J as a,re as b,w as c,be as d,pe as e,_e as f,ye as g,P as h,B as i,he as j};
65
- //# sourceMappingURL=chunk-WCDXJGYT.js.map
@@ -1,2 +0,0 @@
1
- import{h as y,j as u}from"./chunk-WCDXJGYT.js";import{r as m}from"./chunk-IYFZS4PV.js";import{b as c}from"./chunk-TINPMWJK.js";function D(l,r){let{scope:o,minLoc:a=10,limit:b=30}=r??{},{definitions:f,callerMap:C,calleeMap:M}=S(l,o);return f.map(e=>{let s=e.endLine-e.startLine+1,p=C.get(e.symbolId)?.size??0,n=M.get(e.symbolId)??[],d=n.filter(t=>t.file!==e.relativePath),i=new Set(d.map(t=>`${t.symbol}|${t.file}`)).size,L=new Set(n.map(t=>`${t.symbol}|${t.file}`)).size;return{symbol:e.symbol,shortName:c(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:s,fanIn:p,fanOut:i,calleeCount:L,score:Math.round(s/50*(p/5)*Math.max(i/5,1)*100)/100}}).filter(e=>e.loc>=a).sort((e,s)=>s.score-e.score||s.loc-e.loc).slice(0,b)}function S(l,r){let o=m(l,r).filter(a=>a.isFunctionLike&&!l.isIgnored(a.relativePath));return{definitions:o,callerMap:u(l,o),calleeMap:y(l,o)}}export{D as a};
2
- //# sourceMappingURL=chunk-Y7H6D2EV.js.map