scip-query 0.7.1 → 0.8.0
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 +171 -1132
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-NSTZMBAB.js → chunk-2EC4JTHC.js} +2 -2
- package/dist/{chunk-ZXFTC5ET.js → chunk-46ILZVMX.js} +2 -2
- package/dist/chunk-4A4JFNWG.js +2 -0
- package/dist/{chunk-GAQGJ52J.js → chunk-4B7YLRXX.js} +2 -2
- package/dist/chunk-64UY7VTR.js +63 -0
- package/dist/chunk-66ORT3LS.js +2 -0
- package/dist/{chunk-QPRIYXH4.js → chunk-6G76D2YM.js} +2 -2
- package/dist/{chunk-VUBQBW7H.js → chunk-6P5W4U6G.js} +2 -2
- package/dist/chunk-6ZFKI5EP.js +40 -0
- package/dist/{chunk-ZNUPGRPR.js → chunk-7I6KNKE3.js} +2 -2
- package/dist/{chunk-23YIGCYF.js → chunk-7TYJD45F.js} +5 -5
- package/dist/chunk-7UZWNW4E.js +2 -0
- package/dist/{chunk-4STLJYHI.js → chunk-AGW2MVIO.js} +2 -2
- package/dist/chunk-APLCSDXL.js +4 -0
- package/dist/chunk-BCFED24F.js +2 -0
- package/dist/chunk-CVRXOP6M.js +3 -0
- package/dist/chunk-D43L5PQF.js +2 -0
- package/dist/chunk-DJTJ3DLZ.js +7 -0
- package/dist/chunk-EAU4RDFG.js +2 -0
- package/dist/{chunk-BI4F6GXI.js → chunk-EKP7XJ6L.js} +2 -2
- package/dist/{chunk-33SSUPCB.js → chunk-EM2PPDN7.js} +2 -2
- package/dist/{chunk-ROOHENEP.js → chunk-FIPE5AQT.js} +2 -2
- package/dist/chunk-FTBT4RP2.js +7 -0
- package/dist/{chunk-WPLKHAH7.js → chunk-GD7XRHSV.js} +2 -2
- package/dist/{chunk-WJQY2LGT.js → chunk-GMEBYEMU.js} +2 -2
- package/dist/chunk-GTZAU7OL.js +2 -0
- package/dist/chunk-HVGNOUYP.js +2 -0
- package/dist/chunk-HVXIXDLV.js +2 -0
- package/dist/{chunk-KJ3ZJIE5.js → chunk-I7OTKWNY.js} +2 -2
- package/dist/{chunk-2JEFS2YJ.js → chunk-JAMU6FLN.js} +2 -2
- package/dist/chunk-JTCEWV7Q.js +2 -0
- package/dist/chunk-K4Z3FCUJ.js +6 -0
- package/dist/{chunk-FD37DBTD.js → chunk-K6YIGVL7.js} +2 -2
- package/dist/chunk-MKE7SEEX.js +2 -0
- package/dist/chunk-N5D5ZCBW.js +7 -0
- package/dist/{chunk-ROZNBWIF.js → chunk-NGLRXEWN.js} +2 -2
- package/dist/{chunk-J6Z5YKGQ.js → chunk-NK7TQQG4.js} +2 -2
- package/dist/chunk-NOVKLH2F.js +2 -0
- package/dist/chunk-OIMM7KMI.js +2 -0
- package/dist/chunk-OQSV6OS2.js +2 -0
- package/dist/chunk-PBGTMPJ7.js +2 -0
- package/dist/{chunk-ARBZM2NF.js → chunk-PCMVXWDC.js} +4 -4
- package/dist/{chunk-U75WH4XG.js → chunk-PE4EJOLN.js} +2 -2
- package/dist/chunk-PLFYFZX3.js +2 -0
- package/dist/{chunk-A2AVLALL.js → chunk-QYQXPPDI.js} +2 -2
- package/dist/{chunk-3OUC276S.js → chunk-RCRK4E7E.js} +2 -2
- package/dist/chunk-RIXOMSOR.js +20 -0
- package/dist/chunk-SB6I6O3P.js +2 -0
- package/dist/{chunk-KNA6Z7JB.js → chunk-SDGCKEB7.js} +2 -2
- package/dist/chunk-SLOIQKY7.js +2 -0
- package/dist/chunk-SOGLYIJ4.js +62 -0
- package/dist/chunk-SSINY7HL.js +4 -0
- package/dist/{chunk-563HLCDW.js → chunk-TFO4OMJZ.js} +2 -2
- package/dist/chunk-TH4JVC34.js +71 -0
- package/dist/chunk-TQTVM27C.js +6 -0
- package/dist/{chunk-LDV2B7ET.js → chunk-TR5AU6A5.js} +2 -2
- package/dist/{chunk-WODJHE6Z.js → chunk-UQE3DSXY.js} +2 -2
- package/dist/{chunk-72JOIFXL.js → chunk-UUDYI3FF.js} +2 -2
- package/dist/chunk-VDZL45XI.js +2 -0
- package/dist/{chunk-QWJBIBE6.js → chunk-VN6B6HFB.js} +2 -2
- package/dist/{chunk-DFK54IRN.js → chunk-WC43FMAB.js} +2 -2
- package/dist/chunk-WEJYUS5O.js +2 -0
- package/dist/chunk-WQFOZIID.js +4 -0
- package/dist/chunk-XBFLIGWU.js +3 -0
- package/dist/chunk-XSZ5NC4O.js +2 -0
- package/dist/{chunk-2IYEIFPP.js → chunk-Z2AJQ7VA.js} +2 -2
- package/dist/chunk-ZIIQ55VK.js +2 -0
- package/dist/chunk-ZJ737ZMD.js +2 -0
- package/dist/cli.js +171 -174
- package/dist/health-C6r2VgpA.d.ts +234 -0
- package/dist/index.d.ts +16 -30
- package/dist/index.js +1 -1
- package/dist/postinstall.js +4 -4
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +66 -0
- package/dist/queries/cleanup-plan.js +2 -0
- package/dist/queries/co-change.d.ts +42 -0
- package/dist/queries/co-change.js +2 -0
- 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.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +52 -0
- package/dist/queries/diff-gate.js +2 -0
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +69 -0
- package/dist/queries/doc-drift.js +2 -0
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/index.d.ts +38 -2
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/outline.d.ts +1 -0
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +65 -0
- package/dist/queries/plan-context.js +2 -0
- package/dist/queries/recent-duplicates.d.ts +48 -0
- package/dist/queries/recent-duplicates.js +2 -0
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +58 -0
- package/dist/queries/self-audit.js +2 -0
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +6 -0
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/unused-params.d.ts +38 -0
- package/dist/queries/unused-params.js +2 -0
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.js +16 -16
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.js +2 -2
- package/package.json +34 -1
- package/skills/concrete-plan/SKILL.md +37 -7
- package/skills/scip-ai-cleanup/SKILL.md +145 -0
- package/skills/scip-debloat/SKILL.md +37 -7
- package/skills/scip-explore/SKILL.md +22 -9
- package/skills/scip-language-playbook/SKILL.md +4 -4
- package/skills/scip-maintainability/SKILL.md +264 -0
- package/skills/scip-verify/SKILL.md +2 -2
- package/dist/chunk-3GNFUVFA.js +0 -2
- package/dist/chunk-5TT47UMX.js +0 -44
- package/dist/chunk-6H2XIIPY.js +0 -71
- package/dist/chunk-7H4RJ4MC.js +0 -2
- package/dist/chunk-7O4MJYIW.js +0 -63
- package/dist/chunk-7OX2O53H.js +0 -62
- package/dist/chunk-BOVNTAKQ.js +0 -3
- package/dist/chunk-CKIO6SVS.js +0 -2
- package/dist/chunk-D6Z67MZL.js +0 -2
- package/dist/chunk-FOQQDXE7.js +0 -2
- package/dist/chunk-IODTPF5H.js +0 -20
- package/dist/chunk-JB4PUN5S.js +0 -40
- package/dist/chunk-JTXKS5GK.js +0 -3
- package/dist/chunk-KJ6CW6EK.js +0 -2
- package/dist/chunk-MDAYGS6T.js +0 -2
- package/dist/chunk-NHDPYW7O.js +0 -2
- package/dist/chunk-NKJKI6SE.js +0 -2
- package/dist/chunk-NYEMZHUC.js +0 -6
- package/dist/chunk-OHEIZWIA.js +0 -4
- package/dist/chunk-QAEDNTY7.js +0 -2
- package/dist/chunk-QE6MGGUY.js +0 -2
- package/dist/chunk-RCJEFQOK.js +0 -4
- package/dist/chunk-TGK5DFBJ.js +0 -2
- package/dist/chunk-TRNAQABL.js +0 -7
- package/dist/chunk-V53J46BX.js +0 -2
- package/dist/chunk-XO6R3X5J.js +0 -2
- package/dist/chunk-YSZNAG4G.js +0 -2
- package/dist/health-x7B4Xu_6.d.ts +0 -119
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scip-maintainability
|
|
3
|
+
description: Principled maintainability review using scip-query. Finds hidden policies, scattered concepts, accidental variation, weak boundaries, and system-compression opportunities, then proposes or executes structural improvements without chasing health scores.
|
|
4
|
+
allowed-tools: [Bash, Write, Edit, Glob, Agent, TaskCreate, TaskUpdate, TaskGet, TaskList]
|
|
5
|
+
keywords: [maintainability, architecture, compression, simplify, principal, staff, smell, hidden-policy, concept-boundary, accidental-variation, refactor]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# SCIP Maintainability Review
|
|
9
|
+
|
|
10
|
+
You are reviewing a codebase from the standpoint of a senior maintainer. The goal is not to maximize a metric. The goal is to make future changes easier to understand and safer to execute by tying every claim to `scip-query` evidence and by improving the structure that real maintainers must reason about.
|
|
11
|
+
|
|
12
|
+
A maintainability review is an architecture review over real code units such as files, symbols, commands, adapters, caches, public exports, tests, and docs. It identifies where one human concept is scattered across several mechanisms, where policy lives in caller folklore, and where accidental variation makes future edits harder than they need to be.
|
|
13
|
+
|
|
14
|
+
System compression belongs inside this review. A system compression is a maintainability improvement that replaces several mechanisms performing the same role, policy, lifecycle, or public-surface job with fewer named mechanisms that preserve behavior.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## When to Use This Skill
|
|
19
|
+
|
|
20
|
+
- "What would a principal engineer notice?"
|
|
21
|
+
- "What is gross here?"
|
|
22
|
+
- "Did this look vibe-coded?"
|
|
23
|
+
- "How should we simplify this architecture?"
|
|
24
|
+
- "Find deeper maintainability problems"
|
|
25
|
+
- "What hidden policies or concepts are scattered?"
|
|
26
|
+
- "Compress this system"
|
|
27
|
+
- "Find the refactor that actually makes this easier to maintain"
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Hard Rules
|
|
32
|
+
|
|
33
|
+
1. **Evidence first.** Use `scip-query` to ground claims in files, symbols, references, call graphs, dependencies, surfaces, and blast radius. If the SCIP index is missing or stale, run `scip-query reindex` before trusting graph facts.
|
|
34
|
+
|
|
35
|
+
2. **Do not chase health scores.** `scip-query health`, detector counts, and LOC estimates are diagnostic signals. They are not the objective. A change is valuable only when it reduces real maintenance burden while preserving behavior.
|
|
36
|
+
|
|
37
|
+
3. **Name the referents before naming the smell.** A smell is not real until you can point to the concrete files, symbols, tests, or public surfaces that make the future-maintenance risk real.
|
|
38
|
+
|
|
39
|
+
4. **Preserve essential variation.** Do not compress code merely because it looks similar. Different language grammars, runtime contracts, compatibility boundaries, public APIs, or domain rules may justify different code.
|
|
40
|
+
|
|
41
|
+
5. **Reject false abstractions.** A new abstraction is justified only when it removes a hidden policy, names a lifecycle, enforces a rule callers were hand-maintaining, or reduces the concept count required for safe change.
|
|
42
|
+
|
|
43
|
+
6. **Prefer small named mechanisms.** Delete, inline, merge, generate, or enforce before adding broad frameworks.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Core Concepts
|
|
48
|
+
|
|
49
|
+
A code smell is an observable codebase fact that predicts avoidable future mistakes because the same knowledge must be rediscovered, synchronized, or defended in more than one place.
|
|
50
|
+
|
|
51
|
+
A concept boundary is the line around code units that exist for one reason to change. A weak boundary mixes unrelated reasons to change, such as parsing syntax, choosing fallback policy, caching data, and rendering output in one module.
|
|
52
|
+
|
|
53
|
+
A hidden policy is a rule for choosing behavior when several plausible behaviors exist, but the rule is implemented through local branches, repeated comments, naming conventions, or caller folklore instead of a named mechanism.
|
|
54
|
+
|
|
55
|
+
A lifecycle is a repeatable sequence of states or steps that makes a result valid, such as parse -> fallback -> emit, candidate -> evidence -> score -> report, or load -> augment -> write -> invalidate.
|
|
56
|
+
|
|
57
|
+
Accidental variation is difference in code shape that does not correspond to a difference in behavior, domain facts, runtime constraints, or external contracts.
|
|
58
|
+
|
|
59
|
+
Essential variation is difference that must remain because the real-world units differ, such as different language grammars, indexer capabilities, user-visible APIs, runtime environments, or compatibility boundaries.
|
|
60
|
+
|
|
61
|
+
Concept count is the number of distinct ideas a maintainer must keep active to make a safe change. Lowering concept count is valuable only when the new structure still explains all real variation.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Workflow
|
|
66
|
+
|
|
67
|
+
### 1. Bound the Review
|
|
68
|
+
|
|
69
|
+
Restate the question in concrete terms:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
What future-maintenance mistakes does this structure invite, and what smaller named mechanisms would prevent them without hiding real variation?
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Identify the scope: whole repo, module, command family, query family, runtime surface, test fixture set, or one feature path.
|
|
76
|
+
|
|
77
|
+
### 2. Refresh and Map Evidence
|
|
78
|
+
|
|
79
|
+
Start from current code intelligence:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
scip-query status
|
|
83
|
+
scip-query reindex # Run when missing, stale, uncertain, or after code changes
|
|
84
|
+
scip-query stats
|
|
85
|
+
scip-query system <scope>
|
|
86
|
+
scip-query surface <scope>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Then map the concrete units:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
scip-query files <pattern>
|
|
93
|
+
scip-query outline <file>
|
|
94
|
+
scip-query outline <file>
|
|
95
|
+
scip-query deps <file>
|
|
96
|
+
scip-query rdeps <file>
|
|
97
|
+
scip-query trace <symbol>
|
|
98
|
+
scip-query call-graph <symbol>
|
|
99
|
+
scip-query affected <symbol>
|
|
100
|
+
scip-query change-surface <file>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use cleanup commands as probes, not verdicts:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
scip-query health --json
|
|
107
|
+
scip-query similar
|
|
108
|
+
scip-query similar-files
|
|
109
|
+
scip-query similar-chains
|
|
110
|
+
scip-query extract-candidates
|
|
111
|
+
scip-query wrapper-candidates
|
|
112
|
+
scip-query passthrough-candidates
|
|
113
|
+
scip-query stale-abstractions --include-low-confidence
|
|
114
|
+
scip-query drift
|
|
115
|
+
scip-query cycles
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 3. Build a Role Inventory
|
|
119
|
+
|
|
120
|
+
For each important cluster, record:
|
|
121
|
+
|
|
122
|
+
- concrete files and exported symbols
|
|
123
|
+
- callers and downstream public surfaces
|
|
124
|
+
- tests and fixtures that define behavior
|
|
125
|
+
- fallback paths, caches, registries, adapters, and command handlers
|
|
126
|
+
- generated artifacts or compatibility constraints
|
|
127
|
+
- the role each unit plays in the workflow
|
|
128
|
+
|
|
129
|
+
Ask:
|
|
130
|
+
|
|
131
|
+
- What one concept is being implemented in several places?
|
|
132
|
+
- What policy is hidden in branches, comments, argument conventions, or test fixtures?
|
|
133
|
+
- What lifecycle is present but unnamed?
|
|
134
|
+
- Which differences are essential, and which are accidental?
|
|
135
|
+
- What must a new maintainer know that the local interface does not admit?
|
|
136
|
+
- Would a smaller named mechanism remove a reason to change, or only move code around?
|
|
137
|
+
|
|
138
|
+
### 4. Rank Maintainability Pressure
|
|
139
|
+
|
|
140
|
+
Prefer severe smells in this order:
|
|
141
|
+
|
|
142
|
+
1. Hidden correctness or evidence policy spread across modules.
|
|
143
|
+
2. Repeated lifecycle or pipeline with no named owner.
|
|
144
|
+
3. Public surface that exposes accidental internals.
|
|
145
|
+
4. Large module with multiple unrelated reasons to change.
|
|
146
|
+
5. Tests that encode incident history without contract vocabulary.
|
|
147
|
+
6. Adapter families with repeated capability or fallback shapes.
|
|
148
|
+
7. Suppression comments that document architecture decisions instead of exceptions.
|
|
149
|
+
8. Thin wrappers, pass-throughs, and helper layers that do not buy clarity.
|
|
150
|
+
|
|
151
|
+
Reject a target when:
|
|
152
|
+
|
|
153
|
+
- similar code reflects essential variation
|
|
154
|
+
- the new abstraction needs more concepts than it removes
|
|
155
|
+
- a compatibility boundary must stay explicit
|
|
156
|
+
- the smell is only aesthetic
|
|
157
|
+
- the behavior cannot be verified
|
|
158
|
+
|
|
159
|
+
### 5. Choose a Compression Model
|
|
160
|
+
|
|
161
|
+
For substantial changes, compare at least two models:
|
|
162
|
+
|
|
163
|
+
- conservative: delete or inline local bloat without changing ownership
|
|
164
|
+
- shape-level: introduce one small mechanism that owns a repeated role or lifecycle
|
|
165
|
+
- radical: replace a scattered surface with metadata, generation, or an enforced policy
|
|
166
|
+
|
|
167
|
+
Evaluate each model by:
|
|
168
|
+
|
|
169
|
+
- behavior preserved
|
|
170
|
+
- concept count removed
|
|
171
|
+
- blast radius from `affected`, `change-surface`, `deps`, and `rdeps`
|
|
172
|
+
- deletion potential
|
|
173
|
+
- failure mode if the abstraction is false
|
|
174
|
+
- migration path and verification cost
|
|
175
|
+
|
|
176
|
+
Choose the model that removes a concept or policy duplication, not the model that merely extracts a helper.
|
|
177
|
+
|
|
178
|
+
### 6. Produce a Register or Atlas
|
|
179
|
+
|
|
180
|
+
For broad review, create or update a register under `docs/plans/` unless the user asks not to edit files:
|
|
181
|
+
|
|
182
|
+
```markdown
|
|
183
|
+
# SCIP Maintainability Register
|
|
184
|
+
|
|
185
|
+
## Executive Read
|
|
186
|
+
## Scope Map
|
|
187
|
+
## Smell Ledger
|
|
188
|
+
|
|
189
|
+
| Priority | Smell | Evidence | Why it hurts | Better shape | Disposition |
|
|
190
|
+
| --- | --- | --- | --- | --- | --- |
|
|
191
|
+
|
|
192
|
+
## Compression Opportunities
|
|
193
|
+
## Deferred Boundaries
|
|
194
|
+
## Verification Plan
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
For implementation work, create an atlas before editing:
|
|
198
|
+
|
|
199
|
+
```markdown
|
|
200
|
+
# <Scope> Maintainability Atlas
|
|
201
|
+
|
|
202
|
+
## Scope Map
|
|
203
|
+
## Role Inventory
|
|
204
|
+
## Hidden Policies
|
|
205
|
+
## Essential vs Accidental Variation
|
|
206
|
+
## Opportunity Ledger
|
|
207
|
+
## Dependency Order
|
|
208
|
+
## Touch Map
|
|
209
|
+
## Validation Plan
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Use dispositions:
|
|
213
|
+
|
|
214
|
+
- `merge`: combine mechanisms with the same role
|
|
215
|
+
- `delete`: remove proven unused or replaced code
|
|
216
|
+
- `inline`: remove a wrapper, adapter, or single-use abstraction
|
|
217
|
+
- `extract`: isolate a real shared role that multiple consumers need
|
|
218
|
+
- `generate`: derive a surface from metadata instead of maintaining it by hand
|
|
219
|
+
- `enforce`: centralize a policy or invariant so callers cannot drift
|
|
220
|
+
- `supersede`: absorb a local issue into a larger cluster
|
|
221
|
+
- `defer`: keep visible but out of scope because of a verified blocker
|
|
222
|
+
- `skip`: reject because the compression is false or net-negative
|
|
223
|
+
|
|
224
|
+
### 7. Implement Conservatively
|
|
225
|
+
|
|
226
|
+
When asked to fix the smells:
|
|
227
|
+
|
|
228
|
+
- introduce the smallest named mechanism that matches the real concept
|
|
229
|
+
- keep essential variation close to the adapter or domain code that knows it
|
|
230
|
+
- move hidden policies behind interfaces that make the choice visible
|
|
231
|
+
- preserve behavior before broadening scope
|
|
232
|
+
- update registers or docs to record deferred boundaries and why
|
|
233
|
+
|
|
234
|
+
### 8. Verify the Work
|
|
235
|
+
|
|
236
|
+
Run focused tests for touched code and repeat the structural probes that motivated the change:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
scip-query health --json
|
|
240
|
+
scip-query drift
|
|
241
|
+
scip-query stale-abstractions --include-low-confidence
|
|
242
|
+
scip-query wrapper-candidates
|
|
243
|
+
scip-query passthrough-candidates
|
|
244
|
+
scip-query similar-files
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Report:
|
|
248
|
+
|
|
249
|
+
- the named smell addressed
|
|
250
|
+
- the mechanism introduced, deleted, or simplified
|
|
251
|
+
- what was deliberately not compressed
|
|
252
|
+
- verification results
|
|
253
|
+
- commit hash, when committed
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Output Style
|
|
258
|
+
|
|
259
|
+
Be candid, specific, and evidence-grounded:
|
|
260
|
+
|
|
261
|
+
- "This module has three reasons to change."
|
|
262
|
+
- "This helper names a policy that was previously caller folklore."
|
|
263
|
+
- "This is false compression because the two adapters differ by runtime contract."
|
|
264
|
+
- "The health score changed, but that is a side effect, not the reason this was worth doing."
|
|
@@ -37,7 +37,7 @@ You are verifying that a code change was implemented correctly. Every check must
|
|
|
37
37
|
|
|
38
38
|
## Symbol Lookup Tips
|
|
39
39
|
|
|
40
|
-
scip-query accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
|
|
40
|
+
`scip-query` accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
43
|
scip-query code processVegaMention # just the function name
|
|
@@ -64,7 +64,7 @@ scip-query code 'src/modules/chat/chat.service.ts:100-200'
|
|
|
64
64
|
|
|
65
65
|
**If "Symbol not found":**
|
|
66
66
|
1. Try a shorter/simpler name — `login` instead of `AuthService:login`
|
|
67
|
-
2. Try `scip-query
|
|
67
|
+
2. Try `scip-query outline <file>` to see what symbols exist in the file
|
|
68
68
|
3. Try `scip-query trace <name>` which uses a different lookup path
|
|
69
69
|
4. Use the `file:line-line` syntax for `code` if you know the location
|
|
70
70
|
|
package/dist/chunk-3GNFUVFA.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as C}from"./chunk-V76FCF5F.js";import{a as x,b as L}from"./chunk-MX6F756F.js";import{b as h}from"./chunk-QAEDNTY7.js";import{c as m,g as c}from"./chunk-7OX2O53H.js";import{e as g,g as y,j as b}from"./chunk-5TT47UMX.js";function P(o,e,s,n){let r=g(e);if(!r)return!0;let i=b(o,e);if(!i)return!0;let a=S.get(i);return a||(a=N(i,r),S.set(i,a)),a.get(`${s}:${n}`)??!0}var S=new WeakMap;function N(o,e){let s=y(e),n=new Map,r=i=>{s.has(i.type)&&n.set(`${i.startPosition.row}:${i.endPosition.row}`,w(i,e));for(let a of i.children)r(a)};return r(o.rootNode),n}function w(o,e){let s=o.namedChildren.find(t=>t.type==="block"||t.type==="statement_block");if(!s)return!1;let n=s.namedChildren.filter(t=>t.type!=="comment"&&t.type!=="line_comment"&&t.type!=="block_comment");if(n.length!==1)return!1;let r=n[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 l=i.namedChildren.find(t=>t.type==="arguments"||t.type==="argument_list");if(!l)return!1;let d=l.namedChildren.filter(t=>t.type!=="comment"),p=o.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters");if(!p)return!1;let u=[];for(let t of p.namedChildren)if(t.type==="identifier")u.push(t.text);else{let f=t.namedChildren.find(T=>T.type==="identifier");f&&u.push(f.text)}if(d.length!==u.length)return!1;for(let t=0;t<u.length;t+=1){let f=d[t];if(f.type!=="identifier"||f.text!==u[t])return!1}return!0}function $(o,e){let{scope:s,maxLoc:n=15,limit:r=30,scanLimit:i}=e??{},a=new h(o);return C({candidates:()=>A(a,s,n),orderCandidates:L,scanLimit:i,prepare:l=>a.calleeMap(l,{semantic:e?.semantic!==!1}),evaluate:(l,d)=>_(o,l,d.get(l.symbolId)??[]),orderResults:(l,d)=>l.loc-d.loc||l.file.localeCompare(d.file),limit:r})}function _(o,e,s){let n=D(s);if(n.size!==1||!P(o,e.relativePath,e.startLine,e.endLine))return null;let[,r]=[...n.entries()][0];return{symbol:e.symbol,shortName:m(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:x(e),forwardsTo:r.symbol,forwardsToShort:m(r.symbol),forwardsToFile:r.file}}function D(o){let e=o.some(n=>c(n.symbol))?o.filter(n=>c(n.symbol)):o,s=new Map;for(let n of e)s.has(n.symbol)||s.set(n.symbol,n);return s}function A(o,e,s){return o.productionCallableDefinitions({scope:e,minLoc:3,maxLoc:s,requireFunctionLikeSymbol:!0,excludeRustTraitImplMembers:!0})}export{$ as a};
|
|
2
|
-
//# sourceMappingURL=chunk-3GNFUVFA.js.map
|
package/dist/chunk-5TT47UMX.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import{a as w,c as k}from"./chunk-NHDPYW7O.js";import{existsSync as I,readFileSync as O}from"fs";import{join as B}from"path";var C=w("source-text");function y(e,n){let t=n.replace(/\\/g,"/");return C.get(e,t,()=>{let r=B(e.config.projectRoot,t);return I(r)?O(r,"utf-8"):""})}function pe(e){C.invalidateAll(e)}function fe(e,n){C.invalidate(e,n.replace(/\\/g,"/"))}var W=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale|wrapper|passthrough|drift|extract)?/i;function de(e,n,t){if(t<=0)return!1;let r=y(e,n);if(!r)return!1;let c=r.split(`
|
|
2
|
-
`);for(let a=t-1;a>=0&&a>=t-5;a-=1){let s=(c[a]??"").trim();if(s!==""){if(W.test(s))return!0;if(!s.startsWith("//")&&!s.startsWith("*")&&!s.startsWith("/*")&&!s.startsWith("@")&&!s.startsWith("#"))return!1}}return!1}import{extname as v}from"path";var F={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb"};function d(e){return F[v(e).toLowerCase()]??null}function S(e){return v(e).toLowerCase()===".vue"}import{createRequire as Y}from"module";var f=Y(import.meta.url),_=null,j=!1;function P(){if(j)return null;if(_)return _;try{return _=f("tree-sitter"),_}catch{return j=!0,null}}var E=new Map,A=new Set;function Q(e){if(A.has(e))return null;let n=E.get(e);if(n)return n;let t;try{switch(e){case"rust":t=f("tree-sitter-rust");break;case"typescript":t=f("tree-sitter-typescript").typescript;break;case"tsx":t=f("tree-sitter-typescript").tsx;break;case"javascript":t=f("tree-sitter-javascript");break;case"python":t=f("tree-sitter-python");break;case"java":t=f("tree-sitter-java");break;case"kotlin":t=f("tree-sitter-kotlin");break;case"scala":t=f("tree-sitter-scala");break;case"ruby":t=f("tree-sitter-ruby");break;case"c":t=f("tree-sitter-c");break;case"cpp":t=f("tree-sitter-cpp");break;case"csharp":t=f("tree-sitter-c-sharp");break;case"php":t=f("tree-sitter-php").php;break;case"vb":{let r=f("tree-sitter-vb-dotnet");t=r.language??r;break}}}catch{return A.add(e),null}return E.set(e,t),t}var N=new Map;function V(e){let n=N.get(e);if(n)return n;let t=Q(e);if(!t)return null;let r=P();if(!r)return null;let c=new r;try{c.setLanguage(t)}catch{return A.add(e),null}return N.set(e,c),c}function U(e,n){return e.parse(r=>r>=n.length?null:n.slice(r,Math.min(n.length,r+16384)))}function L(e,n){let t=V(e);if(!t)return null;try{return U(t,n)}catch{return null}}var g=new Map;function D(e,n){let t=`${e}::${n}`;if(g.has(t))return g.get(t)??null;let r=Q(e);if(!r)return g.set(t,null),null;let c=P();if(!c)return g.set(t,null),null;try{let a=new c.Query(r,n);return g.set(t,a),a}catch{return g.set(t,null),null}}function R(e){let n=[],t=/<script\b([^>]*)>([\s\S]*?)<\/script>/g;for(let i of e.matchAll(t))typeof i.index=="number"&&n.push({tagOpen:i[1]??"",body:i[2]??"",openIdx:i.index+(i[0].length-(i[2]?.length??0)-9)});if(n.length===0)return null;let r=n.find(i=>/\bsetup\b/.test(i.tagOpen))??n[0],a=r.tagOpen.match(/\blang\s*=\s*["']?([\w-]+)/)?.[1]?.toLowerCase(),s=a==="ts"||a==="typescript"?"typescript":a==="tsx"?"tsx":"javascript";return{body:r.body,startLine:q(e,r.openIdx),language:s}}function q(e,n){let t=0;for(let r=0;r<n&&r<e.length;r++)e.charCodeAt(r)===10&&t++;return t}var h=k("ast-trees");function H(e){h.invalidateAll(e)}function G(e,n){h.invalidate(e,n)}function b(e,n){if(S(n))return z(e,n);let t=d(n);if(!t)return null;let r=y(e,n);return r?h.get(e,n,r,()=>L(t,r)):null}function z(e,n){let t=y(e,n);return t?h.get(e,n,t,()=>{let r=R(t);if(!r)return null;let c=`
|
|
3
|
-
`.repeat(r.startLine)+r.body;return L(r.language,c)}):null}var X={rust:`
|
|
4
|
-
(function_item name: (identifier) @name) @def
|
|
5
|
-
(function_signature_item name: (identifier) @name) @def
|
|
6
|
-
`,typescript:`
|
|
7
|
-
(function_declaration name: (identifier) @name) @def
|
|
8
|
-
(method_definition name: (property_identifier) @name) @def
|
|
9
|
-
(method_signature name: (property_identifier) @name) @def
|
|
10
|
-
(function_signature name: (identifier) @name) @def
|
|
11
|
-
(variable_declarator name: (identifier) @name value: (arrow_function)) @def
|
|
12
|
-
(variable_declarator name: (identifier) @name value: (function_expression)) @def
|
|
13
|
-
(public_field_definition name: (property_identifier) @name value: (arrow_function)) @def
|
|
14
|
-
`,tsx:`
|
|
15
|
-
(function_declaration name: (identifier) @name) @def
|
|
16
|
-
(method_definition name: (property_identifier) @name) @def
|
|
17
|
-
(method_signature name: (property_identifier) @name) @def
|
|
18
|
-
(function_signature name: (identifier) @name) @def
|
|
19
|
-
(variable_declarator name: (identifier) @name value: (arrow_function)) @def
|
|
20
|
-
(variable_declarator name: (identifier) @name value: (function_expression)) @def
|
|
21
|
-
(public_field_definition name: (property_identifier) @name value: (arrow_function)) @def
|
|
22
|
-
`,javascript:`
|
|
23
|
-
(function_declaration name: (identifier) @name) @def
|
|
24
|
-
(method_definition name: (property_identifier) @name) @def
|
|
25
|
-
(variable_declarator name: (identifier) @name value: (arrow_function)) @def
|
|
26
|
-
(variable_declarator name: (identifier) @name value: (function_expression)) @def
|
|
27
|
-
`,python:`
|
|
28
|
-
(function_definition name: (identifier) @name) @def
|
|
29
|
-
`},$=new WeakMap;function J(e,n){return T(e,n,$,X,t=>{let r=[];for(let c of t){let a=null,s=null;for(let i of c.captures)i.name==="name"?a=i.node.text:i.name==="def"&&(s={startLine:i.node.startPosition.row,endLine:i.node.endPosition.row});a&&s&&r.push({name:a,startLine:s.startLine,endLine:s.endLine})}return r})}var K={rust:`
|
|
30
|
-
(call_expression function: (_) @target) @call
|
|
31
|
-
(macro_invocation macro: (_) @target) @call
|
|
32
|
-
`,typescript:`
|
|
33
|
-
(call_expression function: (_) @target) @call
|
|
34
|
-
(new_expression constructor: (_) @target) @call
|
|
35
|
-
`,tsx:`
|
|
36
|
-
(call_expression function: (_) @target) @call
|
|
37
|
-
(new_expression constructor: (_) @target) @call
|
|
38
|
-
`,javascript:`
|
|
39
|
-
(call_expression function: (_) @target) @call
|
|
40
|
-
(new_expression constructor: (_) @target) @call
|
|
41
|
-
`,python:`
|
|
42
|
-
(call function: (_) @target) @call
|
|
43
|
-
`},Z=new WeakMap;function ee(e,n){return T(e,n,Z,K,t=>{let r=[];for(let c of t){let a=null,s=null;for(let o of c.captures)o.name==="target"?a=o.node:o.name==="call"&&(s=o.node);if(!a||!s)continue;let i=x(a);i&&r.push({calleeLeaf:i,memberAccess:te(a),line:s.startPosition.row})}return r})}function te(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}var ne=new WeakMap;function re(e,n){return M(e,n,ne,()=>new Map,(t,r,c)=>{let a=(o,l)=>{if(o===l)return;let u=c.get(o);u||(u=new Set,c.set(o,u)),u.add(l)},s=r==="python"?new Set(["identifier"]):new Set(["type_identifier"]),i=(o,l)=>{let u=p=>{s.has(p.type)&&p.text!==l&&a(p.text,l);for(let m of p.children)u(m)};for(let p of o.children)u(p)};if(r==="rust")for(let o of t.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let l=o.namedChildren.find(p=>p.type==="type_identifier")?.text;if(!l)continue;let u=o.namedChildren.find(p=>p.type==="field_declaration_list"||p.type==="enum_variant_list"||p.type==="ordered_field_declaration_list");u&&i(u,l),o.type==="type_item"&&i(o,l)}else if(r==="python")for(let o of t.rootNode.descendantsOfType("class_definition")){let l=o.namedChildren.find(p=>p.type==="identifier")?.text;if(!l)continue;let u=o.namedChildren.find(p=>p.type==="block");if(u)for(let p of u.descendantsOfType("type"))for(let m of p.descendantsOfType("identifier"))m.text!==l&&a(m.text,l)}else for(let o of t.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let l=o.namedChildren.find(u=>u.type==="type_identifier")?.text;l&&i(o,l)}})??new Map}function M(e,n,t,r,c){let a=d(n);if(!a)return null;let s=b(e,n);if(!s)return null;let i=t.get(s);if(i)return i;let o=r();return c(s,a,o),t.set(s,o),o}function T(e,n,t,r,c){let a=d(n);if(!a)return null;let s=r[a];if(!s)return null;let i=b(e,n);if(!i)return null;let o=t.get(i);if(o)return o;let l=D(a,s);if(!l)return null;let u=c(l.matches(i.rootNode));return t.set(i,u),u}function x(e){switch(e.type){case"identifier":case"type_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let n=e.namedChild(e.namedChildCount-1);return n?x(n):null}case"scoped_identifier":{let n=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return n?x(n):null}case"super":case"self":case"this":return null;default:return null}}var ae=new Set(["function_item","function_signature_item"]),ie=new Set(["function_definition"]),se=new Set(["function_declaration","method_definition","arrow_function","function_expression"]);function oe(e){switch(e){case"rust":return ae;case"python":return ie;default:return se}}export{y as a,pe as b,fe as c,de as d,d as e,S as f,oe as g,H as h,G as i,b as j,J as k,ee as l,re as m,M as n,x as o};
|
|
44
|
-
//# sourceMappingURL=chunk-5TT47UMX.js.map
|
package/dist/chunk-6H2XIIPY.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import we from"better-sqlite3";import{existsSync as Lt,readFileSync as It,writeFileSync as Ft}from"fs";import{dirname as Et,join as wt,resolve as Oe}from"path";import Q from"better-sqlite3";import{execFileSync as Z}from"child_process";import{existsSync as ee,readdirSync as te,readFileSync as ne}from"fs";import{extname as m,join as I}from"path";import G from"ignore";import{readFileSync as U,existsSync as b}from"fs";import{dirname as h,isAbsolute as V,join as S,relative as K,resolve as B}from"path";function k(e){let t=G(),r=!1,n=J(e);for(let o of n)try{let i=U(o,"utf-8");t.add(i),r=!0}catch{}return r||t.add(z),{isIgnored:o=>x(t,e,o),filter:o=>o.filter(i=>!x(t,e,i))}}function J(e){let t=[],r=S(e,".gitignore");b(r)&&t.push(r);let n=h(e),o=0;for(;n!==h(n)&&o<5;){let i=S(n,".gitignore");if(b(i)&&t.push(i),b(S(n,".git")))break;n=h(n),o++}return t}var z=`
|
|
2
|
-
# Dependencies
|
|
3
|
-
node_modules/
|
|
4
|
-
vendor/
|
|
5
|
-
.bundle/
|
|
6
|
-
|
|
7
|
-
# Build output
|
|
8
|
-
dist/
|
|
9
|
-
build/
|
|
10
|
-
out/
|
|
11
|
-
target/
|
|
12
|
-
bin/
|
|
13
|
-
obj/
|
|
14
|
-
|
|
15
|
-
# Python
|
|
16
|
-
__pycache__/
|
|
17
|
-
*.pyc
|
|
18
|
-
*.pyo
|
|
19
|
-
.venv/
|
|
20
|
-
venv/
|
|
21
|
-
.env/
|
|
22
|
-
env/
|
|
23
|
-
*.egg-info/
|
|
24
|
-
|
|
25
|
-
# Rust
|
|
26
|
-
target/
|
|
27
|
-
|
|
28
|
-
# Java / Kotlin / Scala
|
|
29
|
-
*.class
|
|
30
|
-
.gradle/
|
|
31
|
-
.mvn/
|
|
32
|
-
|
|
33
|
-
# C# / .NET
|
|
34
|
-
bin/
|
|
35
|
-
obj/
|
|
36
|
-
packages/
|
|
37
|
-
|
|
38
|
-
# Go
|
|
39
|
-
vendor/
|
|
40
|
-
|
|
41
|
-
# Dart
|
|
42
|
-
.dart_tool/
|
|
43
|
-
build/
|
|
44
|
-
|
|
45
|
-
# PHP
|
|
46
|
-
vendor/
|
|
47
|
-
|
|
48
|
-
# IDE / OS
|
|
49
|
-
.idea/
|
|
50
|
-
.vscode/
|
|
51
|
-
*.swp
|
|
52
|
-
*.swo
|
|
53
|
-
.DS_Store
|
|
54
|
-
Thumbs.db
|
|
55
|
-
|
|
56
|
-
# Type definitions (often noise in queries)
|
|
57
|
-
*.d.ts
|
|
58
|
-
`;function x(e,t,r){let n=X(t,r);if(!n)return!1;try{return e.ignores(n)}catch{return!1}}function X(e,t){if(!t||t===".")return null;if(!V(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let r=V(t)?t:B(e,t),n=K(e,r).replaceAll("\\","/");return!n||n==="."||n.startsWith("..")?null:n}import{readdirSync as Je}from"fs";import{extname as Xe,join as qe}from"path";function T(e){let t=new WeakMap,r=n=>{let o=t.get(n);return o||(o=new Map,t.set(n,o)),o};return{get(n,o,i){let s=r(n);if(s.has(o))return s.get(o);let a=i();return s.set(o,a),a},invalidate(n,o){t.get(n)?.delete(o)},invalidateAll(n){t.delete(n)},size(n){return t.get(n)?.size??0}}}var q=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],C=[".vue"],Y=new Set(q.map(e=>e.toLowerCase())),Qe=[...Y].sort().join(","),L=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);var Ze=T("source-files");function at(e){let t=new Set((e.extensions??C).map(i=>i.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!ee(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let r=k(e.projectRoot),n=re(e.projectRoot,t).filter(i=>!r.isIgnored(i)),o=new Q(e.dbPath);try{let i=ie(o,n),s=o.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
|
|
59
|
-
VALUES (?, ?, NULL, ?)`),u=o.transaction(l=>{let p=0;for(let g of l){if(i.has(g))continue;let d=ne(I(e.projectRoot,g),"utf-8"),H=s.run(se(g),g,d);p+=Number(H.changes)}return p})(n),c={scanned:n.length,inserted:u,existing:n.length-u};return e.onStatus?.(`Augmented SQLite documents with ${u} auxiliary source file${u===1?"":"s"} (${c.existing} already present).`),c}finally{o.close()}}function re(e,t){let r=oe(e,t);if(r)return r;let n=[],o=i=>{let s=i?I(e,i):e,a;try{a=te(s,{withFileTypes:!0})}catch{return}for(let u of a){if(L.has(u.name))continue;let c=i?`${i}/${u.name}`:u.name;if(u.isDirectory()){o(c);continue}t.has(m(u.name).toLowerCase())&&n.push(c)}};return o(""),n.sort()}function oe(e,t){try{return Z("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
|
|
60
|
-
`).filter(n=>n&&t.has(m(n).toLowerCase())).sort()}catch{return null}}function ie(e,t){let r=new Set,n=500;for(let o=0;o<t.length;o+=n){let i=t.slice(o,o+n),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${i.map(()=>"?").join(",")})`).all(...i);for(let a of s)r.add(a.relative_path)}return r}function se(e){return m(e).toLowerCase()===".vue"?"vue":m(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as ae}from"child_process";import{createHash as ue}from"crypto";import{readdirSync as ce,readFileSync as le}from"fs";import{join as F}from"path";function ge(e){return(de(e)??fe(e)).filter(t=>t&&!D(t)).sort()}function ft(e){return ge(e).map(t=>{let r=F(e,t);try{let n=le(r);return{path:t,size:n.byteLength,hash:ue("sha256").update(n).digest("hex")}}catch{return{path:t,size:-1,hash:"unreadable"}}})}function de(e){try{return ae("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
|
|
61
|
-
`).filter(Boolean)}catch{return null}}function fe(e){let t=[],r=[""];for(;r.length>0;){let n=r.pop(),o=n?F(e,n):e,i;try{i=ce(o,{withFileTypes:!0})}catch{continue}for(let s of i){let a=n?`${n}/${s.name}`:s.name;if(s.isDirectory()){D(a)||r.push(a);continue}t.push(a)}}return t}function D(e){return e.split("/").some(r=>pe.has(r))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var pe=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{createRequire as me}from"module";import{existsSync as be,readFileSync as v}from"fs";import{dirname as E,extname as he,join as w,relative as Se,resolve as St}from"path";import{pathToFileURL as ye}from"url";function O(e,t){let{vueCore:r,ts:n,volarTs:o}=ve(e),{parsed:i,vueOptions:s}=Re(r,n,t),a=E(t),u=r.createVueLanguagePlugin(n,i.options,s,d=>d),c=Ve(r,n,u),l=xe(a,i),{languageServiceHost:p}=o.createLanguageServiceHost(n,n.sys,c,d=>d,l),g=n.createLanguageService(p);return{ts:n,language:c,languageService:g,fileNames:i.fileNames,configDir:a}}function ve(e){let t=me(ye(w(e,"package.json")).href);return{vueCore:y(t,"@vue/language-core",e),ts:y(t,"typescript",e),volarTs:y(t,"@volar/typescript",e)}}function Re(e,t,r){let n=t.readConfigFile(r,t.sys.readFile);if(n.error||!n.config)throw new Error(`Failed to read ${r}`);let i=e.createParsedCommandLine(t,t.sys,r).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(i.globalTypesPath=e.createGlobalTypesWriter(i,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(n.config,t.sys,E(r),void 0,r,void 0,e.getAllExtensions(i).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:i}}function Ve(e,t,r){let n={},o=e.createLanguage([r],new Map,i=>{if(!be(i))return;let s=v(i,"utf-8");n.current?.scripts.set(i,t.ScriptSnapshot.fromString(s),r.getLanguageId(i)??Le(i))});return n.current=o,o}function xe(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function y(e,t,r){try{return e(t)}catch(n){throw(typeof n=="object"&&n!==null&&"code"in n?n.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${r}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:n}):n}}function A(e,t,r){let n=ke(e);return o=>{let i=f(t,o.fileName),s=r.get(o.fileName);if(!s)return null;let a=r.positionAt(s,o.textSpan.start),u=n.get(i);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:Te(u.starts,a.line,2)}}function ke(e){let t=e.prepare(`
|
|
62
|
-
SELECT
|
|
63
|
-
d.relative_path AS relativePath,
|
|
64
|
-
der.start_line AS startLine,
|
|
65
|
-
der.end_line AS endLine,
|
|
66
|
-
der.symbol_id AS symbolId
|
|
67
|
-
FROM defn_enclosing_ranges der
|
|
68
|
-
JOIN documents d ON d.id = der.document_id
|
|
69
|
-
ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
|
|
70
|
-
`).all(),r=new Map;for(let n of t){let o=r.get(n.relativePath);o||(o={containingByLine:new Map,starts:[]},r.set(n.relativePath,o)),o.starts.push({line:n.startLine,symbolId:n.symbolId});for(let i=n.startLine;i<=n.endLine;i++)o.containingByLine.set(i,n.symbolId)}for(let n of r.values())n.starts.sort((o,i)=>o.line-i.line);return r}function Te(e,t,r){let n=0,o=e.length-1;for(;n<=o;){let s=Math.floor((n+o)/2);e[s].line<t?n=s+1:o=s-1}let i=null;for(let s of[o,n]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-t);u>r||(!i||u<i.distance)&&(i={distance:u,symbolId:a.symbolId})}return i?.symbolId??null}function N(e,t){let r=Fe(t),n=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=new Map;return{get(i){if(o.has(i))return o.get(i)??null;let s=De(n,r,t,i);return o.set(i,s),s}}}function P(e,t,r,n,o){if(e.fileName.endsWith(".vue")){let i=n.language.scripts.get(e.fileName),s=i?.generated?.languagePlugin.typescript?.getServiceScript(i.generated.root)?.code;if(i&&s){let a=n.language.maps.get(s,i);if(R(a,e.textSpan.start)!==null)return r.get(e.fileName)}return e.fileName.startsWith(o)?r.get(e.fileName):null}return t(e)}function*M(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,r=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),n;for(;n=t.exec(e);){let o=n[0];r.has(o)||(yield{text:o,start:n.index,end:n.index+o.length})}}function _(e,t){for(let[r]of e.toGeneratedLocation(t,n=>!!n.navigation))return r;return null}function R(e,t){let r=e;for(let[n]of r.toSourceLocation(t,o=>!!o.navigation))return n;return null}function Ce(e,t){let r=0,n=e.lineStarts.length-1;for(;r<=n;){let i=Math.floor((r+n)/2);e.lineStarts[i]<=t?r=i+1:n=i-1}let o=Math.max(0,n);return{line:o,character:t-e.lineStarts[o]}}function j(e,t){return f(e,t).startsWith("node_modules/")}function f(e,t){return Se(e,t).replaceAll("\\","/")}function Le(e){switch(he(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function $(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let r=v(t,"utf-8"),n={text:r,lineStarts:Ie(r)};return e.set(t,n),n}catch{return e.set(t,null),null}},positionAt:Ce}}function Ie(e){let t=[0];for(let r=0;r<e.length;r++)e.charCodeAt(r)===10&&t.push(r+1);return t}function Fe(e){try{let t=JSON.parse(v(w(e,"package.json"),"utf-8"));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function De(e,t,r,n){let o=f(r,n),i=Ee(t.name,t.version,o);return e.get(i)?.id??null}function Ee(e,t,r){let n=r.split("/").map(o=>`\`${o.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${n}/default.`}function At(e){let t=Oe(e.projectRoot,e.tsconfig),r=O(e.projectRoot,t),n=new we(e.dbPath,{readonly:!0});try{let o=$();return Ae({projectRoot:e.projectRoot,vueFiles:e.vueFiles??[],tasks:e.tasks,context:r,symbolLookup:A(n,e.projectRoot,o),vueSymbolLookup:N(n,e.projectRoot),sourceReader:o})}finally{n.close()}}function Ae(e){let t=[],r=0,n=e.tasks??e.vueFiles.map(o=>({fileName:o,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let o of n){let i=Ne(e,o);t.push(...i.occurrences),r+=i.skippedReferences}return{occurrences:t,skippedReferences:r}}function Ne(e,t){let r=e.context.language.scripts.get(t.fileName),n=r?.generated?.languagePlugin.typescript?.getServiceScript(r.generated.root)?.code;if(!r||!n)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let o=e.sourceReader.get(t.fileName);if(!o)return{occurrences:[],skippedReferences:t.countFileSkip?1:0};let i=e.context.language.maps.get(n,r),s=f(e.projectRoot,t.fileName),a=[...M(o.text)],u={tokens:a.filter(c=>c.start>=t.startOffset&&c.start<t.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:_e(a),processedStarts:new Set};return Pe({...e,fileName:t.fileName,sourceInfo:o,sourceFile:s,map:i,tokenContext:u})}function Pe(e){let t=[],r=0;for(let n of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(n.start))continue;let o=_(e.map,n.start);if(o===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,o+1)??[]).find(u=>!j(e.projectRoot,u.fileName));if(!s){r++;continue}let a=P(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){r++;continue}W(t,e.sourceReader,e.sourceInfo,e.sourceFile,n,a),e.tokenContext.processedStarts.add(n.start),Me(t,e,n,o,a)}return{occurrences:t,skippedReferences:r}}function Me(e,t,r,n,o){if(!((t.tokenContext.tokenTextCounts.get(r.text)??0)<=1))for(let i of je(t.context.languageService,t.fileName,n+1,t.map,r,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(i))continue;let s=t.tokenContext.tokenByStart.get(i);s&&(W(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,o),t.tokenContext.processedStarts.add(i))}}function W(e,t,r,n,o,i){let s=t.positionAt(r,o.start);e.push({sourceFile:n,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+o.text.length,symbolId:i})}function _e(e){let t=new Map;for(let r of e)t.set(r.text,(t.get(r.text)??0)+1);return t}function je(e,t,r,n,o,i){let s=e.getDocumentHighlights?.(t,r,[t])??[],a=[];for(let u of s)if(u.fileName===t)for(let c of u.highlightSpans){let l=$e(n,c.textSpan.start,i,o.text);l!==null&&a.push(l)}return a}function $e(e,t,r,n){let o=r.get(t);if(o?.text===n)return o.start;let i=R(e,t);if(i===null)return null;let s=r.get(i);return s?.text===n?s.start:null}export{at as a,ft as b,At as c};
|
|
71
|
-
//# sourceMappingURL=chunk-6H2XIIPY.js.map
|
package/dist/chunk-7H4RJ4MC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./chunk-OHEIZWIA.js";import{a as v}from"./chunk-AQYBOORI.js";import{a as R}from"./chunk-TRNAQABL.js";import{d as w}from"./chunk-JTXKS5GK.js";import{a as L}from"./chunk-3GNFUVFA.js";import{b as x}from"./chunk-NYEMZHUC.js";import{a as S}from"./chunk-A2AVLALL.js";import{a as b}from"./chunk-NSTZMBAB.js";import{a as C}from"./chunk-XO6R3X5J.js";import{a as g}from"./chunk-FD37DBTD.js";import{a as H}from"./chunk-BI4F6GXI.js";import{a as d,b as y}from"./chunk-D6Z67MZL.js";import{e as u,f as l}from"./chunk-NKJKI6SE.js";function m(t){let e=z(t);return{score:I(t),overview:{documents:t.statsResult.documents,symbols:t.statsResult.symbols,indexSizeBytes:t.statsResult.indexSizeBytes},findings:{deadSymbols:t.dead.count,deadLoc:t.dead.loc,isolatedSymbols:t.isolated.count,isolatedLoc:t.isolated.loc,cycles:t.realCycleCount,similarPairs:t.similarCount,extractionCandidates:t.extractCount,wrappers:t.wrappers.count,passthroughs:t.passthroughs.count,staleTypes:t.stale.count,driftedFiles:t.drift.count,complexityHotspotCount:t.complexity.extremeCount},actions:e,topComplexity:t.complexity.top,warnings:t.warnings.length>0?t.warnings:void 0}}function z(t){let e=[];if(t.dead.count>0&&e.push({category:"Dead code",description:`${t.dead.count} symbols with zero references anywhere \u2014 safe to delete`,effort:"low",impact:"high",count:t.dead.count,locRecoverable:t.dead.loc}),t.isolated.count>0&&e.push({category:"Isolated symbols",description:`${t.isolated.count} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:t.isolated.count,locRecoverable:t.isolated.loc}),t.realCycleCount>0&&e.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.similarCount>0&&e.push({category:"Similar functions",description:`${t.similarCount} pairs with real logic overlap (beyond shared imports) \u2014 consolidation candidates`,effort:"medium",impact:"medium",count:t.similarCount,locRecoverable:0}),t.extractCount>0&&e.push({category:"Extraction candidates",description:`${t.extractCount} large functions with isolated callee clusters \u2014 extract method opportunities`,effort:"medium",impact:"medium",count:t.extractCount,locRecoverable:0}),t.wrappers.count>0&&e.push({category:"Wrapper functions",description:`${t.wrappers.count} single-consumer symbols that could be inlined`,effort:"low",impact:"low",count:t.wrappers.count,locRecoverable:t.wrappers.loc}),t.passthroughs.count>0&&e.push({category:"Passthrough functions",description:`${t.passthroughs.count} functions that just forward to one callee \u2014 unnecessary indirection`,effort:"low",impact:"low",count:t.passthroughs.count,locRecoverable:t.passthroughs.loc}),t.stale.count>0){let i=[];t.stale.unused>0&&i.push(`${t.stale.unused} unused`),t.stale.singleUse>0&&i.push(`${t.stale.singleUse} single-consumer (not in types file)`),e.push({category:"Stale abstractions",description:`${i.join(", ")} \u2014 premature abstraction`,effort:"low",impact:"medium",count:t.stale.count,locRecoverable:t.stale.loc})}if(t.drift.count>0){let i=[];t.drift.unusedImports>0&&i.push(`${t.drift.unusedImports} unused imports`),t.drift.layerViolations>0&&i.push(`${t.drift.layerViolations} layer violations`),e.push({category:"Structural drift",description:i.join(", "),effort:t.drift.layerViolations>0?"medium":"low",impact:t.drift.layerViolations>0?"medium":"low",count:t.drift.count,locRecoverable:0})}let a={high:3,medium:2,low:1},r={low:3,medium:2,high:1};return e.sort((i,n)=>{let c=a[i.impact]*r[i.effort];return a[n.impact]*r[n.effort]-c}),e}function I(t){let e=Math.max(t.statsResult.documents,1),a=Math.max(t.statsResult.symbols,1),r=100,i=t.dead.count/a;r-=Math.min(20,Math.round(i*200));let n=t.isolated.count/a;r-=Math.min(10,Math.round(n*200)),r-=Math.min(15,t.realCycleCount*5);let c=t.similarCount/a*1e3;r-=Math.min(10,Math.round(c));let f=t.extractCount/a*1e3;r-=Math.min(5,Math.round(f/2)),r-=Math.min(3,t.wrappers.count),r-=Math.min(3,t.passthroughs.count);let M=t.stale.count/Math.max(a*.1,1);r-=Math.min(8,Math.round(M*10));let _=t.drift.count/e;return r-=Math.min(5,Math.round(_*50)),r-=Math.min(5,t.complexity.extremeCount*2),Math.max(0,Math.min(100,r))}import{getHeapStatistics as $}from"v8";var N=64*1024*1024;function h(){let t=globalThis.gc;if(!t)return;let e=$();e.heap_size_limit-e.used_heap_size<N||t()}var O=50,j=75e3,U=5e3,E=2500,V=["overview","dead","isolated","cycles","similar","extract-candidates","wrapper-candidates","passthrough-candidates","stale-abstractions","drift","complexity-hotspots"],A={overview:(t,e,a,r)=>({phase:"overview",statsResult:r,warnings:a.warnings}),dead:(t,e,a)=>({phase:"dead",dead:G(t,e,a)}),isolated:(t,e,a)=>({phase:"isolated",isolated:F(t,e,a)}),cycles:(t,e,a)=>({phase:"cycles",realCycleCount:W(t,e,a)}),similar:(t,e,a)=>({phase:"similar",similarCount:q(t,e,a)}),"extract-candidates":(t,e,a)=>({phase:"extract-candidates",extractCount:Y(t,e,a)}),"wrapper-candidates":(t,e,a)=>({phase:"wrapper-candidates",wrappers:Q(t,e,a)}),"passthrough-candidates":(t,e,a)=>({phase:"passthrough-candidates",passthroughs:X(t,e,a)}),"stale-abstractions":(t,e,a)=>({phase:"stale-abstractions",stale:J(t,e,a)}),drift:(t,e,a)=>({phase:"drift",drift:K(t,e,a)}),"complexity-hotspots":(t,e,a)=>({phase:"complexity-hotspots",complexity:Z(t,e,a)})};function Rt(t,e={}){return T(t,e.full===!0,(a,r)=>{let i=k(t,e.scope,a,r);return m(i)})}function Lt(t,e,a={}){return T(t,a.full===!0,(r,i)=>A[e](t,a.scope,i,r))}function T(t,e,a){let r=v(t),i=tt(r,e);try{return a(r,i)}finally{d(t,{semanticProvider:!0}),h()}}function Pt(t){return m(D(t))}function D(t){let e=o(t,"overview");return{statsResult:e.statsResult,warnings:e.warnings,dead:o(t,"dead").dead,isolated:o(t,"isolated").isolated,realCycleCount:o(t,"cycles").realCycleCount,similarCount:o(t,"similar").similarCount,extractCount:o(t,"extract-candidates").extractCount,wrappers:o(t,"wrapper-candidates").wrappers,passthroughs:o(t,"passthrough-candidates").passthroughs,stale:o(t,"stale-abstractions").stale,drift:o(t,"drift").drift,complexity:o(t,"complexity-hotspots").complexity}}function o(t,e){let a=t.find(r=>r.phase===e);if(!a)throw new Error(`Missing health phase result: ${e}`);return a}function k(t,e,a,r){return D(V.map(i=>A[i](t,e,r,a)))}function G(t,e,a){return s(t,a,"dead",()=>{let r=y(t,{scope:e,minLoc:3,skipBarrels:!0,deadCodeOnly:!0,scanLimit:a.candidateScanLimit,semantic:!1});return p(rt(t,r.symbols))})}function F(t,e,a){return s(t,a,"isolated",()=>{let r=S(t,{scope:e,minLoc:3,scanLimit:a.candidateScanLimit,semantic:!1});return p(it(t,r))})}function W(t,e,a){return s(t,a,"cycles",()=>H(t,{scope:e}).filter(i=>i.kind==="real").length)}function q(t,e,a){return s(t,a,"similar",()=>x(t,{scope:e,minSimilarity:.6,limit:50,minCallees:4,scanLimit:a.candidateScanLimit,semantic:!1}).length)}function Y(t,e,a){return s(t,a,"extract-candidates",()=>C(t,{scope:e,minLoc:15,minCallees:5,limit:50,scanLimit:a.candidateScanLimit,semantic:!1}).length)}function Q(t,e,a){return B(t,a,"wrapper-candidates",()=>R(t,{scope:e,maxLoc:15,limit:50,scanLimit:a.candidateScanLimit,semantic:!1}))}function X(t,e,a){return B(t,a,"passthrough-candidates",()=>L(t,{scope:e,maxLoc:15,limit:50,scanLimit:a.candidateScanLimit,semantic:!1}))}function J(t,e,a){return s(t,a,"stale-abstractions",()=>{let r=P(t,{scope:e,minLoc:3,limit:50,scanLimit:a.candidateScanLimit,semantic:!1}),i=r.filter(n=>n.consumers===0).length;return{count:r.length,loc:r.reduce((n,c)=>n+c.loc,0),unused:i,singleUse:r.length-i}})}function K(t,e,a){return s(t,a,"drift",()=>{let r=b(t,{scope:e,semantic:!1});return{count:r.unusedImports+r.layerViolations,unusedImports:r.unusedImports,layerViolations:r.layerViolations}})}function Z(t,e,a){return s(t,a,"complexity-hotspots",()=>{let r=g(t,{scope:e,minLoc:10,limit:10,scanLimit:a.candidateScanLimit,semantic:!1});return{top:r.slice(0,5).map(i=>({symbol:i.shortName,score:i.score})),extremeCount:r.filter(i=>i.score>O).length}})}function tt(t,e){return t.symbols>=j||t.documents>=U?e?{candidateScanLimit:void 0,releaseCachesBetweenPhases:!0,warnings:["Large index detected; running unbounded health analyses because --full was supplied."]}:{candidateScanLimit:E,releaseCachesBetweenPhases:!0,warnings:[`Large index detected; candidate-style health checks scanned their highest-priority ${E} symbols. Run "scip-query health --full" for unbounded candidate counts.`]}:{candidateScanLimit:void 0,releaseCachesBetweenPhases:!0,warnings:[]}}function et(t,e){e.releaseCachesBetweenPhases&&(w(t),d(t),h())}function s(t,e,a,r){at(a);try{return r()}finally{et(t,e)}}function B(t,e,a,r){return s(t,e,a,()=>p(r()))}function at(t){process.env.SCIP_QUERY_HEALTH_TRACE==="1"&&console.error(`[health] ${t}`)}function rt(t,e){return e.filter(a=>!u(t,a.relativePath)&&!l(t,a.symbol,a.relativePath)&&a.kind==="dead-code")}function it(t,e){return e.filter(a=>!u(t,a.relativePath)&&!l(t,a.symbol,a.relativePath))}function p(t){return{count:t.length,loc:t.reduce((e,a)=>e+a.loc,0)}}export{V as a,Rt as b,Lt as c,Pt as d};
|
|
2
|
-
//# sourceMappingURL=chunk-7H4RJ4MC.js.map
|
package/dist/chunk-7O4MJYIW.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import{l as T}from"./chunk-BOVNTAKQ.js";import{d as N,s as k}from"./chunk-7OX2O53H.js";import{a as x}from"./chunk-NN3O7TPH.js";function p(i,e,t){if(i.has(e))return i.get(e);let n=t();return i.set(e,n),n}import _ from"path";function oe(i,e){return i.getReferences().map(t=>{let n=t.getNode();return $(n,e)})}function se(i){let e=i;return typeof e.findReferences=="function"?e.findReferences():[]}function U(i,e,t,n){let r=[];for(let o of se(i))for(let s of oe(o,n))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||r.push(s);for(let o of t)r.push(o);return E(r)}function W(i,e,t,n){let r=[],o=t?.getStart();for(let s of i.getReferences()){let a=s.getNode();y(n,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||r.push({location:$(a,n),node:a}))}return r}function $(i,e){let t=i.getSourceFile(),n=t.getLineAndColumnAtPos(i.getStart());return{file:y(e,t.getFilePath())??t.getBaseName(),line:n.line-1,column:n.column-1}}function B(i,e,t){let n=i.getSourceFile(),r=g(n,i),o=i.getText(),s=new RegExp(`\\b${ae(o)}\\b`,"g"),a=n.getFullText().split(`
|
|
2
|
-
`),l=[];for(let c=0;c<a.length;c++){if(c===r)continue;let f=a[c]??"";s.lastIndex=0;let u;for(;(u=s.exec(f))!==null;)l.push({file:e,line:c,column:u.index})}return E(l.filter(c=>y(t,_.join(t,c.file))===e))}function P(i){for(let e=i;e;e=e.getParent()){let t=e.getKindName();if(t.includes("Type")||t==="InterfaceDeclaration"||t==="TypeAliasDeclaration")return!0;if(t==="CallExpression"||t==="NewExpression"||t==="ExpressionStatement")return!1}return!1}function g(i,e){return i.getLineAndColumnAtPos(e.getStart()).line-1}function E(i){let e=new Set,t=[];for(let n of i){let r=`${n.file}:${n.line}:${n.column}`;e.has(r)||(e.add(r),t.push(n))}return t}function y(i,e){let t=_.relative(i||process.cwd(),e).replace(/\\/g,"/");return!t||t.startsWith("..")?null:t}function ae(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function H(i,e,t,n){let r=ce(e,n);return r.size===0?new Map:le(i,t,r)}function ce(i,e){let t=new Map;for(let n of k(i,e)){let r=N(n.symbol)??n.leaf;if(!r)continue;let o=t.get(r);o||(o=[],t.set(r,o)),o.push(n)}return t}function le(i,e,t){let n=new Map,r=new Map;return e.forEachDescendant(o=>{for(let s of de(i,o)){let a=t.get(s);if(!a)continue;let l=g(e,o);for(let c of a){if(l<c.startLine-1||l>c.endLine+1)continue;let f=Math.abs(l-c.startLine),u=r.get(c.symbolId);u!==void 0&&u<=f||(r.set(c.symbolId,f),n.set(c.symbolId,o))}}}),n}function de(i,e){let t=[],n=r=>{r&&!t.includes(r)&&t.push(r)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let r=e.getNameNode();n(r?.getText())}if("getName"in e&&typeof e.getName=="function"){let r=e.getName();n(r)}return i.Node.isIdentifier(e)&&n(e.getText()),t}function J(i,e,t,n){return i.all(`SELECT
|
|
3
|
-
gs.id AS symbolId,
|
|
4
|
-
gs.symbol,
|
|
5
|
-
d.relative_path AS relativePath,
|
|
6
|
-
COALESCE(der.start_line, c.start_line) AS startLine,
|
|
7
|
-
COALESCE(der.end_line, c.end_line) AS endLine,
|
|
8
|
-
COALESCE(gs.display_name, '') AS leaf,
|
|
9
|
-
NULL AS parentTypeName,
|
|
10
|
-
CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
|
|
11
|
-
CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
|
|
12
|
-
gs.kind AS kind,
|
|
13
|
-
gs.documentation AS documentation,
|
|
14
|
-
gs.enclosing_symbol AS enclosingSymbol
|
|
15
|
-
FROM global_symbols gs
|
|
16
|
-
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
17
|
-
LEFT JOIN chunks c ON c.document_id = der.document_id
|
|
18
|
-
JOIN documents d ON d.id = der.document_id
|
|
19
|
-
WHERE d.relative_path = ?
|
|
20
|
-
AND COALESCE(gs.display_name, gs.symbol) LIKE ?
|
|
21
|
-
ORDER BY ABS(COALESCE(der.start_line, c.start_line) - ?)
|
|
22
|
-
LIMIT 5`,e,`%${n}%`,t)[0]??null}function V(i,e){let t=i.all(`SELECT
|
|
23
|
-
d.id AS documentId,
|
|
24
|
-
gs.id AS symbolId,
|
|
25
|
-
gs.symbol,
|
|
26
|
-
d.relative_path AS relativePath,
|
|
27
|
-
der.start_line AS startLine,
|
|
28
|
-
der.end_line AS endLine,
|
|
29
|
-
COALESCE(gs.display_name, '') AS leaf,
|
|
30
|
-
NULL AS parentTypeName,
|
|
31
|
-
CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
|
|
32
|
-
CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
|
|
33
|
-
gs.kind AS kind,
|
|
34
|
-
gs.documentation AS documentation,
|
|
35
|
-
gs.enclosing_symbol AS enclosingSymbol
|
|
36
|
-
FROM global_symbols gs
|
|
37
|
-
JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
38
|
-
JOIN documents d ON d.id = der.document_id
|
|
39
|
-
WHERE d.relative_path = ?
|
|
40
|
-
UNION ALL
|
|
41
|
-
SELECT
|
|
42
|
-
d.id AS documentId,
|
|
43
|
-
gs.id AS symbolId,
|
|
44
|
-
gs.symbol,
|
|
45
|
-
d.relative_path AS relativePath,
|
|
46
|
-
MIN(c.start_line) AS startLine,
|
|
47
|
-
MAX(c.end_line) AS endLine,
|
|
48
|
-
COALESCE(gs.display_name, '') AS leaf,
|
|
49
|
-
NULL AS parentTypeName,
|
|
50
|
-
CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
|
|
51
|
-
CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
|
|
52
|
-
gs.kind AS kind,
|
|
53
|
-
gs.documentation AS documentation,
|
|
54
|
-
gs.enclosing_symbol AS enclosingSymbol
|
|
55
|
-
FROM global_symbols gs
|
|
56
|
-
JOIN mentions m ON m.symbol_id = gs.id
|
|
57
|
-
JOIN chunks c ON c.id = m.chunk_id
|
|
58
|
-
JOIN documents d ON d.id = c.document_id
|
|
59
|
-
WHERE d.relative_path = ?
|
|
60
|
-
AND m.role = 1
|
|
61
|
-
GROUP BY gs.id, gs.symbol, d.id, d.relative_path, gs.display_name, gs.kind, gs.documentation, gs.enclosing_symbol
|
|
62
|
-
ORDER BY startLine, endLine`,e,e),n=new Set,r=new Map;for(let o of t){if(n.has(o.symbolId))continue;n.add(o.symbolId);let s=o.leaf||N(o.symbol);!s||r.has(s)||r.set(s,{...o,leaf:s})}return r}import pe from"path";var S=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function D(i){let e=i.toLowerCase();return S.some(t=>e.endsWith(t))}function K(i,e){let t=new Map,n=r=>D(r)?p(t,r,()=>{let o=pe.join(i.config.projectRoot,r);for(let{project:s}of e){let a=s.getSourceFile(o)??s.addSourceFileAtPathIfExists(o)??null;if(a)return{project:s,sourceFile:a}}return null}):null;return{sourceFile:r=>n(r)?.sourceFile??null,sourceFileMatch:n,indexedTypeScriptLikeDocuments:()=>x(i,{extensions:S})}}import m from"path";import{existsSync as M,readdirSync as fe,readFileSync as z}from"fs";function Y(i){let e=m.join(i,"package.json");if(!M(e))return[];let t;try{t=JSON.parse(z(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(r=>ue(i,r)).flatMap(r=>me(i,r))}function ue(i,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=m.join(i,e);return M(m.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),r=e.slice(t+1).replace(/^\//,""),o=m.join(i,n||".");if(!M(o))return[];try{return fe(o).map(s=>m.join(o,s,r)).filter(s=>M(m.join(s,"package.json")))}catch{return[]}}function me(i,e){try{let t=JSON.parse(z(m.join(e,"package.json"),"utf8"));if(!t.name)return[];let n=m.relative(i,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:n,sourceRootRelative:`${n}/src`}]}catch{return[]}}function X(i,e){for(let t of i)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function q(i){return[`${i.sourceRootRelative}/index.ts`,`${i.sourceRootRelative}/index.tsx`,`${i.sourceRootRelative}/index.mts`,`${i.sourceRootRelative}/index.cts`]}import{existsSync as h,readFileSync as ge,readdirSync as ye,statSync as Se}from"fs";import d from"path";var R=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function C(i,e){let n=e?d.dirname(d.join(i,e)):i,r=d.resolve(i);for(;n.startsWith(r);){for(let s of R){let a=d.join(n,s);if(h(a))return a}let o=d.dirname(n);if(o===n)break;n=o}for(let o of R){let s=d.join(i,o);if(h(s))return s}return null}function G(i){let e=i.config.projectRoot,t=new Set(he(e,i.config.semantic?.typescript?.tsconfigs)),n=x(i,{includeIgnored:!1,extensions:S});for(let r of n){let o=C(e,r);o&&t.add(d.resolve(o))}if(t.size===0){let r=C(e);r&&t.add(d.resolve(r))}return[...t].filter(r=>!Q(e,r)).sort((r,o)=>r.localeCompare(o))}function he(i,e=[]){let t=new Set;for(let n of e){let r=d.isAbsolute(n)?n:d.join(i,n);h(r)&&t.add(d.resolve(r))}for(let n of be(i))for(let r of R){let o=d.join(n,r);h(o)&&t.add(d.resolve(o))}if(t.size===0){let n=C(i);n&&t.add(d.resolve(n))}return[...t].filter(n=>!Q(i,n)).sort((n,r)=>n.localeCompare(r))}function be(i){let e=d.join(i,"package.json");if(!h(e))return[];let t;try{t=JSON.parse(ge(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(r=>Ie(i,r))}function Ie(i,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=d.join(i,e);return L(s)?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),r=e.slice(t+1).replace(/^\//,""),o=d.join(i,n||".");return L(o)?ye(o).map(s=>d.join(o,s,r)).filter(L):[]}function L(i){try{return Se(i).isDirectory()}catch{return!1}}function Q(i,e){let t=d.relative(i,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}import{createRequire as xe}from"module";var Ne=xe(import.meta.url),b;function Z(){if(b!==void 0)return b;try{b=Ne("ts-morph")}catch{b=null}return b}function ee(i,e){return e.map(t=>({tsconfigPath:t,project:new i.Project({tsConfigFilePath:t,skipFileDependencyResolution:!1})}))}function F(i,e,t){return{language:"typescript",availability:()=>({available:!1,reason:i,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function ie(i,e){let t=Z();if(!t)return F("ts-morph is not installed");let n=G(i);if(n.length===0)return F("no tsconfig found");try{let r=ee(t,n);return new A(i,t,r)}catch(r){return F(r instanceof Error?r.message:String(r),n[0],n)}}var A=class{constructor(e,t,n){this.db=e;this.tsMorph=t;this.projects=n;this.workspacePackages=Y(e.config.projectRoot),this.sourceFiles=K(e,n)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return p(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let n=[];for(let r of t.getImportDeclarations())for(let o of this.importUsageForDeclaration(e,r))n.push(o);return n})}referencesFor(e){return p(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),n=this.packageImportReferencesForDefinition(e);return t?U(t,e,n,this.db.config.projectRoot):n})}calleesFor(e){return p(this.calleesCache,e.symbolId,()=>p(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}signatureFor(e){return p(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let n=t.getType().getCallSignatures()[0];if(!n)return null;let r=n.getParameters().map(s=>{let a=s.getDeclarations()[0],l=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return ne(l)}),o=n.getReturnType().getText(t);return`(${r.join(",")})=>${ne(o)}`})}importUsageForDeclaration(e,t){let n=T(this.db,e,t.getModuleSpecifierValue()),r=te(t);return t.getImportClause()?.isTypeOnly()?r.map(o=>ke(e,n,o)):r.map(o=>this.valueImportUsageForEntry(e,n,o))}valueImportUsageForEntry(e,t,n){let r=n.identifier?n.identifier.findReferences():[],o=[];for(let c of r)for(let f of W(c,e,n.identifier,this.db.config.projectRoot))o.push(f);let s=o.some(c=>!P(c.node)),a=o.some(c=>P(c.node)),l=n.isTypeOnly;return{importer:e,sourcePath:t,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:l,isUsed:l||o.length>0,isTypeUsed:l||a,isValueUsed:s,references:o.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let n of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,n);for(let[n,r]of e)e.set(n,E(r));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,n){if(this.db.isIgnored(n))return;let r=this.sourceFiles.sourceFileMatch(n);if(r)for(let o of r.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,n,o)}addPackageImportReferencesForDeclaration(e,t,n,r){let o=X(this.workspacePackages,r.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of te(r)){if(a.kind!=="named"||!a.identifier)continue;let l=s.get(a.importedName);if(!l||l.size===0)continue;let c=B(a.identifier,n,this.db.config.projectRoot);c.length>0&&Me(e,l,c)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let n=new Map;for(let r of q(t))this.collectPackageExports(t,r,n,new Set);n.size>0&&e.set(t.name,n)}return this.packageExportIndex=e,e}collectPackageExports(e,t,n,r){if(r.has(t))return;r.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),l=a?T(this.db,t,a):t;if(!l||!l.startsWith(`${e.sourceRootRelative}/`))continue;let c=s.getNamedExports();if(c.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,l,n,r);continue}for(let f of c){let u=f.getNameNode().getText(),w=f.getAliasNode()?.getText()??u,O=this.indexedDefinitionByLeaf(l,u);if(!O)continue;let I=n.get(w);I||(I=new Set,n.set(w,I)),I.add(O.symbolId)}}}indexedDefinitionByLeaf(e,t){return p(this.indexedDefinitionLeafCache,e,()=>V(this.db,e)).get(t)??null}nodeForDefinition(e){return p(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return p(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?H(this.tsMorph,this.db,t,e):new Map})}definitionFromSymbol(e){let t=e.getDeclarations();for(let n of t){let r=n.getSourceFile(),o=y(this.db.config.projectRoot,r.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=g(r,n),a=J(this.db,o,s,e.getName());if(a)return{symbol:a.symbol,file:a.relativePath,line:a.startLine}}return null}calleeMapForFile(e){let t=this.sourceFiles.sourceFile(e);if(!t)return new Map;let n=k(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(n.length===0)return new Map;let r=new Map;t.forEachDescendant(o=>{if(!this.tsMorph.Node.isCallExpression(o)&&!this.tsMorph.Node.isNewExpression(o))return;let s=this.semanticCalleeForCallNode(t,n,o);s&&Ee(r,s.callerId,s.target)});for(let[o,s]of r)r.set(o,Fe(s));return r}semanticCalleeForCallNode(e,t,n){let r=De(t,g(e,n));if(!r)return null;let o=n.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:r.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function te(i){let e=[],t=i.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:i.getImportClause()?.isTypeOnly()??!1});let n=i.getNamespaceImport();n&&e.push({identifier:n,importedName:"*",localName:n.getText(),kind:"namespace",isTypeOnly:i.getImportClause()?.isTypeOnly()??!1});for(let r of i.getNamedImports()){let o=r.getNameNode(),a=r.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:r.isTypeOnly()||(i.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function ke(i,e,t){return{importer:i,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function Ee(i,e,t){let n=i.get(e);n||(n=[],i.set(e,n)),n.push(t)}function De(i,e){let t=null;for(let n of i)e<n.startLine||e>n.endLine||(!t||n.startLine>=t.startLine)&&(t=n);return t}function Me(i,e,t){for(let n of e){let r=i.get(n)??[];r.push(...t),i.set(n,r)}}function Fe(i){let e=new Set,t=[];for(let n of i){let r=`${n.symbol}|${n.file}|${n.line}`;e.has(r)||(e.add(r),t.push(n))}return t}function ne(i){return i.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}var j=new WeakMap;function re(i,e){let t=`${i.config.projectRoot}:typescript-workspace`,n=j.get(i);n||(n=new Map,j.set(i,n));let r=n.get(t);if(r)return r;let o=ie(i,e);return n.set(t,o),o}function ft(i){j.delete(i)}function yt(i,e){let t=v(i,e);return t?t.importUsage(e):[]}function ve(i,e){let t=v(i,e.relativePath);return t?t.referencesFor(e):[]}function St(i,e){let t=new Map;for(let n of e)for(let r of ve(i,n)){if(r.file===n.relativePath||i.isIgnored(r.file))continue;let o=t.get(n.symbolId);o||(o=new Set,t.set(n.symbolId,o)),o.add(r.file)}return t}function ht(i,e){let t=new Map;for(let n of e){let r=v(i,n.relativePath);if(!r)continue;let o=r.calleesFor(n);o.length>0&&t.set(n.symbolId,o)}return t}function bt(i,e){let t=v(i,e.relativePath);return t?t.signatureFor(e):null}function v(i,e){if(!D(e))return null;let t=re(i,e);return t.availability().available?t:null}export{ft as a,yt as b,ve as c,St as d,ht as e,bt as f};
|
|
63
|
-
//# sourceMappingURL=chunk-7O4MJYIW.js.map
|