scip-query 0.10.10 → 0.10.11
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/dist/chunk-2KHTSEIL.js +102 -0
- package/dist/{chunk-CCKPYPDI.js → chunk-4UZO3XCV.js} +2 -2
- package/dist/{chunk-MMLZEGMS.js → chunk-54KGX7EX.js} +2 -2
- package/dist/{chunk-2VM46FC5.js → chunk-5GOLFJEO.js} +2 -2
- package/dist/chunk-5OST6GYB.js +2 -0
- package/dist/{chunk-2UYQLFVC.js → chunk-6GN7FXCH.js} +2 -2
- package/dist/{chunk-7UQWUVRG.js → chunk-6IR2AOBM.js} +2 -2
- package/dist/{chunk-QX7LLCGB.js → chunk-6JRV4MY2.js} +2 -2
- package/dist/{chunk-IPQTC36U.js → chunk-6LJHXREW.js} +2 -2
- package/dist/{chunk-CZ425R2B.js → chunk-6QSOCTZT.js} +2 -2
- package/dist/{chunk-RYXW3KRC.js → chunk-7B6LP46R.js} +2 -2
- package/dist/chunk-7GO4EQF5.js +2 -0
- package/dist/chunk-7IVSJJZU.js +7 -0
- package/dist/{chunk-56P7PDST.js → chunk-7TWLSZK5.js} +2 -2
- package/dist/{chunk-AW2QHPLL.js → chunk-AVWPHM2Q.js} +2 -2
- package/dist/{chunk-UYD7FJ3K.js → chunk-BASVXNY3.js} +2 -2
- package/dist/{chunk-XXZXDXTD.js → chunk-BFXPG2VN.js} +2 -2
- package/dist/{chunk-UWYJDBDW.js → chunk-CO5GJRP7.js} +2 -2
- package/dist/chunk-CW5YFOCP.js +5 -0
- package/dist/{chunk-7JRRXGVZ.js → chunk-E35O7UCB.js} +2 -2
- package/dist/{chunk-XIVO4SDZ.js → chunk-EXDQ35NN.js} +2 -2
- package/dist/{chunk-UFX7EPBA.js → chunk-EY43NV4M.js} +2 -2
- package/dist/{chunk-NZ4UDB5N.js → chunk-FFVIFETB.js} +2 -2
- package/dist/{chunk-UDGXK2WA.js → chunk-FKCGBZAC.js} +2 -2
- package/dist/{chunk-TL6QPNF5.js → chunk-FXNWFMKW.js} +2 -2
- package/dist/chunk-G5UPYQGL.js +4 -0
- package/dist/{chunk-Y6E3JHC4.js → chunk-GQBMH2TQ.js} +2 -2
- package/dist/{chunk-736BLPHR.js → chunk-IHUETYFW.js} +2 -2
- package/dist/{chunk-5VG7RKEF.js → chunk-JATUZIEH.js} +2 -2
- package/dist/chunk-JCLDUKT6.js +38 -0
- package/dist/{chunk-SGLLBSCV.js → chunk-JGN2ZFJR.js} +2 -2
- package/dist/{chunk-WG6KRH5F.js → chunk-JME7OWD3.js} +2 -2
- package/dist/{chunk-F6ICF7HL.js → chunk-KDFONWTW.js} +2 -2
- package/dist/{chunk-J7RWXLUL.js → chunk-LSET2TXH.js} +2 -2
- package/dist/{chunk-ZU6PROUY.js → chunk-M4COR2H6.js} +2 -2
- package/dist/{chunk-DQVKIG3D.js → chunk-NOJAM5ZV.js} +2 -2
- package/dist/{chunk-A6TANQNV.js → chunk-O6ZH6C6Y.js} +2 -2
- package/dist/chunk-OLTESY4K.js +3 -0
- package/dist/chunk-P4KYUPBD.js +4 -0
- package/dist/{chunk-Z4I7BVIU.js → chunk-P753MDDE.js} +2 -2
- package/dist/{chunk-6LNQOOTB.js → chunk-P7AL7Y37.js} +2 -2
- package/dist/{chunk-YWDVDAD7.js → chunk-QLAUCRDJ.js} +2 -2
- package/dist/{chunk-UQLFQLAF.js → chunk-RNM6LMCF.js} +2 -2
- package/dist/{chunk-PTQVNJ4Q.js → chunk-TK7O5ER5.js} +2 -2
- package/dist/chunk-TQ5W2H3S.js +4 -0
- package/dist/chunk-USPV3T5K.js +2 -0
- package/dist/{chunk-I46WR7MT.js → chunk-VCQYSG2M.js} +2 -2
- package/dist/{chunk-XSNRACLV.js → chunk-W6BVEKYC.js} +2 -2
- package/dist/{chunk-KX5PLFZ5.js → chunk-WUCEKFQC.js} +2 -2
- package/dist/{chunk-TH2N6QHW.js → chunk-Y5NBHMQX.js} +2 -2
- package/dist/{chunk-YBEEVDJQ.js → chunk-YCOFCT4B.js} +2 -2
- package/dist/{chunk-RXRLZFUL.js → chunk-YWYFU2V3.js} +2 -2
- package/dist/{chunk-5NVUWIAN.js → chunk-Z3YYR4OS.js} +2 -2
- package/dist/{chunk-ZQO43G2T.js → chunk-Z4HICZGY.js} +2 -2
- package/dist/{chunk-3DGD6NKW.js → chunk-ZQDIXAF5.js} +2 -2
- package/dist/cli.js +250 -247
- package/dist/index.js +1 -1
- 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.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +11 -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-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/docs/COMMAND_REFERENCE.md +1 -1
- package/package.json +1 -1
- package/skills/scip-hyper-optimization/SKILL.md +153 -24
- package/skills/scip-hyper-optimization/agents/openai.yaml +3 -3
- package/dist/chunk-3Q77KKEY.js +0 -2
- package/dist/chunk-4KTOV4QN.js +0 -3
- package/dist/chunk-4N4WONI4.js +0 -102
- package/dist/chunk-A6IDHNMC.js +0 -4
- package/dist/chunk-FRPEPTYJ.js +0 -5
- package/dist/chunk-GBEYTDY5.js +0 -2
- package/dist/chunk-PKMZCDQD.js +0 -4
- package/dist/chunk-QVI3NR7E.js +0 -7
- package/dist/chunk-SULEXAHO.js +0 -38
- package/dist/chunk-YGHUVQLR.js +0 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: scip-hyper-optimization
|
|
3
|
-
description: Run scientific performance optimization campaigns with scip-query evidence, command ledgers, and benchmark corpora. Use when the user asks to hyper optimize, make commands blazing fast, speed up a CLI/tool/app, benchmark regressions, or compare targeted tuning against radically different implementations.
|
|
3
|
+
description: Run scientific performance optimization campaigns with scip-query evidence, hierarchical profiling, command ledgers, and benchmark corpora. Use when the user asks to hyper optimize, make commands blazing fast, speed up a CLI/tool/app, find bottlenecks, benchmark regressions, optimize cold or warm paths, or compare targeted tuning against radically different implementations.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# SCIP Hyper Optimization
|
|
7
|
+
|
|
7
8
|
Use this skill to make a command, workflow, service, page, or tool as fast as
|
|
8
9
|
feasibly possible without changing its observable result. Hyper optimization is
|
|
9
10
|
a bounded campaign that improves runtime, memory use, or computational cost
|
|
@@ -12,9 +13,16 @@ benchmark and unchanged output.
|
|
|
12
13
|
|
|
13
14
|
A measurement harness is the repeatable set of commands, fixtures, corpora,
|
|
14
15
|
environment notes, and result documents used to decide whether performance
|
|
15
|
-
changed. A
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
changed. A run history is the durable time-series of those measurements: one
|
|
17
|
+
record per run, command, subprocess, or profiled stage, with enough metadata to
|
|
18
|
+
compare commits and draw charts later. A profile span is one named timed piece
|
|
19
|
+
of work inside the target process, such as input loading, cache reads, database
|
|
20
|
+
queries, graph traversal, rendering, or a child process. Hierarchical profiling
|
|
21
|
+
is using coarse spans to find the dominant stage, then recursively splitting
|
|
22
|
+
only that stage until the expensive operation is concrete enough to fix. A
|
|
23
|
+
command ledger is the living document for one target: what it returns, what code
|
|
24
|
+
runs, where time is spent, what was tried, and what evidence accepted or
|
|
25
|
+
rejected each idea.
|
|
18
26
|
|
|
19
27
|
## Rules
|
|
20
28
|
|
|
@@ -23,22 +31,43 @@ accepted or rejected each idea.
|
|
|
23
31
|
`call-graph`, `code`, `dataflow`, `complexity`, `diff-impact`, `diff-gate`.
|
|
24
32
|
3. Capture representative inputs, required output behavior, and correctness
|
|
25
33
|
checks before editing.
|
|
26
|
-
4.
|
|
27
|
-
|
|
28
|
-
5.
|
|
34
|
+
4. Record every benchmark in a machine-readable run history before and after
|
|
35
|
+
each optimization; Markdown summaries are secondary.
|
|
36
|
+
5. Measure cold-index, cold-cache or evidence-fill, warm steady-state, and
|
|
37
|
+
repeated focused paths separately when they can diverge.
|
|
38
|
+
6. Profile the target's internal chain before editing. A bare command duration
|
|
39
|
+
is enough to rank targets, not enough to choose a fix.
|
|
40
|
+
7. Treat profiling as a search algorithm: place coarse spans first, split the
|
|
41
|
+
biggest span, and stop descending only when the slow operation is identifiable
|
|
42
|
+
as a specific repeated lookup, initialization, scan, traversal, subprocess,
|
|
43
|
+
serialization step, or wait.
|
|
44
|
+
8. Attach counts to spans: files, rows, symbols, candidates, cache hits/misses,
|
|
45
|
+
subprocesses, bytes, edges, nodes, retries, and output rows. Time without
|
|
46
|
+
cardinality hides the cause.
|
|
47
|
+
9. Work both tracks: tune the current pipeline and evaluate radically different
|
|
29
48
|
algorithms or data models that preserve the same result.
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
10. Keep only changes that improve real workloads without reducing accuracy,
|
|
50
|
+
diagnostics, safety checks, or supported inputs.
|
|
51
|
+
|
|
52
|
+
## Phase 0: Target And Measurement Harness
|
|
32
53
|
|
|
33
|
-
## Phase 0: Measurement Harness
|
|
34
54
|
If the target repository is not already a reliable scip-query workspace, invoke
|
|
35
55
|
`scip-query-setup` first. Do not run setup-ci in this workflow.
|
|
36
56
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
Choose the optimization target explicitly. Use user-reported pain, production
|
|
58
|
+
telemetry, benchmark ranking, regression data, cost, frequency, or risk to
|
|
59
|
+
justify why this target comes first. Do not optimize the slowest thing by habit
|
|
60
|
+
if another path dominates real user time or compute spend.
|
|
61
|
+
|
|
62
|
+
Create or update a benchmark note and a run-history store before code changes.
|
|
63
|
+
Prefer the repo's existing convention; otherwise use
|
|
64
|
+
`docs/benchmarks/YYYY-MM-DD-<target>-baseline.md` and
|
|
65
|
+
`docs/benchmarks/runs/YYYY-MM-DD-<target>.jsonl`. Include target, machine/date
|
|
40
66
|
context, corpus or fixture list, cold/warm/correctness commands, baseline
|
|
41
|
-
timings, output-contract evidence, and slowest stages.
|
|
67
|
+
timings, output-contract evidence, and slowest stages. Append a structured run
|
|
68
|
+
record for each measurement with at least timestamp, commit/version, target,
|
|
69
|
+
corpus, scenario, command, duration, exit status, output hash or size, and
|
|
70
|
+
notes for outliers.
|
|
42
71
|
|
|
43
72
|
Choose the measurement mechanism from the target's real workload. For app
|
|
44
73
|
paths, use the app's benchmark, test, route smoke, build, profiler, load test,
|
|
@@ -51,13 +80,20 @@ scip-query bench --json
|
|
|
51
80
|
scip-query bench --json --cold-index --include-heavy --timeout-ms 600000
|
|
52
81
|
```
|
|
53
82
|
|
|
83
|
+
For long benchmark matrices, prefer progress output or incremental JSONL writes
|
|
84
|
+
so the current command, subprocess, elapsed time, and completed measurements are
|
|
85
|
+
visible while the run is still active and useful if interrupted.
|
|
86
|
+
|
|
54
87
|
## Phase 1: Command Ledger
|
|
88
|
+
|
|
55
89
|
Create one ledger per target:
|
|
56
90
|
`docs/benchmarks/YYYY-MM-DD-<target>-ledger.md`. Include Output Contract,
|
|
57
|
-
Current Pipeline,
|
|
58
|
-
|
|
91
|
+
Target Selection, Current Pipeline, Run History Location, Profile Spans,
|
|
92
|
+
Bottleneck Candidates, Measurements, Current-Pipeline Optimizations,
|
|
93
|
+
Alternative Designs, and Decisions.
|
|
59
94
|
|
|
60
95
|
## Phase 2: Trace Current Behavior
|
|
96
|
+
|
|
61
97
|
Trace the target end to end and write the actual path into the ledger:
|
|
62
98
|
|
|
63
99
|
```bash
|
|
@@ -72,26 +108,119 @@ scip-query complexity <hot-symbol>
|
|
|
72
108
|
scip-query change-surface <touched-file> --json --full
|
|
73
109
|
```
|
|
74
110
|
|
|
75
|
-
Record
|
|
76
|
-
|
|
111
|
+
Record the chain reaction from entry point to result: input parsing, option
|
|
112
|
+
resolution, subprocesses, lookups, database queries, graph traversal, source
|
|
113
|
+
scans, semantic calls, cache reads/writes, rendering, output serialization, and
|
|
114
|
+
verification. The trace should be concrete enough that each major step can be
|
|
115
|
+
timed as a profile span.
|
|
116
|
+
|
|
117
|
+
Before adding spans, use the trace to predict span boundaries. Good first spans
|
|
118
|
+
usually match the target's real pipeline nouns: load inputs, compute candidates,
|
|
119
|
+
read cache, compute misses, write cache, build graph, score, render, serialize,
|
|
120
|
+
and child process. Use `call-graph` to find nested helpers inside the slow
|
|
121
|
+
stage, `dataflow` to follow the expensive object or cache key, `refs` to learn
|
|
122
|
+
whether a suspected fix affects other paths, and `complexity` to avoid spending
|
|
123
|
+
the first profiling pass on low-risk glue.
|
|
124
|
+
|
|
125
|
+
## Phase 3: Profile The Timed Chain
|
|
126
|
+
|
|
127
|
+
Before editing, produce a stage profile for the selected target. Prefer existing
|
|
128
|
+
runtime profilers, tracing systems, structured logs, or benchmark hooks. If none
|
|
129
|
+
exist, add temporary or permanent instrumentation that names timed spans without
|
|
130
|
+
changing observable output. For CLIs and build tools, include child processes
|
|
131
|
+
and worker tasks; for services, include request handlers, database calls,
|
|
132
|
+
network calls, queue jobs, cache hits/misses, rendering, and serialization.
|
|
133
|
+
|
|
134
|
+
Use this discovery ladder:
|
|
135
|
+
|
|
136
|
+
1. Measure the target unprofiled so the user-facing baseline is real.
|
|
137
|
+
2. Measure it profiled once. If profiled and unprofiled times are close, the
|
|
138
|
+
profiler is diagnostic overhead, not the bottleneck. If profiling dominates,
|
|
139
|
+
fix the harness before trusting fine spans.
|
|
140
|
+
3. Measure distinct states separately: cold index, cold derived-cache/evidence
|
|
141
|
+
fill, warm cache hit, repeated focused run, and production-like mixed state.
|
|
142
|
+
4. Add coarse spans that cover the whole chain. If span time does not explain
|
|
143
|
+
wall time, look for uninstrumented child processes, async waits, I/O, process
|
|
144
|
+
startup, or profiler gaps.
|
|
145
|
+
5. Pick the largest span by wall time multiplied by real workload frequency.
|
|
146
|
+
Split only that span into child spans.
|
|
147
|
+
6. Repeat until a fixable operation appears: a repeated singleton creation, a
|
|
148
|
+
per-item lookup, a broad scan, a wrapper traversal, a cache miss storm, a
|
|
149
|
+
subprocess startup, a serialization step, or a wait.
|
|
150
|
+
7. Add cardinality metadata to every split: count of rows/files/symbols/nodes,
|
|
151
|
+
cache hits/misses, bytes, output rows, and skipped items.
|
|
152
|
+
8. Record the before profile in the ledger before touching code.
|
|
153
|
+
|
|
154
|
+
Write profile records to the run history with parent/child span names when
|
|
155
|
+
possible. Separate wall time from CPU time when the tools allow it. Mark cache
|
|
156
|
+
state explicitly: cold index, cold evidence/cache fill, warm cache hit, repeated
|
|
157
|
+
focused run, or production-like mixed state.
|
|
158
|
+
|
|
159
|
+
## Phase 4: Diagnose And Find Speedups
|
|
160
|
+
|
|
161
|
+
Classify the dominant span before choosing a fix:
|
|
162
|
+
|
|
163
|
+
| Profile shape | Likely cause | First fixes to test |
|
|
164
|
+
| ----------------------------------------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
165
|
+
| Cold path huge, warm path fast | Derived evidence/cache fill, expensive initialization, or cache invalidation | Persist the derived result, reuse compatible cache versions, batch cache fills, hoist initialization |
|
|
166
|
+
| Warm path still slow | Cache scan, query shape, deserialization, reshaping, rendering, or output size | Narrow query, add indexes, store compact payloads, stream or avoid repeated object shaping |
|
|
167
|
+
| Same expensive setup repeated across many files/items | Singleton/client/checker/session/project built inside a loop | Preload required inputs, create once after inputs are stable, cache per project/process |
|
|
168
|
+
| Many medium-cost per-item operations | N+1 lookups, scalar provider calls, repeated source reads | Batch by provider/file/key, load rows in bulk, group work by locality |
|
|
169
|
+
| Traversal span grows with AST/source nodes | Wrapper allocation or broad source scan | Use lower-level APIs, prefilter by exact names only when output identity proves equivalence, index reusable facts |
|
|
170
|
+
| Database time dominates | Broad scan, missing index, many statements, repeated prepares | Push filters into SQL, batch queries, cache prepared statements, add measured indexes |
|
|
171
|
+
| Child process or startup dominates | Too many subprocesses or cold tool startup | Reuse workers, batch commands, keep warm daemons, collapse process boundaries |
|
|
172
|
+
| Serialization/output dominates | Large JSON, repeated formatting, full materialization | Stream, summarize, avoid duplicate fields, or add an explicit compact mode |
|
|
77
173
|
|
|
78
|
-
## Phase 3: Find Speedups
|
|
79
174
|
For the current pipeline, look for repeated work, broad scans, N+1 lookups,
|
|
80
175
|
uncached pure work, avoidable source or semantic reads, large arrays, late
|
|
81
|
-
filters, batchable per-file work,
|
|
176
|
+
filters, batchable per-file work, excessive subprocess startup, serialization
|
|
177
|
+
cost, cache invalidation churn, and safe parallelism. Prioritize by measured
|
|
178
|
+
span cost multiplied by real workload frequency; do not chase a large cold-only
|
|
179
|
+
span if the stated purpose depends on warm interactive latency.
|
|
180
|
+
|
|
181
|
+
Favor fixes in this order when they preserve output:
|
|
182
|
+
|
|
183
|
+
1. Remove accidental repetition: hoist, memoize, reuse, or preload.
|
|
184
|
+
2. Batch scalar work by provider, file, database key, network endpoint, or
|
|
185
|
+
process.
|
|
186
|
+
3. Move stable derived work from the hot path into an index/cache with a clear
|
|
187
|
+
invalidation key.
|
|
188
|
+
4. Replace broad scans with indexed lookups or candidate-first retrieval.
|
|
189
|
+
5. Replace high-overhead wrapper APIs with lower-level APIs only after output
|
|
190
|
+
identity checks prove equivalence.
|
|
191
|
+
6. Add pruning only when it is mathematically equivalent or output-identity
|
|
192
|
+
checks across representative corpora prove no observable change.
|
|
82
193
|
|
|
83
194
|
For alternative designs, restate the output contract first. Ask whether SQLite
|
|
84
195
|
can answer directly, an index/cache/precomputed table can move work out of the
|
|
85
196
|
hot path, batch queries can replace loops, a cheap pruning stage can precede
|
|
86
197
|
exact work, or workers can run independent phases safely.
|
|
87
198
|
|
|
88
|
-
## Phase
|
|
199
|
+
## Phase 5: Implement And Verify
|
|
200
|
+
|
|
89
201
|
Make the smallest reversible change that tests one performance hypothesis.
|
|
90
|
-
Update the ledger with hypothesis, changed files/symbols,
|
|
91
|
-
output comparison, tests, and gates.
|
|
202
|
+
Update the ledger and run history with hypothesis, changed files/symbols,
|
|
203
|
+
before/after timings, profile-span deltas, output comparison, tests, and gates.
|
|
204
|
+
|
|
205
|
+
After each candidate fix, run the smallest valid before/after matrix for the
|
|
206
|
+
target scenario: unprofiled control, profiled profile, output hash or semantic
|
|
207
|
+
identity check, and representative correctness tests. If a faster change alters
|
|
208
|
+
the output contract, reject or revert it unless the user explicitly approved a
|
|
209
|
+
behavior change.
|
|
92
210
|
|
|
93
211
|
Run the narrow correctness check, benchmark cases, `scip-query diff-impact
|
|
94
212
|
--json`, and `scip-query diff-gate --json`; reindex first if freshness is not
|
|
95
213
|
proven. Also run postchecks matching the change type. End with starting time,
|
|
96
214
|
final time, percentage change, accepted changes, rejected ideas, remaining
|
|
97
|
-
bottlenecks, and the next target.
|
|
215
|
+
bottlenecks, and the next target. If results conflict, keep the change only when
|
|
216
|
+
the target scenario and output contract justify it; otherwise revert and record
|
|
217
|
+
the rejected hypothesis.
|
|
218
|
+
|
|
219
|
+
## Phase 6: Report And Visualize
|
|
220
|
+
|
|
221
|
+
End every optimization round with a compact scoreboard generated from the run
|
|
222
|
+
history, not hand-copied memory. At minimum, show starting value, current value,
|
|
223
|
+
delta, scenario, corpus, commit/version, and output identity evidence. When the
|
|
224
|
+
history has enough rows, produce a trend table or chart for the target command
|
|
225
|
+
or workflow. Keep Markdown readable for humans, but treat the structured
|
|
226
|
+
history as the source of truth.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
interface:
|
|
2
|
-
display_name:
|
|
3
|
-
short_description:
|
|
4
|
-
default_prompt:
|
|
2
|
+
display_name: 'SCIP Hyper Optimization'
|
|
3
|
+
short_description: 'Hierarchical profiling-driven optimization'
|
|
4
|
+
default_prompt: 'Use $scip-hyper-optimization to choose an optimization target, capture output identity, measure cold and warm controls, profile the dominant span hierarchically, then optimize without changing behavior.'
|
package/dist/chunk-3Q77KKEY.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as Q}from"./chunk-B75HZHUP.js";import{a as v}from"./chunk-GBEYTDY5.js";import{b as H,e as U,f as z,g as K}from"./chunk-C5CTSJ6X.js";import{a as X}from"./chunk-UQLFQLAF.js";import{c as Z,d as J,e as q,f as C,l as G}from"./chunk-F6ICF7HL.js";import{e as $}from"./chunk-4KTOV4QN.js";import{b as T}from"./chunk-P5RYBRIO.js";import{h as V,n as x}from"./chunk-4N4WONI4.js";import{c as A,f as M,g as O,h as j,i as B,j as W}from"./chunk-JM72FNGA.js";import{a as k,d as E}from"./chunk-HF25DFSC.js";import{a as _}from"./chunk-DS6QEB3G.js";import{b as P,d as N,e as F}from"./chunk-XUGQU7PM.js";import{a as h}from"./chunk-64MNV6AB.js";import{b as S}from"./chunk-7S5E7KWT.js";var g=new WeakMap;function ee(e,t){let n=k(t);if(!(n==="rust"||n==="typescript"||n==="tsx"||n==="javascript"))return[];let r=_(e,t);if(!r)return[];let o=P(e,t,r),s=N(e,"definition-exclusions",t,o);if(s){let a=he(s);if(a)return a}let u=n==="rust"?De(e,t):_e(e,t);return F(e,"definition-exclusions",t,o,JSON.stringify(u)),u}function he(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(xe)?null:t}catch{return null}}function xe(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.startLine!="number"||!Number.isFinite(t.startLine)||typeof t.endLine!="number"||!Number.isFinite(t.endLine)||typeof t.reason!="string"?!1:t.containerName===void 0||typeof t.containerName=="string"}var te=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]),Re=/\b(?:describe|it|test|fdescribe|fit|xdescribe|xit|beforeEach|afterEach|beforeAll|afterAll|before|after|suite|bench|benchmark)\s*\(/,Se=/\b(?:export\s+)?(?:async\s+)?function\s+use[A-Z][A-Za-z0-9_$]*\b|\b(?:const|let|var)\s+use[A-Z][A-Za-z0-9_$]*\s*(?::[^=;]+)?=\s*(?:async\s*)?(?:function\b|(?:<[^=;{]+>\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>)/;function _e(e,t){let n=_(e,t);if(!n||!Ee(n))return[];let i=E(e,t);if(!i)return[];let r=g.get(i);if(r)return r;let o=!1,s=i.rootNode;for(let a of s.namedChildren){if(a.type!=="expression_statement")continue;let l=a.namedChild(0);if(!l||l.type!=="call_expression")continue;let c=l.namedChild(0);if(!c)continue;let f=c.type==="member_expression"?c.namedChild(c.namedChildCount-1)?.text:c.text;if(f&&te.has(f)){o=!0;break}}let u=[];o&&u.push({startLine:0,endLine:s.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"});for(let a of s.namedChildren){let l=null,c=null;if(a.type==="function_declaration")l=a.namedChild(0)?.text??null,c=a;else if(a.type==="export_statement"){let f=a.namedChild(0);f?.type==="function_declaration"&&(l=f.namedChild(0)?.text??null,c=f)}else if(a.type==="lexical_declaration"){let f=a.namedChild(0);if(f?.type==="variable_declarator"){let m=f.namedChild(0)?.text,b=f.namedChild(1);m&&(b?.type==="arrow_function"||b?.type==="function_expression")&&(l=m,c=f)}}l&&/^use[A-Z]/.test(l)&&c&&u.push({startLine:c.startPosition.row,endLine:c.endPosition.row,reason:"React custom hook (use*)"})}return u.push(...ne(i,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),g.set(i,u),u}function Ee(e){if(e.includes("scip-query"))return!0;let t=!1;for(let n of te)if(e.includes(n)){t=!0;break}return t&&Re.test(e)?!0:e.includes("use")&&Se.test(e)}var Ce=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function ve(e){return Ce.test(e)}function ne(e,t,n){let i=[],r=o=>{if(t.has(o.type)&&o.parent){let u=o.parent.children,a=-1;for(let l=0;l<u.length;l+=1)if(u[l].startIndex===o.startIndex&&u[l].type===o.type){a=l;break}if(a>0)for(let l=a-1;l>=0;l-=1){let c=u[l];if(n.has(c.type)){if(ve(c.text)){i.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(c.type==="attribute_item"||c.type==="inner_attribute_item"))break}}for(let s of o.namedChildren)r(s)};return r(e.rootNode),i}function De(e,t){let n=E(e,t);if(!n)return[];let i=g.get(n);if(i)return i;let r=[],o=Le(n);return o?(g.set(n,o),o):(re(n.rootNode,r,!1,!1),r.push(...ne(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),r.push(...Ae(n.rootNode)),g.set(n,r),r)}function Le(e){return Me(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)"}]:null}function re(e,t,n,i){let r=n,o=i;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(o=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),e.type==="function_item"||e.type==="function_signature_item"?we(e,t,n,i):i&&Te(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?Ie(e,t,n):e.type==="mod_item"&&D(e).some(s=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(s))&&(r=!0);for(let s of e.namedChildren)re(s,t,r,o)}function we(e,t,n,i){let r=D(e),o=null;i?o="trait impl method (dynamic dispatch)":n&&(o="inside #[cfg(test)] mod");for(let s of r){let u=Ne(s);if(u){o=u;break}if(ie(s)){o="#[allow(dead_code)]";break}}o&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:o})}function Ie(e,t,n){let i=D(e),r=e.namedChildren.find(o=>o.type==="type_identifier")?.text;i.some(ke)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:r}),i.some(ie)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:r}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:r})}function D(e){let t=e.parent;if(!t)return[];let n=t.children,i=-1;for(let o=0;o<n.length;o+=1)if(n[o].startIndex===e.startIndex&&n[o].type===e.type){i=o;break}if(i<=0)return[];let r=[];for(let o=i-1;o>=0;o-=1){let s=n[o];if(s.type==="attribute_item"||s.type==="inner_attribute_item")r.push(s.text);else{if(s.type==="line_comment"||s.type==="block_comment")continue;break}}return r}var Pe=[{re:/#\[\s*tauri::command\b/,reason:"#[tauri::command]"},{re:/#\[\s*command\b/,reason:"#[command]"},{re:/#\[\s*test\b/,reason:"#[test]"},{re:/#\[\s*bench\b/,reason:"#[bench]"},{re:/#\[\s*tokio::test\b/,reason:"#[tokio::test]"},{re:/#\[\s*async_std::test\b/,reason:"#[async_std::test]"},{re:/#\[\s*wasm_bindgen\b/,reason:"#[wasm_bindgen]"},{re:/#\[\s*no_mangle\b/,reason:"#[no_mangle]"},{re:/#\[\s*napi\b/,reason:"#[napi]"},{re:/#\[\s*pyfunction\b/,reason:"#[pyfunction]"},{re:/#\[\s*pymethod\b/,reason:"#[pymethod]"},{re:/#\[\s*pyo3\b/,reason:"#[pyo3]"},{re:/#\[\s*cfg\s*\(\s*test\s*\)/,reason:"#[cfg(test)]"},{re:/#\[\s*doc\s*\(\s*hidden\s*\)/,reason:"#[doc(hidden)]"}];function Ne(e){return Pe.find(({re:t})=>t.test(e))?.reason??null}var Fe=[/\bSerialize\b/,/\bDeserialize\b/,/\bFromRow\b/,/\bsqlx::FromRow\b/,/\bDeriveEntityModel\b/,/\bIntoSchema\b/,/\bToSchema\b/,/\bDeriveValueType\b/,/\bError\b/,/\bthiserror::Error\b/];function ke(e){return/#\[\s*derive\s*\(/.test(e)?Fe.some(t=>t.test(e)):!1}function ie(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function Te(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function Ae(e){let t=je(e);if(t.size===0)return[];let n=[];for(let i of e.descendantsOfType("mod_item")){let r=i.childForFieldName("name")?.text;r&&t.has(r)&&n.push({startLine:i.startPosition.row,endLine:i.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:r})}return n}function Me(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var Oe=/^#!?\[\s*serde\s*\(/,Y=/\bwith\s*=\s*"([^"]+)"/g;function je(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){if(!Oe.test(n.text))continue;Y.lastIndex=0;let i;for(;(i=Y.exec(n.text))!==null;){let r=i[1],o=r.split("::").pop()??r;o&&t.add(o)}}return t}function oe(e){let t=new Map,n=i=>{let r=t.get(i);if(r)return r;let o=ee(e,i);return r={ranges:o.map(s=>({startLine:s.startLine,endLine:s.endLine})),containers:new Set(o.map(s=>s.containerName).filter(s=>!!s))},t.set(i,r),r};return(i,r,o,s)=>{let u=n(i);for(let a of u.ranges)if(r>=a.startLine&&r<=a.endLine)return!0;if(s&&u.containers.has(s))return!0;for(let a of x(o))if(u.containers.has(a))return!0;return!1}}function ct(e,t={}){S(e,{groups:t.semanticProvider===!0?["whole-project","semantic-provider"]:["whole-project"]})}function se(e,t,n={}){S(e,{groups:n.definitions===!0?["source-file","definition-catalog"]:["source-file"],file:t.replace(/\\/g,"/")})}function ce(e,t){return t.isIgnoredPath(e.relativePath)?p("ignored-file"):j(e.symbol)?p("module-like-symbol"):ae(e.symbol)?!e.isFunctionLike&&e.enclosingSymbol&&ae(e.enclosingSymbol)?p("nested-non-callable-value"):!t.includeTests&&!L(e.relativePath)?p("test-file"):!t.includeTests&&t.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName)?p("excluded-file-region"):B(e.symbol)?p("rust-trait-impl-member"):W(e.symbol)?p("rust-test-module"):!t.includeMembers&&!Be(e)?p("member"):e.endLine-e.startLine+1<t.minLoc?p("below-min-loc"):{accepted:!0}:p("non-value-symbol")}function L(e){return H(e)!=="test"}function p(e){return{accepted:!1,rejectionReason:e}}function ae(e){return O(e)||e.endsWith("().")||e.endsWith(".")}function Be(e){return M(e.symbol)||x(e.symbol).length===0}function le(){return new Map}function ue(e,t,n){let i=new Map;for(let r of Z(e,n))e.isIgnored(r.relative_path)||t.has(r.relative_path)||R(i,r.symbol_id,r.relative_path,r.ref_count,"scip-mention");return i}function fe(e,t,n){let i=new Set;for(let r of J(e,t))e.isIgnored(r.relative_path)||n.has(r.relative_path)||i.add(r.symbol_id);return i}function w(e,t){let n=e.get(t);if(!n)return!1;for(let i of n.values())if(i.occurrences>0)return!0;return!1}function I(e,t,n){let i=e.get(t);if(!i)return!1;for(let[r,o]of i)if(r!==n&&o.occurrences>0)return!0;return!1}function de(e){return e?.occurrences??0}function R(e,t,n,i,r="source-fallback"){if(i<=0)return;let o=pe(e,t,n);o.occurrences+=i,o.sources.add(r)}function me(e,t,n,i,r){if(i<=0)return;let o=pe(e,t,n);o.occurrences=Math.max(i,o.occurrences),o.sources.add(r)}function pe(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));let r=i.get(n);return r||(r={occurrences:0,sources:new Set},i.set(n,r)),r}var We=3e3,He=1e3;function Ft(e,t={}){let{scope:n,minLoc:i=1,includeTests:r=!1,skipBarrels:o=!1,includeMembers:s=!1,deadCodeOnly:u=!1,scanLimit:a,semantic:l=!0}=t,c=Q(Ue(e,{scope:n,minLoc:i,includeTests:r,includeMembers:s}),a),f=o?new Set(U(e)):new Set,m=u?le():ue(e,f,c.map(d=>d.symbolId)),b=u?fe(e,c.map(d=>d.symbolId),f):new Set,y=u?c.filter(d=>!b.has(d.symbolId)):c.filter(d=>!I(m,d.symbolId,d.relativePath));u?Je(e,y,m,f):Ze(e,y,m,f);let ye=u?y.filter(d=>!w(m,d.symbolId)):y.filter(d=>!I(m,d.symbolId,d.relativePath));Qe(e,ye,m,{includeTests:r,inactiveBarrelPaths:f,includeSemantic:!u&&l});let ge=u?y.filter(d=>!w(m,d.symbolId)):c;return Ve(e,ze(ge,m))}function Ue(e,t){let n=oe(e),i=[];for(let r of V(e,t.scope))ce(r,{minLoc:t.minLoc,includeTests:t.includeTests,includeMembers:t.includeMembers,isIgnoredPath:s=>e.isIgnored(s),isExcludedRegion:n}).accepted&&i.push(r);return i}function ze(e,t){return e.map(n=>Ke(n,t)).filter(n=>n.cross_file_refs===0).sort((n,i)=>i.loc-n.loc||n.relative_path.localeCompare(i.relative_path)||n.start_line-i.start_line)}function Ke(e,t){let n=t.get(e.symbolId)??new Map,i=de(n.get(e.relativePath)),r=0;for(let[o,s]of n)o!==e.relativePath&&(r+=s.occurrences);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,same_file_refs:i,cross_file_refs:r}}function Ve(e,t){let n=[],i=0,r=0,o=0;for(let s of t){if(e.isIgnored(s.relative_path)||z(e,s.relative_path)||K(e,s.symbol,s.relative_path))continue;let u=s.same_file_refs===0?"dead-code":"file-internal";u==="dead-code"?i++:r++,o+=s.loc,n.push({relativePath:s.relative_path,startLine:s.start_line,endLine:s.end_line,loc:s.loc,symbol:s.symbol,shortName:A(s.symbol),sameFileRefs:s.same_file_refs,kind:u})}return{symbols:n,counts:{total:n.length,deadCode:i,fileInternal:r,loc:o},totalCount:n.length,deadCodeCount:i,fileInternalCount:r,totalLoc:o}}function Ze(e,t,n,i){if(t.length===0)return;let r=new v(e),o=new Set(t.map(a=>a.symbolId)),s=new Set(t.map(a=>a.leaf).filter(Boolean)),u=new Set(r.sourceFiles());for(let a of h(e))u.add(a);r.scanSourceReferences({paths:u,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:s,skipPath:a=>i.has(a)},a=>{o.has(a.target.symbolId)&&(Ge(e,a)||R(n,a.target.symbolId,a.sourceFile,Xe(a),"source-fallback"))})}function Je(e,t,n,i){if(t.length===0)return;let r=new v(e),o=qe(t),s=new Set(r.sourceFiles());for(let c of h(e))s.add(c);let u=new Set(o.keys()),a=new Map,l=c=>{let f=a.get(c);return f||(f=G(e,c),a.set(c,f)),f};r.scanSourceReferences({paths:s,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:u,skipPath:c=>i.has(c),resolveTargets:({sourceFile:c,name:f,kind:m})=>{let b=o.get(f);return b?$e(c,f,b,l(c),{permissive:m!=="cross-language-dispatch"}):[]},afterPath:c=>{a.delete(c),se(e,c)}},c=>{let f=c.kind==="identifier"&&c.sourceFile===c.target.relativePath?Math.max(0,c.occurrences-1):c.occurrences;c.kind==="identifier"&&be(e,{sourceFile:c.sourceFile,name:c.name,target:c.target,occurrences:f})||R(n,c.target.symbolId,c.sourceFile,f,"source-fallback")})}function qe(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let i=t.get(n.leaf)??[];i.push(n),t.set(n.leaf,i)}return t}function $e(e,t,n,i,r){let o=n.filter(a=>a.relativePath===e);if(o.length>0)return o;if(!r.permissive&&n.length===1)return[...n];let s=i.get(t);if(s)for(let a of s){let l=n.filter(c=>C(a,c.relativePath));if(l.length>0)return l}let u=new Set;for(let a of i.values())for(let l of a)u.add(l);for(let a of u){let l=n.filter(c=>C(a,c.relativePath));if(l.length>0&&l.length===n.length)return l}return r.permissive?[...n]:[]}function Ge(e,t){return t.kind==="cross-language-dispatch"&&t.target.relativePath===t.sourceFile?!0:t.kind==="identifier"&&be(e,t)}function Xe(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function be(e,t){return t.occurrences>1?!1:T(e,t.sourceFile).some(n=>n.used||n.sourcePath!==t.target.relativePath?!1:n.importedName===t.name||n.localName===t.name)}function Qe(e,t,n,i){let r=i.includeSemantic!==!1,o=r&&t.length>=We&&h(e).length>=He,s=(a,l)=>{l===a.relativePath||e.isIgnored(l)||i.inactiveBarrelPaths.has(l)||!i.includeTests&&!L(l)||me(n,a.symbolId,l,1,"caller-map")};if(o)Ye(e,t,s);else for(let a of t){let l=X(e,a,{semantic:r});if(l.length!==0)for(let c of l)s(a,c.file)}if(!o)return;let u=$(e,t);for(let a of t){let l=u.get(a.symbolId);if(l)for(let c of l)s(a,c)}}function Ye(e,t,n){let i=new Map(t.map(r=>[r.symbolId,r]));for(let r of q(e,[...i.keys()])){let o=i.get(r.symbol_id);o&&n(o,r.relative_path)}}export{ct as a,Ft as b};
|
|
2
|
-
//# sourceMappingURL=chunk-3Q77KKEY.js.map
|
package/dist/chunk-4KTOV4QN.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{l as T}from"./chunk-OBGRLXWF.js";import{f as g}from"./chunk-4N4WONI4.js";import{d as h}from"./chunk-JM72FNGA.js";import{c as B,g as _,i as V}from"./chunk-XUGQU7PM.js";import{a as k}from"./chunk-64MNV6AB.js";import{a as W,c as $}from"./chunk-7S5E7KWT.js";function p(r,e,t){if(r.has(e))return r.get(e);let n=t();return r.set(e,n),n}import J from"path";function de(r,e){return r.getReferences().map(t=>{let n=t.getNode();return Y(n,e)})}function me(r){let e=r;return typeof e.findReferences=="function"?e.findReferences():[]}function z(r,e,t,n){let i=[];for(let o of me(r))for(let s of de(o,n))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||i.push(s);for(let o of t)i.push(o);return M(i)}function K(r,e,t,n){let i=[],o=t?.getStart();for(let s of r.getReferences()){let a=s.getNode();S(n,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||i.push({location:Y(a,n),node:a}))}return i}function Y(r,e){let t=r.getSourceFile(),n=t.getLineAndColumnAtPos(r.getStart());return{file:S(e,t.getFilePath())??t.getBaseName(),line:n.line-1,column:n.column-1}}function X(r,e,t){let n=r.getSourceFile(),i=y(n,r),o=r.getText(),s=new RegExp(`\\b${ge(o)}\\b`,"g"),a=n.getFullText().split(`
|
|
2
|
-
`),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let u=a[l]??"";s.lastIndex=0;let d;for(;(d=s.exec(u))!==null;)c.push({file:e,line:l,column:d.index})}return M(c.filter(l=>S(t,J.join(t,l.file))===e))}function R(r){for(let e=r;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 y(r,e){return r.getLineAndColumnAtPos(e.getStart()).line-1}function M(r){let e=new Set,t=[];for(let n of r){let i=`${n.file}:${n.line}:${n.column}`;e.has(i)||(e.add(i),t.push(n))}return t}function S(r,e){let t=J.relative(r||process.cwd(),e).replace(/\\/g,"/");return!t||t.startsWith("..")?null:t}function ge(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(r,e,t,n){let i=ye(e,n);return i.size===0?new Map:he(r,t,i)}function ye(r,e){let t=new Map;for(let n of g(r,e)){let i=h(n.symbol)??n.leaf;if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push(n)}return t}function he(r,e,t){let n=new Map,i=new Map;return e.forEachDescendant(o=>{for(let s of Se(r,o)){let a=t.get(s);if(!a)continue;let c=y(e,o);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let u=Math.abs(c-l.startLine),d=i.get(l.symbolId);d!==void 0&&d<=u||(i.set(l.symbolId,u),n.set(l.symbolId,o))}}}),n}function Se(r,e){let t=[],n=i=>{i&&!t.includes(i)&&t.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();n(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();n(i)}return r.Node.isIdentifier(e)&&n(e.getText()),t}var xe=$("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function H(r,e,t,n){let i=Z(r,e),o=G(i.get(n)??[],t);if(o)return o;let s=[];for(let a of i.values())for(let c of a)((c.leaf||h(c.symbol)||"").includes(n)||c.symbol.includes(n))&&s.push(c);return G(s,t)}function Q(r,e){let t=new Map;for(let[n,i]of Z(r,e)){let o=i[0];o&&t.set(n,o)}return t}function Z(r,e){return xe.get(r,e,()=>{let t=new Map;for(let n of g(r,e)){let i=n.leaf||h(n.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push({...n,leaf:i})}for(let n of t.values())n.sort((i,o)=>i.startLine-o.startLine||i.endLine-o.endLine||i.symbolId-o.symbolId);return t})}function G(r,e){let t=null,n=Number.POSITIVE_INFINITY;for(let i of r){let o=Math.abs(i.startLine-e);(o<n||o===n&&t&&i.startLine<t.startLine)&&(t=i,n=o)}return t}import Ie from"path";var x=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function I(r){let e=r.toLowerCase();return x.some(t=>e.endsWith(t))}function ee(r,e){let t=new Map,n=i=>I(i)?p(t,i,()=>{let o=Ie.join(r.config.projectRoot,i);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:i=>n(i)?.sourceFile??null,sourceFileMatch:n,indexedTypeScriptLikeDocuments:()=>k(r,{extensions:x})}}import m from"path";import{existsSync as F,readdirSync as be,readFileSync as te}from"fs";function ne(r){let e=m.join(r,"package.json");if(!F(e))return[];let t;try{t=JSON.parse(te(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>De(r,i)).flatMap(i=>Ne(r,i))}function De(r,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=m.join(r,e);return F(m.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=m.join(r,n||".");if(!F(o))return[];try{return be(o).map(s=>m.join(o,s,i)).filter(s=>F(m.join(s,"package.json")))}catch{return[]}}function Ne(r,e){try{let t=JSON.parse(te(m.join(e,"package.json"),"utf8"));if(!t.name)return[];let n=m.relative(r,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:n,sourceRootRelative:`${n}/src`}]}catch{return[]}}function re(r,e){for(let t of r)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function ie(r){return[`${r.sourceRootRelative}/index.ts`,`${r.sourceRootRelative}/index.tsx`,`${r.sourceRootRelative}/index.mts`,`${r.sourceRootRelative}/index.cts`]}import{existsSync as b,readFileSync as ke,readdirSync as Me,statSync as Fe}from"fs";import f from"path";var E=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function j(r,e){let n=e?f.dirname(f.join(r,e)):r,i=f.resolve(r);for(;n.startsWith(i);){for(let s of E){let a=f.join(n,s);if(b(a))return a}let o=f.dirname(n);if(o===n)break;n=o}for(let o of E){let s=f.join(r,o);if(b(s))return s}return null}function oe(r){let e=r.config.projectRoot,t=new Set(ve(e,r.config.semantic?.typescript?.tsconfigs)),n=k(r,{includeIgnored:!1,extensions:x});for(let i of n){let o=j(e,i);o&&t.add(f.resolve(o))}if(t.size===0){let i=j(e);i&&t.add(f.resolve(i))}return[...t].filter(i=>!se(e,i)).sort((i,o)=>i.localeCompare(o))}function ve(r,e=[]){let t=new Set;for(let n of e){let i=f.isAbsolute(n)?n:f.join(r,n);b(i)&&t.add(f.resolve(i))}for(let n of Pe(r))for(let i of E){let o=f.join(n,i);b(o)&&t.add(f.resolve(o))}if(t.size===0){let n=j(r);n&&t.add(f.resolve(n))}return[...t].filter(n=>!se(r,n)).sort((n,i)=>n.localeCompare(i))}function Pe(r){let e=f.join(r,"package.json");if(!b(e))return[];let t;try{t=JSON.parse(ke(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>Te(r,i))}function Te(r,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=f.join(r,e);return C(s)?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=f.join(r,n||".");return C(o)?Me(o).map(s=>f.join(o,s,i)).filter(C):[]}function C(r){try{return Fe(r).isDirectory()}catch{return!1}}function se(r,e){let t=f.relative(r,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}import{createRequire as Re}from"module";var Ce=Re(import.meta.url),D;function ae(){if(D!==void 0)return D;try{D=Ce("ts-morph")}catch{D=null}return D}function ce(r,e){return e.map(t=>({tsconfigPath:t,project:new r.Project({tsConfigFilePath:t,skipFileDependencyResolution:!1})}))}function v(r,e,t){return{language:"typescript",availability:()=>({available:!1,reason:r,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function pe(r,e){let t=ae();if(!t)return v("ts-morph is not installed");let n=oe(r);if(n.length===0)return v("no tsconfig found");try{let i=ce(t,n);return new w(r,t,i)}catch(i){return v(i instanceof Error?i.message:String(i),n[0],n)}}var w=class{constructor(e,t,n){this.db=e;this.tsMorph=t;this.projects=n;this.workspacePackages=ne(e.config.projectRoot),this.sourceFiles=ee(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 i of t.getImportDeclarations())for(let o of this.importUsageForDeclaration(e,i))n.push(o);return n})}referencesFor(e){return p(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),n=this.packageImportReferencesForDefinition(e);return t?z(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 i=n.getParameters().map(s=>{let a=s.getDeclarations()[0],c=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return fe(c)}),o=n.getReturnType().getText(t);return`(${i.join(",")})=>${fe(o)}`})}importUsageForDeclaration(e,t){let n=T(this.db,e,t.getModuleSpecifierValue()),i=le(t);return t.getImportClause()?.isTypeOnly()?i.map(o=>Ee(e,n,o)):i.map(o=>this.valueImportUsageForEntry(e,n,o))}valueImportUsageForEntry(e,t,n){let i=n.identifier?n.identifier.findReferences():[],o=[];for(let l of i)for(let u of K(l,e,n.identifier,this.db.config.projectRoot))o.push(u);let s=o.some(l=>!R(l.node)),a=o.some(l=>R(l.node)),c=n.isTypeOnly;return{importer:e,sourcePath:t,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:c,isUsed:c||o.length>0,isTypeUsed:c||a,isValueUsed:s,references:o.map(l=>l.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,i]of e)e.set(n,M(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,n){if(this.db.isIgnored(n))return;let i=this.sourceFiles.sourceFileMatch(n);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,n,o)}addPackageImportReferencesForDeclaration(e,t,n,i){let o=re(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of le(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let l=X(a.identifier,n,this.db.config.projectRoot);l.length>0&&Le(e,c,l)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let n=new Map;for(let i of ie(t))this.collectPackageExports(t,i,n,new Set);n.size>0&&e.set(t.name,n)}return this.packageExportIndex=e,e}collectPackageExports(e,t,n,i){if(i.has(t))return;i.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?T(this.db,t,a):t;if(!c||!c.startsWith(`${e.sourceRootRelative}/`))continue;let l=s.getNamedExports();if(l.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,n,i);continue}for(let u of l){let d=u.getNameNode().getText(),O=u.getAliasNode()?.getText()??d,U=this.indexedDefinitionByLeaf(c,d);if(!U)continue;let N=n.get(O);N||(N=new Set,n.set(O,N)),N.add(U.symbolId)}}}indexedDefinitionByLeaf(e,t){return p(this.indexedDefinitionLeafCache,e,()=>Q(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?q(this.tsMorph,this.db,t,e):new Map})}definitionFromSymbol(e){let t=e.getDeclarations();for(let n of t){let i=n.getSourceFile(),o=S(this.db.config.projectRoot,i.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=y(i,n),a=H(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=g(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(n.length===0)return new Map;let i=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&&je(i,s.callerId,s.target)});for(let[o,s]of i)i.set(o,Ae(s));return i}semanticCalleeForCallNode(e,t,n){let i=we(t,y(e,n));if(!i)return null;let o=n.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:i.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function le(r){let e=[],t=r.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:r.getImportClause()?.isTypeOnly()??!1});let n=r.getNamespaceImport();n&&e.push({identifier:n,importedName:"*",localName:n.getText(),kind:"namespace",isTypeOnly:r.getImportClause()?.isTypeOnly()??!1});for(let i of r.getNamedImports()){let o=i.getNameNode(),a=i.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(r.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Ee(r,e,t){return{importer:r,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function je(r,e,t){let n=r.get(e);n||(n=[],r.set(e,n)),n.push(t)}function we(r,e){let t=null;for(let n of r)e<n.startLine||e>n.endLine||(!t||n.startLine>=t.startLine)&&(t=n);return t}function Le(r,e,t){for(let n of e){let i=r.get(n)??[];i.push(...t),r.set(n,i)}}function Ae(r){let e=new Set,t=[];for(let n of r){let i=`${n.symbol}|${n.file}|${n.line}`;e.has(i)||(e.add(i),t.push(n))}return t}function fe(r){return r.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}var L=new WeakMap;W({name:"semantic-provider",groups:["semantic-provider"],clearAll:r=>L.delete(r)});function A(r,e){let t=`${r.config.projectRoot}:typescript-workspace`,n=L.get(r);n||(n=new Map,L.set(r,n));let i=n.get(t);if(i)return i;let o=pe(r,e);return n.set(t,o),o}function Tt(r,e){let t=P(r,e);return t?t.importUsage(e):[]}function ue(r,e){let t=P(r,e.relativePath);return t?t.referencesFor(e):[]}function Rt(r,e){let t=new Map,n=B(r),i=[];for(let o of e){let s=Oe(r,o,n,i);for(let a of s){if(a.file===o.relativePath||r.isIgnored(a.file))continue;let c=t.get(o.symbolId);c||(c=new Set,t.set(o.symbolId,c)),c.add(a.file)}}return i.length>0&&A(r).availability().available&&V(r,i),t}function Oe(r,e,t,n){if(!t||!I(e.relativePath))return ue(r,e);let i=_(r,e.relativePath,e.symbol,t);if(i!==null){let s=Ue(i);if(s)return s}let o=ue(r,e);return n.push({relativePath:e.relativePath,symbol:e.symbol,projectFingerprint:t,payload:JSON.stringify(o)}),o}function Ue(r){try{return JSON.parse(r)}catch{return null}}function Ct(r,e){let t=new Map;for(let n of e){let i=P(r,n.relativePath);if(!i)continue;let o=i.calleesFor(n);o.length>0&&t.set(n.symbolId,o)}return t}function Et(r,e){let t=P(r,e.relativePath);return t?t.signatureFor(e):null}function P(r,e){if(!I(e))return null;let t=A(r,e);return t.availability().available?t:null}export{I as a,A as b,Tt as c,ue as d,Rt as e,Ct as f,Et as g};
|
|
3
|
-
//# sourceMappingURL=chunk-4KTOV4QN.js.map
|
package/dist/chunk-4N4WONI4.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import{a as N,b as m,c as E,d as M,e as p,g as F}from"./chunk-JM72FNGA.js";import{c as R}from"./chunk-72KY2ZFO.js";import{a as f}from"./chunk-DS6QEB3G.js";import{b,c as g,d as h,e as D,j as _}from"./chunk-XUGQU7PM.js";import{a as I}from"./chunk-64MNV6AB.js";import{c as S}from"./chunk-7S5E7KWT.js";function ce(e,n){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name, gs.documentation
|
|
2
|
-
FROM global_symbols gs
|
|
3
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
4
|
-
JOIN documents d ON der.document_id = d.id
|
|
5
|
-
WHERE ${n.where}
|
|
6
|
-
${e.pathExclusionsFor("d")}
|
|
7
|
-
${O(n.orderBy)}
|
|
8
|
-
${k(n.limit)}`,...n.params??[])}function de(e,n){return e.all(`SELECT
|
|
9
|
-
gs.id,
|
|
10
|
-
gs.symbol,
|
|
11
|
-
c.document_id,
|
|
12
|
-
MIN(c.start_line) AS start_line,
|
|
13
|
-
MAX(c.end_line) AS end_line,
|
|
14
|
-
d.relative_path,
|
|
15
|
-
gs.display_name,
|
|
16
|
-
gs.documentation
|
|
17
|
-
FROM global_symbols gs
|
|
18
|
-
JOIN mentions m ON m.symbol_id = gs.id
|
|
19
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
20
|
-
JOIN documents d ON c.document_id = d.id
|
|
21
|
-
WHERE m.role = 1
|
|
22
|
-
AND ${n.where}
|
|
23
|
-
${e.pathExclusionsFor("d")}
|
|
24
|
-
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
|
|
25
|
-
${O(n.orderBy)}
|
|
26
|
-
${k(n.limit)}`,...n.params??[])}function O(e){return e?`ORDER BY ${e}`:""}function k(e){return typeof e=="number"?`LIMIT ${e}`:""}function $(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function C(e){if(!e)return null;let n=w(e);if(n)return n.replace(/\n/g," ");let t=e.indexOf("|");if(t===-1)return e.replace(/\n/g," ");let r=e.slice(t+1);return(w(r)??r).replace(/\n/g," ")}function w(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function v(e){if(m(e.symbol)!==null)return!1;let t=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(t)}function L(e,n,t={}){let r=new Map;for(let o of n)e.length>0&&!v(o)||r.set(o.id,o);for(let o of e)r.set(o.id,o);let i=[...r.values()];return t.sort?i.sort((o,s)=>o.start_line-s.start_line||o.end_line-s.end_line||o.symbol.localeCompare(s.symbol)):i}var H=S("file-definitions",{clearGroups:["definition-catalog"]}),A=new WeakMap;function x(e,n){return H.get(e,n,()=>{let t=j(e,n);if(t)return t;let r=L(z(e,n),G(e,n),{sort:!0}),i=P(e,n,r.map(B)),o=g(e),s=f(e,n);return o&&s&&D(e,"file-definitions",n,b(e,n,s),JSON.stringify({projectFingerprint:o,definitions:i.map(l=>({...l}))})),i})}function j(e,n){let t=g(e);if(!t)return null;let r=f(e,n);if(!r)return null;let i=h(e,"file-definitions",n,b(e,n,r));return i?W(i,t,n):null}function W(e,n,t){try{let r=JSON.parse(e);if(!_(r)||r.projectFingerprint!==n||!Array.isArray(r.definitions))return null;let i=[];for(let o of r.definitions){let s=Y(o,t);if(!s)return null;i.push(s)}return i}catch{return null}}function Y(e,n){return!_(e)||typeof e.symbolId!="number"||typeof e.symbol!="string"||typeof e.documentId!="number"||typeof e.startLine!="number"||typeof e.endLine!="number"||e.relativePath!==n||typeof e.leaf!="string"||typeof e.parentTypeName!="string"&&e.parentTypeName!==null||typeof e.isFunctionLike!="boolean"||typeof e.isTypeLike!="boolean"||typeof e.kind!="number"&&e.kind!==null||typeof e.documentation!="string"&&e.documentation!==null||typeof e.enclosingSymbol!="string"&&e.enclosingSymbol!==null?null:{symbolId:e.symbolId,symbol:e.symbol,documentId:e.documentId,startLine:e.startLine,endLine:e.endLine,relativePath:e.relativePath,leaf:e.leaf,parentTypeName:e.parentTypeName,isFunctionLike:e.isFunctionLike,isTypeLike:e.isTypeLike,kind:e.kind,documentation:e.documentation,enclosingSymbol:e.enclosingSymbol}}function z(e,n){return e.all(`SELECT
|
|
27
|
-
gs.id,
|
|
28
|
-
gs.symbol,
|
|
29
|
-
der.document_id,
|
|
30
|
-
der.start_line,
|
|
31
|
-
der.end_line,
|
|
32
|
-
d.relative_path,
|
|
33
|
-
gs.display_name,
|
|
34
|
-
gs.kind,
|
|
35
|
-
gs.documentation,
|
|
36
|
-
gs.enclosing_symbol
|
|
37
|
-
FROM global_symbols gs
|
|
38
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
39
|
-
JOIN documents d ON der.document_id = d.id
|
|
40
|
-
WHERE d.relative_path = ?
|
|
41
|
-
${e.symbolNoiseFor("gs")}
|
|
42
|
-
ORDER BY der.start_line, der.end_line`,n)}function G(e,n){return e.all(`SELECT
|
|
43
|
-
gs.id,
|
|
44
|
-
gs.symbol,
|
|
45
|
-
c.document_id,
|
|
46
|
-
MIN(c.start_line) AS start_line,
|
|
47
|
-
MAX(c.end_line) AS end_line,
|
|
48
|
-
d.relative_path,
|
|
49
|
-
gs.display_name,
|
|
50
|
-
gs.kind,
|
|
51
|
-
gs.documentation,
|
|
52
|
-
gs.enclosing_symbol
|
|
53
|
-
FROM global_symbols gs
|
|
54
|
-
JOIN mentions m ON m.symbol_id = gs.id
|
|
55
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
56
|
-
JOIN documents d ON c.document_id = d.id
|
|
57
|
-
WHERE d.relative_path = ?
|
|
58
|
-
AND m.role = 1
|
|
59
|
-
${e.symbolNoiseFor("gs")}
|
|
60
|
-
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
61
|
-
ORDER BY start_line, end_line`,n)}function B(e){return{symbolId:e.id,symbol:e.symbol,documentId:e.document_id,startLine:e.start_line,endLine:e.end_line,relativePath:e.relative_path,leaf:M(e.symbol),parentTypeName:m(e.symbol),isFunctionLike:F(e.symbol),isTypeLike:p(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function De(e,n={}){return K(e,n.scope)}function K(e,n){return I(e,{scope:n,includeIgnored:!1}).flatMap(t=>x(e,t)).filter(t=>!e.isIgnored(t.relativePath))}function Ie(e,n){let t=T(U(e,n.scope,n.sqlPrefilter)),r=T(X(e,n.scope,n.sqlPrefilter)),i=new Set([...t.keys(),...r.keys()]),o=[];for(let s of[...i].sort()){if(e.isIgnored(s))continue;let l=L(t.get(s)??[],r.get(s)??[],{sort:!0}).filter(a=>n.symbolMatches(a.symbol));l.length!==0&&o.push(...P(e,s,l.map(B)))}return o}function U(e,n,t){let r=n?"AND d.relative_path LIKE ?":"",i=t==="callable"?`AND ${J("gs")}`:"",o=n?[`%${n}%`]:[];return e.all(`SELECT
|
|
62
|
-
gs.id,
|
|
63
|
-
gs.symbol,
|
|
64
|
-
der.document_id,
|
|
65
|
-
der.start_line,
|
|
66
|
-
der.end_line,
|
|
67
|
-
d.relative_path,
|
|
68
|
-
gs.display_name,
|
|
69
|
-
gs.kind,
|
|
70
|
-
gs.documentation,
|
|
71
|
-
gs.enclosing_symbol
|
|
72
|
-
FROM global_symbols gs
|
|
73
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
74
|
-
JOIN documents d ON der.document_id = d.id
|
|
75
|
-
WHERE 1 = 1
|
|
76
|
-
${e.pathExclusionsFor("d")}
|
|
77
|
-
${r}
|
|
78
|
-
${i}
|
|
79
|
-
${e.symbolNoiseFor("gs")}
|
|
80
|
-
ORDER BY d.relative_path, der.start_line, der.end_line`,...o)}function X(e,n,t){let r=n?"AND d.relative_path LIKE ?":"",i=t==="callable"?`AND ${J("gs")}`:"",o=n?[`%${n}%`]:[];return e.all(`SELECT
|
|
81
|
-
gs.id,
|
|
82
|
-
gs.symbol,
|
|
83
|
-
c.document_id,
|
|
84
|
-
MIN(c.start_line) AS start_line,
|
|
85
|
-
MAX(c.end_line) AS end_line,
|
|
86
|
-
d.relative_path,
|
|
87
|
-
gs.display_name,
|
|
88
|
-
gs.kind,
|
|
89
|
-
gs.documentation,
|
|
90
|
-
gs.enclosing_symbol
|
|
91
|
-
FROM global_symbols gs
|
|
92
|
-
JOIN mentions m ON m.symbol_id = gs.id
|
|
93
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
94
|
-
JOIN documents d ON c.document_id = d.id
|
|
95
|
-
WHERE m.role = 1
|
|
96
|
-
${e.pathExclusionsFor("d")}
|
|
97
|
-
${r}
|
|
98
|
-
${i}
|
|
99
|
-
${e.symbolNoiseFor("gs")}
|
|
100
|
-
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
101
|
-
ORDER BY d.relative_path, start_line, end_line`,...o)}function J(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function T(e){let n=new Map;for(let t of e){let r=n.get(t.relative_path);r?r.push(t):n.set(t.relative_path,[t])}return n}function Re(e,n,t={}){if(n.length===0)return[];let r=n.flatMap(i=>x(e,i)).filter(i=>!e.isIgnored(i.relativePath));return t.onlyDocumented&&(r=r.filter(i=>i.documentation!==null&&i.documentation!=="")),t.sort&&(r=r.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),r.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:E(i.symbol),signature:$(C(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function Z(e){let n=new Map,t=e.map((r,i)=>({definition:r,index:i,span:r.endLine-r.startLine})).sort((r,i)=>r.span-i.span||r.index-i.index);for(let{definition:r}of t)for(let i=r.startLine;i<=r.endLine;i+=1)n.has(i)||n.set(i,r);return n}function Ne(e,n){let t=A.get(e);return t||(t=Z(e),A.set(e,t)),t.get(n)??null}function Ee(e,n){let t=x(e,n.relative_path).find(r=>r.symbolId===n.id);return t?{symbolId:t.symbolId,symbol:t.symbol,documentId:t.documentId,startLine:t.startLine,endLine:t.endLine,relativePath:t.relativePath}:{symbolId:n.id,symbol:n.symbol,documentId:n.document_id,startLine:n.start_line,endLine:n.end_line,relativePath:n.relative_path}}function P(e,n,t){let r=f(e,n),i=R(e,n);return i?ie(t,i,r):r?V(t,r):t}function V(e,n){let t=n.split(/\r?\n/),r=q(e,t),i=ee(e,r),o=ne(i,t);return te(e,o)}function q(e,n){let t=e.some(i=>y(i.symbol))?se(n):null,r=new Map;for(let i of e)r.set(i.symbolId,oe(n,t,i));return r}function ee(e,n){return e.filter(t=>y(t.symbol)).map(t=>({definition:t,startLine:n.get(t.symbolId)??t.startLine})).sort((t,r)=>t.startLine-r.startLine||t.definition.startLine-r.definition.startLine||t.definition.symbol.localeCompare(r.definition.symbol))}function ne(e,n){let t=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],o=e[r+1],s=o?Math.max(i.startLine,o.startLine-1):n.length-1;t.set(i.definition.symbolId,{startLine:i.startLine,endLine:le(n,i.definition,i.startLine,s)})}return t}function te(e,n){return e.map(t=>{let r=n.get(t.symbolId);return r?{...t,startLine:r.startLine,endLine:r.endLine}:t})}function ie(e,n,t=null){let r=new Map;for(let i of n){let o=r.get(i.name);o?o.push(i):r.set(i.name,[i])}return e.map(i=>{if(!re(i)||!i.leaf)return Q(i,t);let o=r.get(i.leaf);if(!o||o.length===0)return Q(i,t);let s=o[0],l=Math.abs(s.startLine-i.startLine);for(let a=1;a<o.length;a+=1){let c=o[a],d=Math.abs(c.startLine-i.startLine);d<l&&(s=c,l=d)}return{...i,startLine:s.startLine,endLine:s.endLine}})}function re(e){return y(e.symbol)?!0:p(e.symbol)==="term"&&m(e.symbol)===null}function Q(e,n){if(!n||!e.leaf||p(e.symbol)!=="term"||m(e.symbol)!==null)return e;let t=e.leaf.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b(?:export\\s+)?(?:const|let|var)\\s+${t}\\b`),o=n.split(/\r?\n/).findIndex(s=>r.test(s));return o>=0?{...e,startLine:o,endLine:o}:e}function oe(e,n,t){if(!y(t.symbol))return t.startLine;let r=Math.max(0,Math.min(t.startLine,e.length-1));if(!n)return r;let i=n.get(t.leaf);if(!i||i.length===0)return r;let o=null;for(let s of i){let l=Math.abs(s-t.startLine);(!o||l<o.distance)&&(o={line:s,distance:l})}return o?.line??r}function se(e){let n=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,t=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,r=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,s=(l,a)=>{let c=o.get(l);if(!c){o.set(l,[a]);return}c[c.length-1]!==a&&c.push(a)};for(let l=0;l<e.length;l+=1){let a=e[l]??"";for(let d of a.matchAll(n))d[1]&&s(d[1],l);for(let d of a.matchAll(t))d[1]&&s(d[1],l);let c=a.match(r);c?.[1]&&s(c[1],l);for(let d of a.matchAll(i))d[1]&&s(d[1],l)}return o}function le(e,n,t,r){let i=Math.max(t,Math.min(e.length-1,r)),o=Math.max(t,Math.min(i,n.endLine)),s=0,l=0,a=!1;for(let c=t;c<=i;c+=1){let d=ae(e[c]??"");for(let u of d)u==="{"?(s+=1,a=!0):u==="}"?s=Math.max(0,s-1):u==="("?l+=1:u===")"&&(l=Math.max(0,l-1));if(a&&s===0||!a&&l===0&&c>=o)return c}return o}function ae(e){let n="",t=null,r=!1;for(let i=0;i<e.length;i+=1){let o=e[i],s=e[i+1];if(!t&&o==="/"&&s==="/"){n+=" ".repeat(e.length-i);break}if(t){if(r){r=!1,n+=" ";continue}if(o==="\\"){r=!0,n+=" ";continue}o===t&&(t=null),n+=" ";continue}if(o==='"'||o==="'"||o==="`"){t=o,n+=" ";continue}n+=o}return n}function y(e){return e.includes("().")}function Me(e){let n=N(e);if("kind"in n)return[];let t=[];for(let r=n.descriptors.length-2;r>=0;r-=1){let i=n.descriptors[r];i?.suffix==="type"&&i.name&&t.push(i.name)}return t}export{ce as a,de as b,$ as c,C as d,L as e,x as f,De as g,K as h,Ie as i,Re as j,Z as k,Ne as l,Ee as m,Me as n};
|
|
102
|
-
//# sourceMappingURL=chunk-4N4WONI4.js.map
|
package/dist/chunk-A6IDHNMC.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as ae}from"./chunk-7JRRXGVZ.js";import{a as se}from"./chunk-2VM46FC5.js";import{a as S}from"./chunk-B32FX5KB.js";import{a as re}from"./chunk-QVI3NR7E.js";import{a as ne}from"./chunk-AW2QHPLL.js";import{a as oe}from"./chunk-C2QSK7E7.js";import{a as te,c as ie}from"./chunk-FRPEPTYJ.js";import{a as X}from"./chunk-A6TANQNV.js";import{a as ee}from"./chunk-KX5PLFZ5.js";import{a as Q}from"./chunk-ZU6PROUY.js";import{a as O,c as U,d as V,h as L,i as B}from"./chunk-DQVKIG3D.js";import{a as q,b as x,e as W}from"./chunk-PKMZCDQD.js";import{a as Z}from"./chunk-CZ425R2B.js";import{b as J}from"./chunk-3Q77KKEY.js";import{a as E,c as H,d as _,e as z}from"./chunk-65AU3HFZ.js";import{g as M}from"./chunk-BSN22NRK.js";import{a as Y}from"./chunk-QYB5P7GL.js";import{a as I}from"./chunk-GBEYTDY5.js";import{f as F,g as v}from"./chunk-C5CTSJ6X.js";import{d as k,e as N,f as P}from"./chunk-JM72FNGA.js";import{createHash as Me}from"crypto";import{existsSync as ge}from"fs";function ce(e){let[i,t]=A(e,":"),n=i||"unknown",o=(s={})=>{let r=s.actionTier??pe(n);return{sourceAnalyzer:n,actionTier:r,rootCauseKey:s.rootCauseKey??(t||e),label:s.label??`${n} finding`,relatedFiles:s.relatedFiles??[],why:s.why??[],remediation:s.remediation??ye(r,n),file:s.file}};if(!t)return o({rootCauseKey:e,why:["Baseline identity did not include analyzer payload."]});if(["dead","isolated","extract","wrapper","passthrough","stale"].includes(n)){let[s,r]=A(t,":");return o({file:s,relatedFiles:s?[s]:[],rootCauseKey:r?`${s}:${r}`:t,label:`${n} finding`,why:r?[`Baseline subject: ${r}.`]:[]})}if(n==="cycle"){let s=t.split(">").filter(Boolean);return o({relatedFiles:s,rootCauseKey:t,label:"cycle finding",why:s.length>0?[`Cycle path: ${s.join(" > ")}.`]:[]})}if(n==="similar"){let s=t.split("|").filter(Boolean);return o({relatedFiles:[],rootCauseKey:t,label:"similarity finding",why:s.length>0?[`Similar symbols: ${s.join(" | ")}.`]:[]})}if(n==="drift"){let[s,r]=A(t,":"),[l,a]=A(r,":");return o({actionTier:s==="unused-import"?"direct":"signal",file:l,relatedFiles:[...new Set([l,a].filter(Boolean))],rootCauseKey:t,label:`${s||"drift"} finding`,why:[...s?[`Drift kind: ${s}.`]:[],...a?[`Related dependency: ${a}.`]:[]]})}return o({why:["Baseline analyzer prefix is not recognized by this diff-gate version."]})}function pe(e){switch(e){case"dead":case"isolated":case"cycle":case"passthrough":return"direct";case"similar":case"extract":case"wrapper":case"stale":return"signal";default:return"signal"}}function ye(e,i){return e==="direct"?`Fix the new ${i} baseline finding, or knowingly accept it via health --write-baseline.`:`Review the new ${i} baseline signal; fix it if it reflects real debt, or knowingly accept it via health --write-baseline.`}function A(e,i){let t=e.indexOf(i);return t<0?[e,""]:[e.slice(0,t),e.slice(t+i.length)]}import{existsSync as be,readFileSync as le}from"fs";var w={classifyCitation:Ce,citationContexts:Se,citationKindLabel:De,citationRemediation:we,referenceTargets:Re};function Ce(e){let i=e.join(`
|
|
2
|
-
`).toLowerCase(),t=[],n=x(i,[".scipquery","declaredcouplings","suppression","suppressions","config","configuration","json"]);if(n.length>0)return t.push(`configuration/example terms near citation: ${n.join(", ")}`),{citationKind:"configuration-example",actionTier:"support",reasons:t};let o=x(i,["accepted","intentional","intentionally","retained","historical"]);if(o.length>0)return t.push(`intentional-record terms near citation: ${o.join(", ")}`),{citationKind:"intentional-record",actionTier:"support",reasons:t};let s=x(i,["command","cli","usage","example","run","workflow"]);return s.length>0?(t.push(`guide/reference terms near citation: ${s.join(", ")}`),{citationKind:"guide-reference",actionTier:"signal",reasons:t}):(t.push(e.length>0?"citation appears in prose without config or guide markers":"citation context unavailable"),{citationKind:"behavioral-claim",actionTier:"direct",reasons:t})}function Se(e,i,t){let n;try{n=le(`${e.config.projectRoot}/${i}`,"utf-8").split(/\r?\n/)}catch{return[]}let o=t.flatMap($e),s=[];for(let r=0;r<n.length;r+=1){let l=n[r]??"";o.some(a=>l.includes(a))&&s.push(q(n,r))}return s}function $e(e){let i=e.split("/");return[e,`./${e}`,i.slice(-3).join("/"),i.slice(-2).join("/")].filter((t,n,o)=>t.length>0&&o.indexOf(t)===n)}function De(e){switch(e){case"behavioral-claim":return"a behavioral doc claim";case"configuration-example":return"a configuration example";case"guide-reference":return"a guide reference";case"intentional-record":return"an intentional record"}}function we(e,i){switch(e){case"behavioral-claim":return`Re-read ${i} and update the behavioral claim or citation.`;case"configuration-example":return`Verify the configuration example in ${i} still points at the intended file; update only if the example target changed.`;case"guide-reference":return`Verify the guide reference in ${i} still sends readers to the right implementation or command surface.`;case"intentional-record":return`Verify the intentional citation in ${i} is still meant to name this file.`}}function Re(e,i,t){let n=O(t),o=new Set;for(let s of i)Te(e,s,n.get(s)??[])&&o.add(s);return o}function Te(e,i,t){if(t.length===0)return!1;if(!ke.test(i))return!0;let n=`${e.config.projectRoot}/${i}`;if(!be(n))return!0;let o=le(n,"utf-8").split(/\r?\n/),s=Fe(o);for(let r of t)for(let l=r.startLine;l<=r.endLine;l+=1)if((o[l]??"").trim()!==""&&!s.has(l))return!0;return!1}var ke=/\.(?:[cm]?[jt]sx?)$/i;function Fe(e){let i=new Set,t=!1;for(let n=0;n<e.length;n+=1){let o=e[n].trim();!t&&ve(o)&&(t=!0),t&&(i.add(n),o.endsWith(";")&&(t=!1))}return i}function ve(e){return/^import(?:\s|$)/.test(e)||/^export(?:\s+type)?\s+(?:\*|\{)/.test(e)}import{existsSync as xe,readFileSync as Ae,writeFileSync as Ge}from"fs";import{isAbsolute as je,join as Ee}from"path";var Le=75e3,Be=5e3,Ke=2500;function Ne(e){let i=oe(e);return i.symbols>=Le||i.documents>=Be?Ke:void 0}var Pe=".scipquery-baseline.json";function G(e,i){return i&&je(i)?i:Ee(e.config.projectRoot,i??Pe)}function fe(e,i={}){let{scope:t}=i,n=Ne(e),o=[],s=J(e,{scope:t,...S.dead,scanLimit:n});for(let r of s.symbols)F(e,r.relativePath)||v(e,r.symbol,r.relativePath)||r.kind==="dead-code"&&o.push(`dead:${r.relativePath}:${r.shortName}`);for(let r of X(e,{scope:t,...S.isolated,scanLimit:n}))F(e,r.relativePath)||v(e,r.symbol,r.relativePath)||o.push(`isolated:${r.relativePath}:${r.shortName}`);for(let r of Y(e,{scope:t}))r.kind==="real"&&o.push(`cycle:${Ie(r.path)}`);for(let r of ie(e,{scope:t,...S.similar,scanLimit:n}))o.push(`similar:${[r.symbolA,r.symbolB].sort().join("|")}`);for(let r of Q(e,{scope:t,...S.extract,scanLimit:n}))o.push(`extract:${r.relativePath}:${r.shortName}`);for(let r of re(e,{scope:t,...S.wrappers,scanLimit:n}))o.push(`wrapper:${r.file}:${r.shortName}`);for(let r of ee(e,{scope:t,...S.passthroughs,scanLimit:n}))o.push(`passthrough:${r.file}:${r.shortName}`);for(let r of ne(e,{scope:t,...S.stale,scanLimit:n}))o.push(`stale:${r.file}:${r.shortName}`);for(let r of Z(e,{scope:t,...S.drift,includePatternDeviations:!1}).results)o.push(`drift:${r.kind}:${r.file}:${r.dep}`);return[...new Set(o)].sort()}function Ie(e){if(e.length===0)return"";let i=0;for(let t=1;t<e.length;t++)e[t]<e[i]&&(i=t);return[...e.slice(i),...e.slice(0,i)].join(">")}function Bt(e,i={}){let t=fe(e,{scope:i.scope}),n=G(e,i.path);return Ge(n,JSON.stringify({version:1,findings:t},null,2)+`
|
|
3
|
-
`),{path:n,findingCount:t.length}}function de(e,i={}){let t=G(e,i.path);if(!xe(t))throw new Error(`No baseline found at ${t}. Create one with: scip-query health --write-baseline`);let n=JSON.parse(Ae(t,"utf-8")),o=new Set(n.findings??[]),s=fe(e,{scope:i.scope}),r=new Set(s);return{baselinePath:t,baselineCount:o.size,current:s,newFindings:s.filter(l=>!o.has(l)),fixedFindings:[...o].filter(l=>!r.has(l))}}var Qt=["echo","incomplete-migration","co-change-partner","doc-reference","unused-params","new-dead","baseline"];function Xt(e,i={}){let t=i.base??"HEAD",{minTogether:n=6,minConfidence:o=.6,maxEchoChecks:s=Number.POSITIVE_INFINITY,maxHelpers:r=Number.POSITIVE_INFINITY,minSimilarity:l=.8,includeBaseline:a=!1,scanLimit:c}=i,y=i.semantic!==!1,h=new Set(i.skip??[]),f=V(e,{base:t}),m=U(e,{base:t,plan:f}),g=m.changedFiles,d=new Set(g),u=new Set(f.changedFileLines),b=new Set([...d,...u]),C=L(e.config.projectRoot,t,B(f,g)),T=dt(e.config.projectRoot,t,f,C),p={base:t,changedFiles:g,changedSymbols:m.changedSymbols.length,checksRun:[],skipped:[],suppressed:[],findings:[],rootCauseGroups:[],note:m.summary.note};if(g.length===0)return p;let $=(K,me)=>{if(h.has(K)){p.skipped.push({check:K,reason:"skipped via --skip"});return}me()};return $("echo",()=>Ve(e,m.changedSymbols,d,T,s,l,c,y,p)),$("incomplete-migration",()=>tt(e,t,f,r,c,y,C,p)),$("co-change-partner",()=>it(e,b,n,o,p)),$("doc-reference",()=>at(e,d,u,f.changedRanges,p)),$("unused-params",()=>ct(e,g,p)),$("new-dead",()=>lt(e,m.changedSymbols,T,p)),a&&$("baseline",()=>gt(e,p)),Oe(p,e.config.suppressions??[]),p.rootCauseGroups=He(p.findings),p}function He(e){let i=new Map;for(let t of e){let n=t.groupKey??`${t.check}:${t.id}`,o=i.get(n);o||(o={groupKey:n,check:t.check,severity:t.severity,actionTier:t.actionTier,sourceAnalyzer:t.sourceAnalyzer,rootCauseKey:t.rootCauseKey,count:0,findingIds:[],files:new Set,relatedFiles:new Set,message:t.message,remediation:t.remediation},i.set(n,o)),o.count+=1,o.findingIds.push(t.id),o.severity=_e(o.severity,t.severity),o.actionTier=ze(o.actionTier,t.actionTier),t.file&&o.files.add(t.file);for(let s of t.relatedFiles??[])o.relatedFiles.add(s)}return[...i.values()].map(t=>({...t,files:[...t.files].sort(),relatedFiles:[...t.relatedFiles].sort()})).sort((t,n)=>n.count-t.count||j(n.severity)-j(t.severity)||t.groupKey.localeCompare(n.groupKey))}function _e(e,i){return j(i)>j(e)?i:e}function j(e){return e==="error"?2:e==="warning"?1:0}function ze(e,i){return e?i&&ue(i)>ue(e)?i:e:i}function ue(e){return e==="direct"?2:e==="signal"?1:0}function Oe(e,i){if(i.length===0||e.findings.length===0)return;let t=[];for(let n of e.findings){let o=i.find(s=>Ue(s,n));o?e.suppressed.push({finding:n,suppression:o}):t.push(n)}e.findings=t}function Ue(e,i){return!e.reason||e.reason.trim()===""||e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()||e.id&&e.id!==i.id||e.check&&e.check!==i.check||e.file&&e.file!==i.file?!1:!!(e.id||e.check)}function R(e,i){e.findings.push({...i,suppressionHint:`scip-query: ignore ${i.check} ${i.id} -- <reason>`})}function Ve(e,i,t,n,o,s,r,l,a){a.checksRun.push("echo");for(let c of i.slice(0,o)){if(!P(c.symbol)||n(c))continue;let y=te(e,c.symbol,{minSimilarity:s,limit:5,scanLimit:r,semantic:l}),h=[];for(let d of y){let u=d.fileA===c.file?d.fileB:d.fileA,b=d.fileA===c.file?d.shortNameB:d.shortNameA,C=d.fileA===c.file?d.symbolB:d.symbolA;t.has(u)||h.push({otherFile:u,otherShort:b,otherSymbol:C,similarity:d.similarity,similarityBasis:d.similarityBasis??"callees",sharedEvidence:d.sharedCallees})}if(h.length===0)continue;let f=h[0],m=D("echo",c.symbol,c.file,...h.map(d=>`${d.otherSymbol}|${d.otherFile}`).sort()),g=qe(c,h);R(a,{id:m,groupKey:m,actionTier:g,check:"echo",severity:"warning",evidence:"heuristic",confidence:f.similarity,file:c.file,symbol:c.symbol,relatedFiles:[...new Set(h.map(d=>d.otherFile))].sort(),message:Qe(c,h),why:Xe(c,h),remediation:et(g,c.shortName,f.otherShort)})}i.length>o&&a.skipped.push({check:"echo",reason:`echo check capped at ${o} of ${i.length} changed symbols`})}function qe(e,i){return i.some(n=>We(e.symbol,n))?"direct":"signal"}function We(e,i){if(i.similarityBasis!=="source-tokens"||i.similarity<.98||i.sharedEvidence.length>8)return!1;let t=k(e),n=k(i.otherSymbol);return!t||!n?!1:t===n?!0:Ze(i.sharedEvidence)?!1:Ye(t,n)}function Ye(e,i){let t=he(e),n=he(i);if(t.length===0||n.length===0)return!1;let o=new Set(n),s=t.filter(r=>o.has(r)).length;return s>=2&&s/Math.min(t.length,n.length)>=.5}function he(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(i=>i.toLowerCase()).filter(i=>i.length>=2)}var Je=new Set(["bytes","crypto","hex","num","random","secret","to","token"]);function Ze(e){return e.length>=3&&e.every(i=>Je.has(i.toLowerCase()))}function Qe(e,i){let t=i[0],n=Math.round(t.similarity*100);return i.length===1?`${e.shortName} (${e.file}) is ${n}% similar to established ${t.otherShort} (${t.otherFile})`:`${e.shortName} (${e.file}) resembles ${i.length} established symbol(s); strongest is ${n}% similar to ${t.otherShort} (${t.otherFile})`}function Xe(e,i){let t=[`${e.shortName} was changed in this diff.`];for(let n of i.slice(0,3))t.push(`${n.otherShort} is outside this diff and scored ${Math.round(n.similarity*100)}% similar by ${n.similarityBasis} evidence.`),t.push(`Shared evidence: ${n.sharedEvidence.slice(0,5).join(", ")||"(none listed)"}.`);return i.length>3&&t.push(`${i.length-3} additional similar match(es) grouped into this finding.`),t}function et(e,i,t){return e==="direct"?`Extract or reuse the shared behavior with ${t}, or keep the duplicate with a suppression reason.`:`Review whether ${i} is intentionally parallel to the established implementation(s); extract shared behavior only if the product semantics match.`}function tt(e,i,t,n,o,s,r,l){let a=se(e,{base:i,maxHelpers:n,diffPlan:t,scanLimit:o,semantic:s,baseContentAt:r});if(!a.available){l.skipped.push({check:"incomplete-migration",reason:"no git history"});return}l.checksRun.push("incomplete-migration"),a.note&&l.skipped.push({check:"incomplete-migration",reason:a.note});for(let c of a.findings){let y=c.leftovers.map(u=>`${u.shortName} (${u.file}, ${Math.round(u.containment*100)}% helper / ${Math.round(u.siteCoverage*100)}% site, ${u.migrationScope})`).join(", "),h=c.leftovers.map(u=>`${u.shortName}: ${u.migrationScope} (${u.migrationScopeReasons[0]})`).join("; "),f=[...c.migratedFiles,...c.leftovers.map(u=>u.file)],m=c.leftovers.length===0?void 0:Math.max(...c.leftovers.map(u=>Math.min(u.containment,u.siteCoverage))),g=c.leftovers.some(u=>u.migrationScope==="possible-subtype"),d=D("incomplete-migration",c.helperSymbol,c.helperFile,f.join("|"));R(l,{id:d,check:"incomplete-migration",severity:"warning",evidence:"heuristic",confidence:m,file:c.helperFile,symbol:c.helperSymbol,relatedFiles:f,message:`new helper ${c.helperShortName} (${c.helperFile}) is wired into ${c.migratedFiles.length} file(s), but ${c.leftovers.length} similar un-migrated site(s) remain: ${y}`,why:[`${c.helperShortName} is new in this diff and already referenced by ${c.migratedFiles.join(", ")}.`,`Helper shape: ${c.helperShape}; ${c.specificHelperCalleeCount}/${c.helperCalleeCount} helper callees are specific enough to score.`,`Unchanged site(s) still contain the helper's callee pattern: ${y}.`,`Migration scope hints: ${h}.`],remediation:g?`Migrate same-scope sites to ${c.helperShortName}; review possible subtype/variant sites before applying the helper.`:`Migrate the remaining sites to ${c.helperShortName}, or confirm they are intentionally different.`})}}function it(e,i,t,n,o){let s=M(e,i,{minTogether:t,minConfidence:0,maxFilesPerCommit:20});if(!s){o.skipped.push({check:"co-change-partner",reason:"no git history"});return}o.checksRun.push("co-change-partner");let r=new Set,l;for(let a of s){let c=i.has(a.fileA),y=i.has(a.fileB);if(c===y)continue;let h=c?a.fileA:a.fileB,f=c?a.fileB:a.fileA,m=c?a.changesA:a.changesB,g=m>0?a.together/m:0;if(g<n||E(f)||E(h)||!ge(`${e.config.projectRoot}/${f}`))continue;let d=`${h}|${f}`;if(r.has(d))continue;r.add(d);let u=D("co-change-partner",h,f,String(a.together)),b=H(h,f),C=_({fileA:h,fileB:f,together:a.together,confidence:g,commitScope:a.commitScope,recency:a.recency,subjectContext:a.subjectContext},b,(l??=z(e))(h,f)),T=[h,f].sort().join("|");o.findings.push({id:u,check:"co-change-partner",severity:"warning",evidence:"change-graph",actionTier:"signal",groupKey:`co-change-partner:${T}`,confidence:g,file:h,relatedFiles:[f],sourceAnalyzer:"co-change",rootCauseKey:T,partnerClass:b.partnerClass,partnerClassReasons:b.reasons,commitScope:a.commitScope,recency:a.recency,focusedTogether:a.focusedTogether,broadTogether:a.broadTogether,broadCommitRatio:a.broadCommitRatio,lastTogetherAt:a.lastTogetherAt,recentTogether:a.recentTogether,subjectContext:a.subjectContext,...C?{declaredCouplingSuggestion:C}:{},message:`${h} changed, but ${f} did not \u2014 they change together ${a.together}x (${Math.round(g*100)}% of the time)`,why:[`${h} is in this diff and ${f} is not.`,`Git history shows ${a.together} co-change(s), which is ${Math.round(g*100)}% of changes to the edited side.`,`History context: ${nt(a)}.`,`Subject context: ${ot(a.subjectContext)}.`,...rt(a),`Partner class: ${b.partnerClass} (${b.reasons.join("; ")}).`],remediation:C?`Update ${f} alongside this change, declare the coupling "${C.name}", or confirm the coupling no longer holds.`:`Update ${f} alongside this change, or confirm the coupling no longer holds.`})}}function nt(e){return`${e.commitScope}/${e.recency}; ${e.focusedTogether} focused, ${e.broadTogether} broad-sweep (${Math.round(e.broadCommitRatio*100)}% broad), ${e.recentTogether} recent, last ${st(e.lastTogetherAt)}`}function ot(e){let i=e.subjectLabels.length>0?e.subjectLabels.slice(0,5).join(", "):"none inferred",t=e.issueRefs.length>0?e.issueRefs.slice(0,5).join(", "):"none",n=e.sampleSubjects.length>0?e.sampleSubjects.slice(0,3).map(o=>`"${o}"`).join("; "):"none";return`labels ${i}; refs ${t}; samples ${n}; external issue/PR labels ${e.externalIssueLabelStatus}`}function rt(e){let i=[];return e.commitScope==="broad-sweep"&&i.push("Broad-sweep history is weaker than focused co-edits; confirm this is a real coordination contract."),e.recency==="stale"&&i.push("The pair has no co-change in the recent history window; confirm the coupling still holds."),i}function st(e){return e<=0?"unknown":new Date(e*1e3).toISOString().slice(0,10)}function at(e,i,t,n,o){o.checksRun.push("doc-reference");let s=w.referenceTargets(e,i,n);if(s.size!==0)for(let r of W(e,s)){if(t.has(r.doc))continue;let l=r.citedClaims.length>0?r.citedClaims:w.citationContexts(e,r.doc,r.cited),a=w.classifyCitation(l),c=D("doc-reference",r.doc,r.cited.join("|"));R(o,{id:c,check:"doc-reference",severity:"warning",evidence:"change-graph",actionTier:a.actionTier,confidence:1,file:r.doc,relatedFiles:r.cited,citationKind:a.citationKind,citationKindReasons:a.reasons,citedClaims:l,message:`${r.doc} cites ${r.cited.join(", ")} as ${w.citationKindLabel(a.citationKind)} \u2014 changed in this diff, doc untouched`,why:[`${r.cited.join(", ")} changed in this diff.`,`${r.doc} cites the changed file(s) but was not updated in the same diff.`,...a.reasons.map(y=>`Citation kind evidence: ${y}`)],remediation:w.citationRemediation(a.citationKind,r.doc)})}}function ct(e,i,t){t.checksRun.push("unused-params");for(let n of ae(e,{files:i,limit:50})){let o=D("unused-params",n.symbol,n.file,n.unusedTrailing.join("|"));R(t,{id:o,check:"unused-params",severity:"warning",evidence:"heuristic",confidence:.85,file:n.file,startLine:n.startLine,endLine:n.endLine,symbol:n.symbol,message:`${n.shortName} (${n.file}) has trailing unused parameter(s): ${n.unusedTrailing.join(", ")}`,why:[`${n.shortName} is in a changed file.`,`The trailing parameter(s) ${n.unusedTrailing.join(", ")} are not referenced in the function body.`],remediation:"Drop the unused trailing parameters and their call-site arguments."})}}function lt(e,i,t,n){n.checksRun.push("new-dead");let o=new I(e);for(let s of i){if(t(s)||s.fanIn>0||o.fileKind(s.file)==="test"||F(e,s.file)||v(e,s.symbol,s.file)||ft(s.symbol))continue;let r=D("new-dead",s.symbol,s.file);R(n,{id:r,check:"new-dead",severity:"warning",evidence:"graph-fact",confidence:.9,file:s.file,symbol:s.symbol,message:`${s.shortName} (${s.file}) was changed but has zero indexed consumers`,why:[`${s.shortName} is a changed production symbol.`,"The index reports zero consumers for this symbol.","The symbol is not in a detected entry surface or configured live root."],remediation:"Wire it up, or remove it before it becomes permanent dead code."})}}function ft(e){if(N(e)!=="type")return!1;let i=k(e);return i.startsWith("_Assert")||i.startsWith("Assert")}function dt(e,i,t,n){let o=new Map(t.renamedFiles.map(r=>[r.to,r.from])),s=n??L(e,i,B(t));return r=>{let l=o.get(r.file)??r.file,a=k(r.symbol);if(!a)return!1;let c=s(l);return c!==null&&ut(c,a)}}function ut(e,i){return new RegExp(`\\b${ht(i)}\\b`).test(e)}function ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gt(e,i){if(!ge(G(e))){i.skipped.push({check:"baseline",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}i.checksRun.push("baseline");let t=de(e);for(let n of t.newFindings){let o=ce(n),s=D("baseline",n);R(i,{id:s,groupKey:`baseline:${o.sourceAnalyzer}:${o.rootCauseKey}`,check:"baseline",severity:"error",evidence:"baseline",actionTier:o.actionTier,confidence:1,file:o.file,relatedFiles:o.relatedFiles.length>0?o.relatedFiles:void 0,sourceAnalyzer:o.sourceAnalyzer,rootCauseKey:o.rootCauseKey,message:`new ${o.label} vs committed baseline: ${n}`,why:["A committed health baseline exists.","The current health result contains a finding not present in that baseline.",`Underlying analyzer: ${o.sourceAnalyzer}.`,`Inherited action tier: ${o.actionTier}.`,`Root cause key: ${o.rootCauseKey}.`,...o.why],remediation:o.remediation})}}function D(e,...i){return`SQ${Me("sha256").update([e,...i].join("\0")).digest("hex").slice(0,12).toUpperCase()}`}export{fe as a,Bt as b,de as c,Qt as d,Xt as e,dt as f};
|
|
4
|
-
//# sourceMappingURL=chunk-A6IDHNMC.js.map
|
package/dist/chunk-FRPEPTYJ.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as j,b as w,e as A,f as T,g as M,h as G,i as U}from"./chunk-YWOOQ4FF.js";import{b as E}from"./chunk-B75HZHUP.js";import{a as R}from"./chunk-GBEYTDY5.js";import{a as P}from"./chunk-SULEXAHO.js";import{a as L}from"./chunk-PTQVNJ4Q.js";import{c as b,d as D,g as I}from"./chunk-JM72FNGA.js";import{a as _,b as v}from"./chunk-DS6QEB3G.js";import{b as q,d as $,e as O}from"./chunk-XUGQU7PM.js";import{d as C}from"./chunk-7S5E7KWT.js";function Ve(e,n,t={}){let{minSimilarity:i=.4,limit:r=20}=t,o=ue(e,n,{semantic:t.semantic!==!1});if(!o)return[];if(!I(o.symbol))return[];if(o.callees.size===0)return K(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit});let s=oe(e,o,i,{scanLimit:t.scanLimit,semantic:t.semantic!==!1});return s.length>0?s.slice(0,r):K(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit})}function oe(e,n,t,i){let r=Z(e,{minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),o=pe(n,r),s=ae(n,r),a=T(s),l=M(n.callees,s),c=[];for(let u of o){if(u.callees.size<3)continue;let m=M(u.callees,s),d=H(n,u,s,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0,medianIdf:a,magnitudeA:l,magnitudeB:m});d&&c.push(d)}return c.sort((u,m)=>m.similarity-u.similarity),c}function ae(e,n){let t=new Map(n.docFreq);for(let i of e.callees)t.set(i,(t.get(i)??0)+1);return A(t,n.corpus.length+1)}function H(e,n,t,i){let r=i.magnitudeA===void 0||i.magnitudeB===void 0?G(e.callees,n.callees,t,{medianIdf:i.medianIdf}):U(e.callees,n.callees,t,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB}),{similarity:o,significantShared:s,trivialShared:a}=r;if(o<i.minSimilarity)return null;let l=s.length+a.length;if(s.length<i.requireSignificantShared&&l<i.requireSharedCount)return null;let c=s.length>0?s:a,u=J(c,"callees");return{symbolA:e.symbol,shortNameA:b(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:b(n.symbol),fileB:n.file,similarity:o,similarityBasis:"callees",sharedCallees:c.map(b),uniqueToA:[...w(e.callees,n.callees)].map(b),uniqueToB:[...w(n.callees,e.callees)].map(b),...u}}function We(e,n={}){let{minSimilarity:t=.5,limit:i=20,scope:r,minCallees:o=4,crossFileOnly:s=!1,scanLimit:a}=n,l=Z(e,{minCallees:o,scope:r,scanLimit:a,semantic:n.semantic!==!1}),c=l.corpus,u=n.focusFiles,m=[],d=0;for(let g=0;g<c.length;g+=1){let f=c[g],x=u?.has(f.file)??!1,y=l.weightedMagnitudes[g],F=new Set;for(let S of f.callees){let p=l.candidateIndexesByCallee.get(S);if(p)for(let h of p)h<=g||u&&!x&&!u.has(c[h].file)||F.add(h)}for(let S of F){let p=c[S];if(s&&f.file===p.file)continue;if(f.paramCount>=0&&p.paramCount>=0){let re=Math.abs(f.paramCount-p.paramCount),se=Math.max(2,Math.ceil(Math.max(f.paramCount,p.paramCount)*.5));if(re>se)continue}let h=H(f,p,l.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:l.medianIdf,magnitudeA:y,magnitudeB:l.weightedMagnitudes[S]});h&&(le(m,h,i,d),d+=1)}}return m.sort((g,f)=>f.result.similarity-g.result.similarity||g.order-f.order),m.map(g=>g.result)}function le(e,n,t,i){if(t<=0)return;if(e.length<t){e.push({result:n,order:i});return}let r=0;for(let s=1;s<e.length;s+=1){let a=e[s],l=e[r];(a.result.similarity<l.result.similarity||a.result.similarity===l.result.similarity&&a.order>l.order)&&(r=s)}let o=e[r];n.similarity<=o.result.similarity||(e[r]={result:n,order:i})}var ce=["ScipDatabase#all","ScipDatabase#get","ScipDatabase#prepare","ScipDatabase#pathExclusionsFor","ScipDatabase#isIgnored","ScipDatabase#symbolNoiseFor","PerDbValue#get","PerDbValue#has",":storage:db:ScipDatabase:all",":storage:db:ScipDatabase:get",":storage:db:ScipDatabase:prepare",":storage:db:ScipDatabase:pathExclusionsFor",":storage:db:ScipDatabase:isIgnored",":storage:db:ScipDatabase:symbolNoiseFor",":storage:per-db-cache:PerDbValue:get",":storage:per-db-cache:PerDbValue:has"];function ue(e,n,t){let i=L(e,n);if(!i||!I(i.symbol))return null;let r=new R(e),o=P(e,i,{semantic:t.semantic});return{symbol:i.symbol,file:i.relativePath,callees:X(o.map(s=>s.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}var me=C("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),fe=C("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function ge(e,n){let{minCallees:t,scope:i,excludeSymbol:r,scanLimit:o}=n,s=n.semantic!==!1,a=me.get(e,()=>new Map),l=`${t}|${i??""}|${o??""}|${s}`,c=a.get(l);return c||(c=be(e,{minCallees:t,scope:i,scanLimit:o,semantic:s}),a.set(l,c)),r===void 0?c:c.filter(u=>u.symbol!==r)}function Z(e,n){let{minCallees:t,scope:i,scanLimit:r}=n,o=n.semantic!==!1,s=fe.get(e,()=>new Map),a=`${t}|${i??""}|${r??""}|${o}`,l=s.get(a);return l||(l=de(ge(e,{minCallees:t,scope:i,scanLimit:r,semantic:o})),s.set(a,l)),l}function de(e){let n=new Map;for(let s of e)for(let a of s.callees)n.set(a,(n.get(a)??0)+1);let t=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=A(n,e.length),r=e.map(s=>M(s.callees,i)),o=new Map;for(let s=0;s<e.length;s+=1){let a=e[s];for(let l of a.callees){if((n.get(l)??0)>t)continue;let c=o.get(l);c||(c=[],o.set(l,c)),c.push(s)}}return{corpus:e,candidateIndexesByCallee:o,docFreq:n,idfWeights:i,weightedMagnitudes:r,medianIdf:T(i),ubiquityThreshold:t}}function pe(e,n){let t=new Map;for(let i of e.callees)for(let r of n.candidateIndexesByCallee.get(i)??[]){let o=n.corpus[r];o.symbol!==e.symbol&&t.set(o.symbol,o)}return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function be(e,n){let{minCallees:t,scope:i,scanLimit:r,semantic:o}=n,s=new R(e),a=E(s.productionCallableDefinitions({scope:i,minLoc:5,sortByLocDesc:typeof r=="number"&&r>0}),r),l=s.calleeMap(a,{semantic:o});return a.map(c=>({symbol:c.symbol,file:c.relativePath,callees:X((l.get(c.symbolId)??[]).map(u=>u.symbol)),paramCount:s.callableSignature(c)?.paramCount??-1})).filter(c=>c.callees.size>=t)}function X(e){return new Set([...e].filter(n=>!ye(n)))}function ye(e){return ce.some(n=>e.includes(n))}function K(e,n,t){let i=Ce(e,n);if(!i||i.tokens.size<3)return[];let r=t.minSimilarity>=.5?t.minSimilarity:.3,o=[],s=ve(i,Re(e,{scanLimit:t.scanLimit}));for(let a of s){if(a.symbol===i.symbol||a.tokens.size<3)continue;let l=j(i.tokens,a.tokens);if(l.size<2)continue;let c=new Set([...i.tokens,...a.tokens]),u=c.size>0?l.size/c.size:0;u<r||o.push({symbolA:i.symbol,shortNameA:b(i.symbol),fileA:i.file,symbolB:a.symbol,shortNameB:b(a.symbol),fileB:a.file,similarity:u,similarityBasis:"source-tokens",sharedCallees:[...l].sort(),uniqueToA:[...w(i.tokens,a.tokens)].sort(),uniqueToB:[...w(a.tokens,i.tokens)].sort(),...J([...l],"source-tokens")})}return o.sort((a,l)=>l.similarity-a.similarity||a.shortNameB.localeCompare(l.shortNameB)),o.slice(0,t.limit)}function J(e,n){let t=e.flatMap(B),i=e.flatMap(y=>V(y,n)),r=N(t,Q),o=N(t,Y),s=N(i,z),a=[...new Set(i.filter(W))],l=e.filter(y=>{let F=V(y,n);return F.some(S=>z.has(S))&&F.some(W)}).length,c=[];r.length>0&&c.push(`access/query scaffolding: ${r.slice(0,5).join(", ")}`),o.length>0&&c.push(`framework/generic scaffolding: ${o.slice(0,5).join(", ")}`),s.length>0&&c.push(`domain behavior verbs: ${s.slice(0,5).join(", ")}`),s.length>0&&a.length>0&&c.push(`domain-specific terms: ${a.slice(0,5).join(", ")}`);let u=n==="source-tokens"&&t.length>0&&t.every(y=>ee.has(y));u&&c.push("shared source tokens are generic scaffolding");let m=s.length>0&&a.length>0,d=r.length+o.length>0,g=n==="callees"&&m&&e.length>=4&&a.length>=4&&l>=2,f=g?"domain-behavior":m?d?"mixed":"domain-behavior":r.length>0?"access-query-scaffolding":o.length>0||u?"framework-scaffolding":"structural-overlap";f==="structural-overlap"&&e.length>0&&c.push(`shared ${n} overlap has no recognized domain or scaffolding category`);let x=f==="domain-behavior"&&(e.length>=3||g)?"direct":"signal";return{evidenceClass:f,actionTier:x,evidenceClassReasons:c,recommendation:Se(f,x)}}function Se(e,n){return n==="direct"?"Shared domain behavior looks concrete; review for an extract/reuse opportunity.":e==="mixed"?"Shared evidence mixes domain behavior with scaffolding; review semantics before extracting anything.":e==="access-query-scaffolding"?"Shared evidence is mostly access/query scaffolding; compare product semantics before reusing code.":e==="structural-overlap"?"Shared structure has no domain or scaffolding classification; inspect names and behavior before reusing code.":"Shared evidence is mostly framework or generic scaffolding; treat as a contextual signal."}function N(e,n){return[...new Set(e.filter(t=>n.has(t)))]}function B(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>1)}function V(e,n){if(n==="source-tokens")return B(e);let t=D(e);return B(t.length>0?t:he(e))}function he(e){return e.replace(/[()`]/g," ").replace(/\.[a-z][a-z0-9]+(?=\s|$)/gi," ").split(/[:/\\\s]+/).map(i=>i.trim()).filter(i=>/[A-Za-z]/.test(i)).at(-1)?.replace(/\.$/,"")??e}function W(e){return e.length>3&&!z.has(e)&&!Q.has(e)&&!Y.has(e)&&!ee.has(e)&&!Fe.has(e)}var z=new Set(["archive","assign","book","cancel","create","delete","ensure","export","import","notify","persist","publish","restore","schedule","send","set","submit","sync","update","upload","validate","write"]),Q=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),Y=new Set(["bytes","computed","crypto","describe","effect","expect","fetch","filter","hex","hook","json","map","mounted","on","promise","random","react","reduce","ref","render","state","test","token","trim","uuid","vue","watch"]),ee=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),Fe=new Set(["best","backend","conflict","database","effect","effects","error","errors","frontend","found","helpers","javascript","module","modules","scip","shared","source","typescript","utils","with","workflow","workflows"]);function Ce(e,n){let t=L(e,n);if(!t||!I(t.symbol))return null;let i=we(e,t);return i?{symbol:t.symbol,file:t.relativePath,tokens:i}:null}function we(e,n){let t=D(n.symbol),i=Ee(e,n.relativePath,n.startLine,n.endLine,t),r=te(i,t);return r.size>0?r:null}var ke=C("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),xe=C("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function ne(e){return`${e.scanLimit??""}`}function Ie(e,n={}){let t=ke.get(e,()=>new Map),i=ne(n),r=t.get(i);return r||(r=De(e,n),t.set(i,r)),r}function Re(e,n={}){let t=xe.get(e,()=>new Map),i=ne(n),r=t.get(i);return r||(r=Me(Ie(e,n)),t.set(i,r)),r}function Me(e){let n=new Map;for(let r of e)for(let o of r.tokens)n.set(o,(n.get(o)??0)+1);let t=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=new Map;for(let r of e)for(let o of r.tokens){if((n.get(o)??0)>t)continue;let s=i.get(o);s||(s=[],i.set(o,s)),s.push(r)}return{corpus:e,candidateByToken:i,docFreq:n,ubiquityThreshold:t}}function ve(e,n){let t=new Map;for(let i of e.tokens)for(let r of n.candidateByToken.get(i)??[])r.symbol!==e.symbol&&t.set(r.symbol,r);return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function De(e,n={}){let t=new R(e),{scanLimit:i}=n,r=E(t.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return Le(e,r)}function Le(e,n){let t=new Map;for(let r of n){let o=t.get(r.relativePath)??[];o.push(r),t.set(r.relativePath,o)}let i=new Map;for(let[r,o]of t){let s=_(e,r);if(!s)continue;let a=q(e,r,s),l=Te(e,r,a),c=!1,u=null;for(let m of o){let d=Ae(m),g=l.get(d),f=g?new Set(g.tokens):null;f||(u??=v(e,r),f=te(ie(u,m.startLine,m.endLine,m.leaf),m.leaf),l.set(d,{key:d,symbol:m.symbol,startLine:m.startLine,endLine:m.endLine,leaf:m.leaf,tokens:[...f].sort()}),c=!0),f.size>0&&i.set(m.symbol,{symbol:m.symbol,file:m.relativePath,tokens:f})}c&&Ne(e,r,a,l)}return n.map(r=>i.get(r.symbol)).filter(r=>!!r)}function Ee(e,n,t,i,r){let o=v(e,n);return o.length===0?"":ie(o,t,i,r)}function ie(e,n,t,i){if(t>=n&&t-n<=12)return e.slice(n,t+1).join(`
|
|
2
|
-
`);let r=[new RegExp(`\\bdef\\s+${k(i)}\\b`),new RegExp(`\\bfun\\s+${k(i)}\\b`),new RegExp(`\\bfn\\s+${k(i)}\\b`),new RegExp(`\\bfunction\\s+${k(i)}\\b`),new RegExp(`\\b${k(i)}\\s*\\(`)],o=e.findIndex(s=>r.some(a=>a.test(s)));if(o>=0){let s=o;for(let a=o+1;a<e.length&&a<=o+8;a++){let l=e[a]??"";if(a>o&&ze(l)||(s=a,l.trim()===""&&a>o+1))break}return e.slice(o,s+1).join(`
|
|
3
|
-
`)}return e.slice(n,Math.min(e.length,n+8)).join(`
|
|
4
|
-
`)}function Ae(e){return`${e.symbol}\0${e.startLine}\0${e.endLine}\0${e.leaf}`}function Te(e,n,t){let i=$(e,"source-fingerprints",n,t);if(!i)return new Map;try{let r=JSON.parse(i);if(!Array.isArray(r.entries))return new Map;let o=new Map;for(let s of r.entries){if(!s||typeof s.key!="string"||typeof s.symbol!="string"||typeof s.startLine!="number"||typeof s.endLine!="number"||typeof s.leaf!="string"||!Array.isArray(s.tokens)||!s.tokens.every(a=>typeof a=="string"))return new Map;o.set(s.key,s)}return o}catch{return new Map}}function Ne(e,n,t,i){let r={entries:[...i.values()].sort((o,s)=>o.key.localeCompare(s.key))};O(e,"source-fingerprints",n,t,JSON.stringify(r))}function te(e,n){if(!e)return new Set;let t=new Set(["public","private","protected","final","static","class","def","fun","fn","function","return","string","bool","boolean","void","unit","self","this","new","const","let","var","end","pub"]),i=Be(n),o=e.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(s=>s.trim()).filter(s=>s.length>1).filter(s=>!t.has(s)).filter(s=>!i.has(s));return new Set(o)}function Be(e){return new Set(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(n=>n.toLowerCase()).filter(n=>n.length>1))}function ze(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}function k(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{Ve as a,ae as b,We as c,le as d,ge as e,Z as f,de as g,pe as h,X as i,J as j};
|
|
5
|
-
//# sourceMappingURL=chunk-FRPEPTYJ.js.map
|
package/dist/chunk-GBEYTDY5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as R,f as j,g as V}from"./chunk-C5CTSJ6X.js";import{a as F}from"./chunk-BGBBVSH4.js";import{b as z,c as J,d as Q}from"./chunk-UQLFQLAF.js";import{c as _}from"./chunk-SULEXAHO.js";import{a as O,j as H,k as W,m as L,n as Y}from"./chunk-F6ICF7HL.js";import{a as q}from"./chunk-VUKC6F77.js";import{f as h,h as D,i as G}from"./chunk-4N4WONI4.js";import{f as M,g as E,i as K,j as B}from"./chunk-JM72FNGA.js";import{a as w,f as g}from"./chunk-72KY2ZFO.js";import{a as S,b as P}from"./chunk-HF25DFSC.js";import{a as N,d as y}from"./chunk-DS6QEB3G.js";import{c as A}from"./chunk-A536TEU4.js";import{a as k}from"./chunk-64MNV6AB.js";function U(t,e,i){let o=e.identifierResolution==="strict"?L:Y,s=e.candidateNames?H(e.candidateNames):null;for(let n of e.paths)if(!(!S(n)&&!(e.includeVueSfc&&P(n)))&&!t.isIgnored(n)&&!e.skipPath?.(n))try{if(s&&!W(N(t,n),s))continue;let d=(a,c,p,b)=>{if(e.candidateNames&&!e.candidateNames.has(a))return;let I=e.resolveTargets?e.resolveTargets({sourceFile:n,name:a,kind:c,defaultTargets:b}):b();for(let x of I)i({sourceFile:n,name:a,target:x,occurrences:p,kind:c})},m=O(t,n);for(let[a,c]of m)d(a,"identifier",c.length,()=>o(t,n,a));for(let a of g(t,n,{includeCrossLanguageDispatchNames:e.includeCrossLanguageDispatchNames,includeRustAttributeNames:e.includeRustAttributeNames})){let c=a.kind==="cross-language-dispatch"?()=>L(t,n,a.name):()=>o(t,n,a.name);d(a.name,a.kind,a.occurrences,c)}}finally{e.afterPath?.(n)}}function X(t,e={}){let{scope:i,files:o,minLoc:s=1,maxLoc:n=Number.POSITIVE_INFINITY,excludeSymbol:f,excludeEntrySurfaces:d=!1,excludeTypesFiles:m=!1,excludeRootedSymbols:a=!1,requireFunctionLikeSymbol:c=!1,requireCallableSymbol:p=!1,excludeRustTraitImplMembers:b=!1,includeSuppressed:I=!1,sortByLocDesc:x=!1}=e,C=[],$=te(t,{scope:i,files:o,requireCallableSymbol:p}),v=new Map,T=new Map,ee=r=>{let l=v.get(r);if(l!==void 0)return l;let u=j(t,r);return v.set(r,u),u},ne=r=>{let l=T.get(r);if(l!==void 0)return l;let u=R(r);return T.set(r,u),u};for(let r of $){let l=r.relativePath;if(t.isIgnored(l)||d&&ee(l)||!ie(r,{requireFunctionLikeSymbol:c,requireCallableSymbol:p})||f!==void 0&&r.symbol===f)continue;let u=F(r);u<s||u>n||m&&re(l)||a&&V(t,r.symbol,l)||b&&K(r.symbol)||ne(l)!=="test"&&(B(r.symbol)||!I&&y(t,l,r.startLine)||C.push(r))}return x?C.sort((r,l)=>F(l)-F(r)):C}function te(t,e){return e.files!==void 0?[...new Set(e.files.map(o=>o.replace(/\\/g,"/")))].sort().filter(o=>!e.scope||o.includes(e.scope)).flatMap(o=>h(t,o)):e.requireCallableSymbol?G(t,{scope:e.scope,symbolMatches:M,sqlPrefilter:"callable"}):D(t,e.scope)}function ie(t,e){return e.requireCallableSymbol?M(t.symbol):e.requireFunctionLikeSymbol?E(t.symbol):t.isFunctionLike}function re(t){return(t.split("/").pop()??"").includes("types")}var Z=class{constructor(e){this.db=e}db;scopedDefinitions(e){return D(this.db,e)}definitionsForFile(e){return h(this.db,e)}productionCallableDefinitions(e={}){return X(this.db,e)}calleeMap(e,i={}){return _(this.db,e,i)}crossFileCallerMap(e,i={}){return z(this.db,e,i)}sourceFallbackCallerFiles(e){return J(this.db,e)}callerFileMap(e,i={}){return Q(this.db,e,i)}frameworkReferencedSymbolIds(e){let i=new Map;for(let s of e){if(!s.leaf)continue;let n=i.get(s.leaf)??[];n.push(s.symbolId),i.set(s.leaf,n)}let o=new Set;for(let s of k(this.db,{includeIgnored:!1}))if(S(s)==="rust")for(let{name:n}of g(this.db,s,{includeRustAttributeNames:!0}))for(let f of i.get(n)??[])o.add(f);return o}symbolsWithNonSelfCallees(e,i={}){if(e.length===0)return new Set;let o=new Map(e.map(n=>[n.symbolId,n.symbol])),s=this.calleeMap(e,i);return new Set([...s.entries()].filter(([n,f])=>{let d=o.get(n);return f.some(m=>m.symbol!==d)}).map(([n])=>n))}fileDependencyGraph(e){return q(this.db,e)}fileKind(e){return R(e)}hasSuppressionComment(e){return y(this.db,e.relativePath,e.startLine)}sourceFiles(){return A(this.db)}scanSourceReferences(e,i){U(this.db,e,i)}callableSignature(e){let i=w(this.db,e.relativePath)?.callables.find(o=>o.startLine===e.startLine&&o.endLine===e.endLine);return i?{paramCount:i.paramCount}:null}};export{Z as a};
|
|
2
|
-
//# sourceMappingURL=chunk-GBEYTDY5.js.map
|
package/dist/chunk-PKMZCDQD.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as O,d as v}from"./chunk-BSN22NRK.js";import{b as E,d as _,e as N,j as F,k as M}from"./chunk-XUGQU7PM.js";import{existsSync as P,readFileSync as X}from"fs";import{join as I}from"path";function L(t,n){let e=G(t,n)??W(t,n)??Z(t,n)??J(t,n);return q(t,e,n)}function G(t,n){let e=-1,i=null;for(let r=0;r<=n;r+=1){let o=A(t[r]??"");o&&(i===null?(i=o,e=r):o===i&&(i=null,e=-1))}if(i===null||e<0)return null;for(let r=n+1;r<t.length;r+=1)if(A(t[r]??"")===i)return{start:e,end:r+1};return{start:e,end:t.length}}function A(t){let n=t.match(/^\s*(```+|~~~+)/);return n?n[1].startsWith("`")?"`":"~":null}function W(t,n){if(!b(t[n]??""))return null;let e=n;for(;e>0&&b(t[e-1]??"");)e-=1;let i=n+1;for(;i<t.length&&b(t[i]??"");)i+=1;return{start:e,end:i}}function b(t){let n=t.trim();return n.startsWith("|")&&n.endsWith("|")&&n.includes("|")}function Z(t,n){let e=n;for(;e>=0;){let o=t[e]??"";if(x(o)!==null)break;if(k(o)!==null)return null;e-=1}if(e<0)return null;let i=x(t[e]??"");if(i===null)return null;let r=e+1;for(;r<t.length;){let o=t[r]??"",c=x(o);if(c!==null){if(c<=i)break;r+=1;continue}if(k(o)!==null)break;r+=1}return{start:e,end:r}}function x(t){let n=t.match(/^(\s*)(?:[-*+]\s+|\d+[.)]\s+)/);return n?n[1].length:null}function J(t,n){let e=t[n]??"";if(B(e)||e.trim().length===0)return{start:n,end:n+1};let i=n;for(;i>0&&j(t[i-1]??"");)i-=1;let r=n+1;for(;r<t.length&&j(t[r]??"");)r+=1;return{start:i,end:r}}function j(t){return k(t)===null}function k(t){return t.trim().length===0?"blank":B(t)?"heading":A(t)?"fence":b(t)?"table":x(t)!==null?"list":null}function B(t){return/^#{1,6}\s+/.test(t.trim())}function q(t,n,e){let{start:i,end:r}=n;if(r-i>40){let c=Math.floor(20);i=Math.max(i,e-c),r=Math.min(r,i+40),i=Math.max(n.start,r-40)}let o=t.slice(i,r).join(`
|
|
2
|
-
`).trim();return o.length<=2e3?o:`${o.slice(0,2e3).trimEnd()}...`}function w(t,n){return n.filter(e=>t.includes(e))}var D=/\.(?:md|mdx|rst|txt)$/i;function K(t){return/(?:^|\/)(?:docs\/plans|plans|adrs?|rfcs?|decisions|changelogs?|archive|reports?)\//i.test(t)||/(?:^|\/)CHANGELOG\.(?:md|mdx|rst|txt)$/i.test(t)}var Q=3,V=/[A-Za-z0-9_@-]+(?:\/[A-Za-z0-9_.@-]+)+\.[A-Za-z0-9]{1,6}\b/g;function St(t,n={}){let{doc:e,limit:i=20,minCoupling:r=Q}=n,o=nt(t);if(!o)return{available:!1,commitsAnalyzed:0,docsScanned:0,findings:[]};let c=[];for(let s of o.docFiles){if(e!==void 0&&!s.includes(e)||e===void 0&&!z(t,s)||e!==void 0&&!P(I(t.config.projectRoot,s)))continue;let l=Math.max(0,...o.changeTimes.get(s)??[]),h=Y(t,s),d=new Map,{resolved:g,broken:a,citations:u}=rt(t,s,o.tracked,o.trackedBySuffix,o.everSeenInHistory),p=new Map(u.map(f=>[f.file,f.contexts]));for(let f of g){if(f===s||D.test(f))continue;let m=(o.changeTimes.get(f)??[]).filter(y=>y>l).length;m!==0&&d.set(f,{file:f,evidence:"reference",coChanges:0,changesSinceDocUpdate:m,...R("reference",h),citationContexts:p.get(f)})}for(let[f,m]of o.coupling.get(s)??[]){if(m<r||!o.tracked.has(f))continue;let y=(o.changeTimes.get(f)??[]).filter($=>$>l).length;if(y===0)continue;let S=d.get(f);S?(S.evidence="both",S.coChanges=m,Object.assign(S,R("both",h))):d.set(f,{file:f,evidence:"co-change",coChanges:m,changesSinceDocUpdate:y,...R("co-change",h)})}if(d.size===0&&a.length===0)continue;let C=[...d.values()].sort((f,m)=>m.changesSinceDocUpdate-f.changesSinceDocUpdate);c.push({doc:s,docLastChangedAt:l,staleness:C.reduce((f,m)=>f+m.changesSinceDocUpdate,0)+a.length*10,subjects:C.slice(0,8),brokenReferences:a})}return c.sort((s,l)=>l.staleness-s.staleness),{available:!0,commitsAnalyzed:o.historyCommitCount,docsScanned:o.docFiles.length,findings:c.slice(0,i)}}function Y(t,n){let e;try{e=X(I(t.config.projectRoot,n),"utf8").slice(0,6e3)}catch{return{docIntent:"unknown",reasons:["doc text unavailable"]}}let i=`${n}
|
|
3
|
-
${e}`.toLowerCase(),r=w(i,["historical note","historical record","history note","retrospective","postmortem","post-mortem","archived","archive","previously","legacy","recorded","record of","snapshot","as of","migration note","decision record"]);if(r.length>0)return{docIntent:"historical-note",reasons:[`historical-note terms: ${r.join(", ")}`]};let o=w(i,["current","standard","standards","must","should","policy","guide","guidance","workflow","contract","invariant","source of truth"]);return o.length>0?{docIntent:"current-guidance",reasons:[`current-guidance terms: ${o.join(", ")}`]}:{docIntent:"unknown",reasons:["no current-guidance or historical-note markers found"]}}function R(t,n){return{actionTier:tt(t,n.docIntent),docIntent:n.docIntent,docIntentReasons:n.reasons}}function tt(t,n){return n==="historical-note"?"support":t==="co-change"?"signal":"direct"}function nt(t){let n=O(t);if(!n)return null;let e=v(t)??new Set,i=new Map,r=new Map,o=new Set;for(let c of n.commits){let s=[...new Set(c.files)],l=s.filter(d=>D.test(d)),h=s.filter(d=>!D.test(d));for(let d of s){o.add(d);let g=i.get(d)??[];g.push(c.timestamp),i.set(d,g)}for(let d of l){let g=r.get(d);g||(g=new Map,r.set(d,g));for(let a of h)g.set(a,(g.get(a)??0)+1)}}return{changeTimes:i,coupling:r,docFiles:[...e].filter(c=>D.test(c)),everSeenInHistory:o,historyCommitCount:n.commits.length,tracked:e,trackedBySuffix:H(e)}}function bt(t,n){if(n.size===0)return[];let e=v(t)??new Set,i=H(e),r=et(n,i),o=[];for(let c of e){if(!z(t,c))continue;let s=U(t,c);if(!s)continue;let l=it(s.candidates,n,r,e,i);if(l.size===0)continue;let h=[...new Set([...l.values()].flatMap(u=>[...u]))],d=ot(s.contextsByCandidate,h),g=[...l].map(([u,p])=>({file:u,contexts:T([...p].flatMap(C=>d.get(C)??[])).slice(0,3)})).filter(u=>u.contexts.length>0),a=[...l.keys()];if(a.length>0){let u=a.sort();o.push({doc:c,cited:u,citations:g,citedClaims:T(g.flatMap(p=>p.contexts)).slice(0,3)})}}return o}function z(t,n){return D.test(n)&&!K(n)&&P(I(t.config.projectRoot,n))}function H(t){let n=new Map;for(let e of t){let i=e.split("/");for(let r of[2,3]){if(i.length<r)continue;let o=i.slice(-r).join("/"),c=n.get(o)??[];c.push(e),n.set(o,c)}}return n}function et(t,n){let e=new Set(t);for(let i of t){let r=i.split("/");for(let o of[2,3]){if(r.length<o)continue;let c=r.slice(-o).join("/"),s=n.get(c);s?.length===1&&s[0]===i&&e.add(c)}}return e}function it(t,n,e,i,r){let o=new Map;for(let c of t){if(!e.has(c))continue;let s;if(i.has(c))s=c;else{let h=r.get(c);h?.length===1&&(s=h[0])}if(!s||!n.has(s))continue;let l=o.get(s)??new Set;l.add(c),o.set(s,l)}return o}function rt(t,n,e,i,r){let o=new Set,c=new Set,s=U(t,n);if(!s)return{resolved:o,broken:[],citations:[]};let l=s.candidates,h=s.contextsByCandidate,d=new Map,g=(a,u)=>{let p=h.get(u);if(!p||p.length===0)return;let C=d.get(a)??[];C.push(...p),d.set(a,T(C).slice(0,3))};for(let a of l){if(e.has(a)){o.add(a),g(a,a);continue}let u=i.get(a);if(u&&u.length===1){o.add(u[0]),g(u[0],a);continue}u&&u.length>1||r.has(a)&&c.add(a)}return{resolved:o,broken:[...c],citations:[...d].map(([a,u])=>({file:a,contexts:u}))}}function ot(t,n){let e=new Map;for(let i of n){let r=t.get(i);r&&r.length>0&&e.set(i,[...r])}return e}function U(t,n){let e;try{e=X(I(t.config.projectRoot,n),"utf-8")}catch{return null}let i=E(t,n,e),r=_(t,"doc-path-evidence",n,i);if(r!==null){let c=at(r);if(c)return c}let o=st(e);return N(t,"doc-path-evidence",n,i,ct(o)),o}function st(t){let n=t.split(/\r?\n/),e=new Set,i=new Map;for(let r=0;r<n.length;r+=1){let o=n[r]??"";for(let c of o.matchAll(V)){let s=c[0].replace(/^\.?\//,"");e.add(s);let l=L(n,r);if(l.length===0)continue;let h=i.get(s)??[];h.push(l),i.set(s,T(h).slice(0,3))}}return{candidates:[...e],contextsByCandidate:i}}function ct(t){let n={candidates:t.candidates,contextsByCandidate:[...t.contextsByCandidate.entries()]};return JSON.stringify(n)}function at(t){try{let n=JSON.parse(t);if(!F(n))return null;let e=M(n.candidates),i=dt(n.contextsByCandidate);return!e||!i?null:{candidates:e,contextsByCandidate:new Map(i)}}catch{return null}}function dt(t){if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;let i=M(e[1]);if(!i)return null;n.push([e[0],i])}return n}function T(t){let n=[];for(let e of new Set(t))n.some(i=>lt(i,e))||n.push(e);return n}function lt(t,n){if(t===n)return!0;let e=t.split(/\r?\n/).map(s=>s.trim()).filter(s=>s.length>0),i=n.split(/\r?\n/).map(s=>s.trim()).filter(s=>s.length>0),r=Math.min(e.length,i.length);if(r===0)return!1;if(r<3)return t.includes(n)||n.includes(t);let o=new Set(i),c=e.filter(s=>o.has(s)).length;return c>=3&&c/r>=.6}export{L as a,w as b,K as c,St as d,bt as e};
|
|
4
|
-
//# sourceMappingURL=chunk-PKMZCDQD.js.map
|