scip-query 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -26
- package/dist/{chunk-FYYOWQXK.js → chunk-2F2WH5WQ.js} +19 -36
- package/dist/{chunk-C7H5WBTJ.js → chunk-2UISVZGQ.js} +2 -2
- package/dist/{chunk-HLKAFWWJ.js → chunk-4ZT7UGWW.js} +56 -91
- package/dist/chunk-5AJJGPZE.js +60 -0
- package/dist/chunk-5RKYZSQ6.js +75 -0
- package/dist/chunk-7YBLWIXY.js +115 -0
- package/dist/{chunk-O7Q7FDUJ.js → chunk-A4GWYETB.js} +2 -2
- package/dist/{chunk-CHDJXYBG.js → chunk-A5BGEBM7.js} +2 -2
- package/dist/{chunk-KKCHYLVI.js → chunk-A7YY7IDA.js} +2 -2
- package/dist/chunk-AS7N27JK.js +115 -0
- package/dist/{chunk-F7XU27LU.js → chunk-CQRYLK33.js} +26 -2
- package/dist/{chunk-NFS5W3PP.js → chunk-CQUNEJYM.js} +2 -2
- package/dist/chunk-D4I3ZMN5.js +38 -0
- package/dist/{chunk-J3JSOSUO.js → chunk-E7J7Q7UW.js} +2 -2
- package/dist/{chunk-GEXE2T6I.js → chunk-EOHPASDV.js} +22 -14
- package/dist/chunk-FVH3Y44U.js +1 -0
- package/dist/chunk-GIBETK3W.js +37 -0
- package/dist/{chunk-SMDCNPMK.js → chunk-H3FPW5YN.js} +2 -2
- package/dist/{chunk-GJDHTTR2.js → chunk-HNURMDF4.js} +32 -17
- package/dist/{chunk-7KIMF5PV.js → chunk-HRDPUTIQ.js} +2 -2
- package/dist/{chunk-OIDHN6GD.js → chunk-I2JM34UV.js} +146 -5
- package/dist/{chunk-EPWLXXBL.js → chunk-IV6NZ426.js} +27 -29
- package/dist/{chunk-VT4JBH6L.js → chunk-KDCQJTYW.js} +2 -2
- package/dist/{chunk-5OMVSV6E.js → chunk-LOVDB4C6.js} +2 -2
- package/dist/chunk-MA3B3IUT.js +75 -0
- package/dist/{chunk-26DOJ63W.js → chunk-N2LH3M2P.js} +13 -2
- package/dist/chunk-NWCJWA36.js +162 -0
- package/dist/{chunk-NG5F43OU.js → chunk-P3VCDYMJ.js} +70 -1
- package/dist/{chunk-P3E6L7KW.js → chunk-P42KQKJZ.js} +83 -3
- package/dist/{chunk-YDBXNPYU.js → chunk-PGHN5UTM.js} +2 -2
- package/dist/{chunk-UGQKAVCD.js → chunk-QCYR4S6T.js} +2 -2
- package/dist/chunk-QGCEAVJD.js +2529 -0
- package/dist/{chunk-KBOQX573.js → chunk-RIEA5DOB.js} +19 -2
- package/dist/{chunk-VIYSWZCO.js → chunk-SL674KAW.js} +31 -3
- package/dist/chunk-SRELHCMG.js +110 -0
- package/dist/chunk-UTRKBUCB.js +87 -0
- package/dist/{chunk-HJZUSUPU.js → chunk-VCOJRQPP.js} +5 -5
- package/dist/chunk-VISMEWYP.js +34 -0
- package/dist/{chunk-LFJQVJYJ.js → chunk-VU7FDTWV.js} +2 -2
- package/dist/{chunk-HLUS2HEB.js → chunk-VUBLUTMU.js} +5 -4
- package/dist/{chunk-WGAD3GNR.js → chunk-WNPF2I25.js} +5 -5
- package/dist/{chunk-YY4QGUQ5.js → chunk-X3J4VPWM.js} +2 -2
- package/dist/{chunk-GSH2FPKV.js → chunk-XH56HXLC.js} +2 -2
- package/dist/{chunk-DH7G3DDV.js → chunk-ZU2AQQB5.js} +2 -2
- package/dist/cli.js +2722 -1036
- package/dist/{db-ShvwGDKf.d.ts → db-C4rPbKkI.d.ts} +7 -14
- package/dist/index.d.ts +4 -5
- package/dist/index.js +378 -149
- package/dist/postinstall.js +9 -3
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +2 -2
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +2 -1
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +2 -1
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +2 -2
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +2 -2
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +2 -2
- package/dist/queries/complexity-hotspots.d.ts +1 -1
- package/dist/queries/complexity-hotspots.js +2 -2
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +2 -2
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +2 -2
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +2 -2
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +2 -2
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +2 -2
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +3 -3
- package/dist/queries/deep-chains.d.ts +1 -1
- package/dist/queries/deep-chains.js +2 -2
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +2 -2
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +2 -2
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +2 -2
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +2 -2
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +13 -13
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +2 -2
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +2 -1
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +2 -2
- package/dist/queries/index.d.ts +1 -2
- package/dist/queries/index.js +49 -53
- package/dist/queries/isolated.d.ts +3 -4
- package/dist/queries/isolated.js +3 -3
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +2 -2
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +2 -1
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +2 -2
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +2 -2
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +3 -3
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +2 -2
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +2 -2
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +2 -2
- package/dist/queries/similar-signatures.d.ts +5 -3
- package/dist/queries/similar-signatures.js +2 -1
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +2 -2
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +2 -2
- package/dist/queries/stale-abstractions.d.ts +1 -1
- package/dist/queries/stale-abstractions.js +2 -2
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +2 -2
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +2 -2
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +2 -2
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +2 -2
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +2 -2
- package/dist/reindex-worker.js +213 -62
- package/package.json +1 -1
- package/skills/scip-language-playbook/SKILL.md +371 -0
- package/dist/chunk-2UELLEBI.js +0 -1
- package/dist/chunk-4JCSOF2O.js +0 -97
- package/dist/chunk-AXQKUYKF.js +0 -1442
- package/dist/chunk-CPVAQJEC.js +0 -46
- package/dist/chunk-EOROMIFO.js +0 -41
- package/dist/chunk-GU2H5QRN.js +0 -28
- package/dist/chunk-LQJUPXQY.js +0 -109
- package/dist/chunk-MPGIHELS.js +0 -39
- package/dist/chunk-P4WO3BBW.js +0 -64
- package/dist/chunk-TOIEB3LG.js +0 -78
- package/dist/chunk-UQEQ6AHX.js +0 -60
- package/dist/chunk-VJJKSGIX.js +0 -121
- package/dist/chunk-YZ6L7GFO.js +0 -73
- package/dist/chunk-ZEUCXQBN.js +0 -71
- package/dist/queries/doc-coverage.d.ts +0 -14
- package/dist/queries/doc-coverage.js +0 -8
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllDefinitions,
|
|
3
|
+
getCallerRowsForSymbol
|
|
4
|
+
} from "./chunk-QGCEAVJD.js";
|
|
1
5
|
import {
|
|
2
6
|
shortenSymbol
|
|
3
7
|
} from "./chunk-QIXNAB5K.js";
|
|
@@ -27,16 +31,29 @@ function hotspots(db, opts = {}) {
|
|
|
27
31
|
LIMIT ?`,
|
|
28
32
|
limit
|
|
29
33
|
);
|
|
30
|
-
|
|
34
|
+
const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
|
|
31
35
|
symbol: r.symbol,
|
|
32
36
|
shortName: shortenSymbol(r.symbol),
|
|
33
37
|
refCount: r.ref_count,
|
|
34
38
|
fileCount: r.file_count,
|
|
35
39
|
definedIn: r.defined_in
|
|
36
40
|
}));
|
|
41
|
+
if (indexedResults.length > 0) {
|
|
42
|
+
return indexedResults;
|
|
43
|
+
}
|
|
44
|
+
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
|
|
45
|
+
const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
|
|
46
|
+
return {
|
|
47
|
+
symbol: definition.symbol,
|
|
48
|
+
shortName: shortenSymbol(definition.symbol),
|
|
49
|
+
refCount: callerRows.length,
|
|
50
|
+
fileCount: new Set(callerRows.map((row) => row.file)).size,
|
|
51
|
+
definedIn: definition.relativePath
|
|
52
|
+
};
|
|
53
|
+
}).filter((row) => row.refCount > 0).sort((left, right) => right.refCount - left.refCount || right.fileCount - left.fileCount).slice(0, limit);
|
|
37
54
|
}
|
|
38
55
|
|
|
39
56
|
export {
|
|
40
57
|
hotspots
|
|
41
58
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-RIEA5DOB.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getAllDefinitions,
|
|
3
|
+
getCalleeRowsForSymbol,
|
|
4
|
+
getCallerRowsForSymbol,
|
|
2
5
|
testFileExclusionSql
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QGCEAVJD.js";
|
|
4
7
|
import {
|
|
5
8
|
shortenSymbol
|
|
6
9
|
} from "./chunk-QIXNAB5K.js";
|
|
@@ -80,7 +83,7 @@ function complexityHotspots(db, opts) {
|
|
|
80
83
|
minLoc,
|
|
81
84
|
limit
|
|
82
85
|
);
|
|
83
|
-
|
|
86
|
+
const indexedResults = rows.filter((r) => !db.isIgnored(r.file)).map((r) => ({
|
|
84
87
|
symbol: r.symbol,
|
|
85
88
|
shortName: shortenSymbol(r.symbol),
|
|
86
89
|
file: r.file,
|
|
@@ -94,9 +97,34 @@ function complexityHotspots(db, opts) {
|
|
|
94
97
|
r.loc / 50 * (r.fan_in / 5) * Math.max(r.fan_out / 5, 1) * 100
|
|
95
98
|
) / 100
|
|
96
99
|
}));
|
|
100
|
+
if (indexedResults.length > 0) {
|
|
101
|
+
return indexedResults;
|
|
102
|
+
}
|
|
103
|
+
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
|
|
104
|
+
const loc = definition.endLine - definition.startLine + 1;
|
|
105
|
+
const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
|
|
106
|
+
const calleeRows = getCalleeRowsForSymbol(db, definition, { limit: 500 });
|
|
107
|
+
const fanIn = new Set(callerRows.map((row) => row.file)).size;
|
|
108
|
+
const fanOut = new Set(
|
|
109
|
+
calleeRows.filter((row) => row.file !== definition.relativePath).map((row) => `${row.symbol}|${row.file}`)
|
|
110
|
+
).size;
|
|
111
|
+
const calleeCount = new Set(calleeRows.map((row) => `${row.symbol}|${row.file}`)).size;
|
|
112
|
+
return {
|
|
113
|
+
symbol: definition.symbol,
|
|
114
|
+
shortName: shortenSymbol(definition.symbol),
|
|
115
|
+
file: definition.relativePath,
|
|
116
|
+
startLine: definition.startLine,
|
|
117
|
+
endLine: definition.endLine,
|
|
118
|
+
loc,
|
|
119
|
+
fanIn,
|
|
120
|
+
fanOut,
|
|
121
|
+
calleeCount,
|
|
122
|
+
score: Math.round(loc / 50 * (fanIn / 5) * Math.max(fanOut / 5, 1) * 100) / 100
|
|
123
|
+
};
|
|
124
|
+
}).filter((row) => row.loc >= minLoc).sort((left, right) => right.score - left.score || right.loc - left.loc).slice(0, limit);
|
|
97
125
|
}
|
|
98
126
|
|
|
99
127
|
export {
|
|
100
128
|
complexityHotspots
|
|
101
129
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-SL674KAW.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getInactiveBarrelPaths,
|
|
3
|
+
isEntrySurface
|
|
4
|
+
} from "./chunk-X3J4VPWM.js";
|
|
5
|
+
import {
|
|
6
|
+
TEST_FILE_PATTERNS,
|
|
7
|
+
TEST_SUPPORT_PATH_PATTERNS,
|
|
8
|
+
getAllDefinitions
|
|
9
|
+
} from "./chunk-QGCEAVJD.js";
|
|
10
|
+
import {
|
|
11
|
+
isFunctionLikeSymbol,
|
|
12
|
+
isModuleLikeSymbol,
|
|
13
|
+
shortenSymbol
|
|
14
|
+
} from "./chunk-QIXNAB5K.js";
|
|
15
|
+
|
|
16
|
+
// src/queries/dead.ts
|
|
17
|
+
function dead(db, opts = {}) {
|
|
18
|
+
const {
|
|
19
|
+
scope,
|
|
20
|
+
minLoc = 1,
|
|
21
|
+
includeTests = false,
|
|
22
|
+
skipBarrels = false,
|
|
23
|
+
includeMembers = false
|
|
24
|
+
} = opts;
|
|
25
|
+
const inactiveBarrelPaths = skipBarrels ? new Set(getInactiveBarrelPaths(db)) : /* @__PURE__ */ new Set();
|
|
26
|
+
const referenceRows = db.all(
|
|
27
|
+
`SELECT
|
|
28
|
+
m.symbol_id,
|
|
29
|
+
d.relative_path,
|
|
30
|
+
COUNT(*) AS ref_count
|
|
31
|
+
FROM mentions m
|
|
32
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
33
|
+
JOIN documents d ON c.document_id = d.id
|
|
34
|
+
WHERE m.role != 1
|
|
35
|
+
${db.pathExclusionsFor("d")}
|
|
36
|
+
GROUP BY m.symbol_id, d.relative_path`
|
|
37
|
+
);
|
|
38
|
+
const referencesBySymbol = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const row of referenceRows) {
|
|
40
|
+
if (db.isIgnored(row.relative_path)) continue;
|
|
41
|
+
if (inactiveBarrelPaths.has(row.relative_path)) continue;
|
|
42
|
+
let refsForSymbol = referencesBySymbol.get(row.symbol_id);
|
|
43
|
+
if (!refsForSymbol) {
|
|
44
|
+
refsForSymbol = /* @__PURE__ */ new Map();
|
|
45
|
+
referencesBySymbol.set(row.symbol_id, refsForSymbol);
|
|
46
|
+
}
|
|
47
|
+
refsForSymbol.set(row.relative_path, row.ref_count);
|
|
48
|
+
}
|
|
49
|
+
const definitions = getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isModuleLikeSymbol(definition.symbol)).filter((definition) => looksValueLikeDefinition(definition.symbol)).filter((definition) => definition.isFunctionLike || !definition.enclosingSymbol || !looksValueLikeDefinition(definition.enclosingSymbol)).filter((definition) => includeTests || passesTestFileFilter(definition.relativePath)).filter((definition) => includeMembers || looksValueLikeDefinition(definition.symbol)).filter((definition) => definition.endLine - definition.startLine + 1 >= minLoc);
|
|
50
|
+
const rows = definitions.map((definition) => {
|
|
51
|
+
const refMap = referencesBySymbol.get(definition.symbolId) ?? /* @__PURE__ */ new Map();
|
|
52
|
+
const sameFileRefs = refMap.get(definition.relativePath) ?? 0;
|
|
53
|
+
let crossFileRefs = 0;
|
|
54
|
+
for (const [relativePath, count] of refMap) {
|
|
55
|
+
if (relativePath === definition.relativePath) continue;
|
|
56
|
+
crossFileRefs += count;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
relative_path: definition.relativePath,
|
|
60
|
+
start_line: definition.startLine,
|
|
61
|
+
end_line: definition.endLine,
|
|
62
|
+
loc: definition.endLine - definition.startLine + 1,
|
|
63
|
+
symbol: definition.symbol,
|
|
64
|
+
same_file_refs: sameFileRefs,
|
|
65
|
+
cross_file_refs: crossFileRefs
|
|
66
|
+
};
|
|
67
|
+
}).filter((row) => row.cross_file_refs === 0).sort((a, b) => b.loc - a.loc || a.relative_path.localeCompare(b.relative_path) || a.start_line - b.start_line);
|
|
68
|
+
let deadCodeCount = 0;
|
|
69
|
+
let fileInternalCount = 0;
|
|
70
|
+
let totalLoc = 0;
|
|
71
|
+
const symbols = rows.filter((r) => !db.isIgnored(r.relative_path)).filter((r) => !isEntrySurface(db, r.relative_path)).map((r) => {
|
|
72
|
+
const kind = r.same_file_refs === 0 ? "dead-code" : "file-internal";
|
|
73
|
+
if (kind === "dead-code") deadCodeCount++;
|
|
74
|
+
else fileInternalCount++;
|
|
75
|
+
totalLoc += r.loc;
|
|
76
|
+
return {
|
|
77
|
+
relativePath: r.relative_path,
|
|
78
|
+
startLine: r.start_line,
|
|
79
|
+
endLine: r.end_line,
|
|
80
|
+
loc: r.loc,
|
|
81
|
+
symbol: r.symbol,
|
|
82
|
+
shortName: shortenSymbol(r.symbol),
|
|
83
|
+
sameFileRefs: r.same_file_refs,
|
|
84
|
+
kind
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
symbols,
|
|
89
|
+
totalCount: symbols.length,
|
|
90
|
+
deadCodeCount,
|
|
91
|
+
fileInternalCount,
|
|
92
|
+
totalLoc
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function passesTestFileFilter(relativePath) {
|
|
96
|
+
const patterns = [.../* @__PURE__ */ new Set([...TEST_FILE_PATTERNS, ...TEST_SUPPORT_PATH_PATTERNS])];
|
|
97
|
+
return patterns.every((pattern) => !likeMatches(relativePath, pattern));
|
|
98
|
+
}
|
|
99
|
+
function likeMatches(value, pattern) {
|
|
100
|
+
const regex = new RegExp(`^${pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/%/g, ".*").replace(/_/g, ".")}$`);
|
|
101
|
+
return regex.test(value);
|
|
102
|
+
}
|
|
103
|
+
function looksValueLikeDefinition(rawSymbol) {
|
|
104
|
+
return isFunctionLikeSymbol(rawSymbol) || rawSymbol.endsWith("().") || rawSymbol.endsWith(".");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
dead
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=chunk-SRELHCMG.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findExactSymbolMatch,
|
|
3
|
+
findFirstSymbolMatch,
|
|
4
|
+
getCallerRowsForSymbol
|
|
5
|
+
} from "./chunk-QGCEAVJD.js";
|
|
6
|
+
import {
|
|
7
|
+
shortenSymbol
|
|
8
|
+
} from "./chunk-QIXNAB5K.js";
|
|
9
|
+
|
|
10
|
+
// src/queries/affected.ts
|
|
11
|
+
function affected(db, symbolPattern, opts = {}) {
|
|
12
|
+
const { maxDepth = 5, scope } = opts;
|
|
13
|
+
const target = findFirstSymbolMatch(db, symbolPattern);
|
|
14
|
+
if (!target) return [];
|
|
15
|
+
const results = [];
|
|
16
|
+
const visited = /* @__PURE__ */ new Set([target.symbolId]);
|
|
17
|
+
const seenResults = /* @__PURE__ */ new Set();
|
|
18
|
+
let frontier = [target];
|
|
19
|
+
for (let depth = 1; depth <= maxDepth; depth++) {
|
|
20
|
+
if (frontier.length === 0) break;
|
|
21
|
+
const nextFrontier = [];
|
|
22
|
+
for (const current of frontier) {
|
|
23
|
+
for (const row of getDirectAffectedRows(db, current, scope)) {
|
|
24
|
+
const resultKey = `${row.file}|${row.shortName}`;
|
|
25
|
+
if (row.symbolId !== null) {
|
|
26
|
+
if (visited.has(row.symbolId)) continue;
|
|
27
|
+
visited.add(row.symbolId);
|
|
28
|
+
} else if (seenResults.has(resultKey)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
seenResults.add(resultKey);
|
|
32
|
+
results.push({
|
|
33
|
+
symbol: row.symbol,
|
|
34
|
+
shortName: row.shortName,
|
|
35
|
+
file: row.file,
|
|
36
|
+
depth
|
|
37
|
+
});
|
|
38
|
+
if (row.symbolId !== null && row.symbolMatch) {
|
|
39
|
+
nextFrontier.push(row.symbolMatch);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
frontier = nextFrontier;
|
|
44
|
+
}
|
|
45
|
+
results.sort((a, b) => a.depth - b.depth || a.file.localeCompare(b.file));
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
function getDirectAffectedRows(db, target, scope) {
|
|
49
|
+
const callerRows = getCallerRowsForSymbol(db, target, { limit: 500 }).filter((row) => !db.isIgnored(row.file)).filter((row) => !scope || row.file.includes(scope));
|
|
50
|
+
const results = [];
|
|
51
|
+
const seen = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const row of callerRows) {
|
|
53
|
+
const match = findExactSymbolMatch(db, row.symbol);
|
|
54
|
+
if (!match) {
|
|
55
|
+
const key2 = `${row.file}|${row.symbol}`;
|
|
56
|
+
if (seen.has(key2)) continue;
|
|
57
|
+
seen.add(key2);
|
|
58
|
+
results.push({
|
|
59
|
+
symbolId: null,
|
|
60
|
+
symbol: row.symbol,
|
|
61
|
+
shortName: shortenSymbol(row.symbol),
|
|
62
|
+
file: row.file,
|
|
63
|
+
symbolMatch: null
|
|
64
|
+
});
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (match.symbolId === target.symbolId || db.isIgnored(match.relativePath)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const key = `${match.symbolId}|${match.relativePath}`;
|
|
71
|
+
if (seen.has(key)) continue;
|
|
72
|
+
seen.add(key);
|
|
73
|
+
results.push({
|
|
74
|
+
symbolId: match.symbolId,
|
|
75
|
+
symbol: match.symbol,
|
|
76
|
+
shortName: shortenSymbol(match.symbol),
|
|
77
|
+
file: match.relativePath,
|
|
78
|
+
symbolMatch: match
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return results;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
affected
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=chunk-UTRKBUCB.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getCalleeRowsForSymbol
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QGCEAVJD.js";
|
|
5
5
|
import {
|
|
6
6
|
shortenSymbol
|
|
7
7
|
} from "./chunk-QIXNAB5K.js";
|
|
@@ -37,11 +37,11 @@ function convergence(db, symbolPatternA, symbolPatternB) {
|
|
|
37
37
|
} else if (shared.length === 0) {
|
|
38
38
|
strategy = "These functions do not share any callees. They are not a callee-based consolidation candidate.";
|
|
39
39
|
} else if (uniqueA.length === 0 && uniqueB.length === 0) {
|
|
40
|
-
strategy = "These functions have identical callee sets.
|
|
40
|
+
strategy = "These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.";
|
|
41
41
|
} else if (uniqueA.length === 0) {
|
|
42
|
-
strategy = `A
|
|
42
|
+
strategy = `A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.`;
|
|
43
43
|
} else if (uniqueB.length === 0) {
|
|
44
|
-
strategy = `B
|
|
44
|
+
strategy = `B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.`;
|
|
45
45
|
} else if (uniqueA.length <= 2 && uniqueB.length <= 2) {
|
|
46
46
|
strategy = `Create a shared function with the ${shared.length} common callees. Pass the ${uniqueA.length + uniqueB.length} divergent callees as parameters or strategy callbacks.`;
|
|
47
47
|
} else {
|
|
@@ -73,4 +73,4 @@ function convergence(db, symbolPatternA, symbolPatternB) {
|
|
|
73
73
|
export {
|
|
74
74
|
convergence
|
|
75
75
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-VCOJRQPP.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEntrySurface
|
|
3
|
+
} from "./chunk-X3J4VPWM.js";
|
|
4
|
+
import {
|
|
5
|
+
getAllDefinitions,
|
|
6
|
+
getCalleeRowsForSymbol,
|
|
7
|
+
getCallerRowsForSymbol
|
|
8
|
+
} from "./chunk-QGCEAVJD.js";
|
|
9
|
+
import {
|
|
10
|
+
shortenSymbol
|
|
11
|
+
} from "./chunk-QIXNAB5K.js";
|
|
12
|
+
|
|
13
|
+
// src/queries/isolated.ts
|
|
14
|
+
function isolated(db, opts = {}) {
|
|
15
|
+
const { scope, minLoc = 3 } = opts;
|
|
16
|
+
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isEntrySurface(db, definition.relativePath)).filter((definition) => definition.isFunctionLike).map((definition) => ({
|
|
17
|
+
definition,
|
|
18
|
+
loc: definition.endLine - definition.startLine + 1
|
|
19
|
+
})).filter((entry) => entry.loc >= minLoc).filter((entry) => getCallerRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).filter((entry) => getCalleeRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).sort(
|
|
20
|
+
(left, right) => right.loc - left.loc || left.definition.relativePath.localeCompare(right.definition.relativePath) || left.definition.startLine - right.definition.startLine
|
|
21
|
+
).map((entry) => ({
|
|
22
|
+
symbol: entry.definition.symbol,
|
|
23
|
+
shortName: shortenSymbol(entry.definition.symbol),
|
|
24
|
+
relativePath: entry.definition.relativePath,
|
|
25
|
+
startLine: entry.definition.startLine,
|
|
26
|
+
endLine: entry.definition.endLine,
|
|
27
|
+
loc: entry.loc
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
isolated
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=chunk-VISMEWYP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QGCEAVJD.js";
|
|
4
4
|
|
|
5
5
|
// src/queries/cycles.ts
|
|
6
6
|
function cycles(db, opts = {}) {
|
|
@@ -58,4 +58,4 @@ function cycles(db, opts = {}) {
|
|
|
58
58
|
export {
|
|
59
59
|
cycles
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-VU7FDTWV.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QGCEAVJD.js";
|
|
4
4
|
|
|
5
5
|
// src/queries/similar-files.ts
|
|
6
6
|
function similarFiles(db, opts = {}) {
|
|
7
|
-
const { minSimilarity = 0.5, limit = 20, scope,
|
|
7
|
+
const { minSimilarity = 0.5, limit = 20, scope, filePattern } = opts;
|
|
8
|
+
const minDeps = opts.minDeps ?? (filePattern ? 1 : 3);
|
|
8
9
|
const profiles = buildFileProfiles(db, { scope, minDeps });
|
|
9
10
|
const results = [];
|
|
10
11
|
if (filePattern) {
|
|
@@ -53,7 +54,7 @@ function findUniversalDependencies(depMap) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
for (const [dep, count] of depCounts) {
|
|
56
|
-
if (count / fileCount > 0.
|
|
57
|
+
if (count >= 6 && count / fileCount > 0.8) {
|
|
57
58
|
universalDeps.add(dep);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -89,4 +90,4 @@ function compareProfiles(a, b, minSimilarity) {
|
|
|
89
90
|
export {
|
|
90
91
|
similarFiles
|
|
91
92
|
};
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-VUBLUTMU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QGCEAVJD.js";
|
|
4
4
|
|
|
5
5
|
// src/queries/similar-chains.ts
|
|
6
6
|
function similarChains(db, opts = {}) {
|
|
@@ -28,8 +28,8 @@ function similarChains(db, opts = {}) {
|
|
|
28
28
|
tailFreq.set(chain[t], (tailFreq.get(chain[t]) ?? 0) + 1);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const infraThreshold = rawChains.length * 0.
|
|
32
|
-
const tailThreshold = rawChains.length * 0.
|
|
31
|
+
const infraThreshold = rawChains.length * 0.9;
|
|
32
|
+
const tailThreshold = rawChains.length * 0.8;
|
|
33
33
|
const infraNodes = /* @__PURE__ */ new Set();
|
|
34
34
|
for (const [node, freq] of nodeFreq) {
|
|
35
35
|
if (freq > infraThreshold) infraNodes.add(node);
|
|
@@ -45,7 +45,7 @@ function similarChains(db, opts = {}) {
|
|
|
45
45
|
const filteredChains = [];
|
|
46
46
|
for (const chain of rawChains) {
|
|
47
47
|
const filtered = chain.filter((n) => !infraNodes.has(n));
|
|
48
|
-
if (filtered.length >=
|
|
48
|
+
if (filtered.length >= 2) {
|
|
49
49
|
filteredChains.push({ original: chain, filtered });
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -210,4 +210,4 @@ function isSubChain(sub, full) {
|
|
|
210
210
|
export {
|
|
211
211
|
similarChains
|
|
212
212
|
};
|
|
213
|
-
//# sourceMappingURL=chunk-
|
|
213
|
+
//# sourceMappingURL=chunk-WNPF2I25.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QGCEAVJD.js";
|
|
4
4
|
|
|
5
5
|
// src/entry-surfaces.ts
|
|
6
6
|
var liveBarrelCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -81,4 +81,4 @@ export {
|
|
|
81
81
|
isEntrySurface,
|
|
82
82
|
getInactiveBarrelPaths
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-X3J4VPWM.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getCalleeRowsForSymbol,
|
|
4
4
|
getSourceReferenceSites
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QGCEAVJD.js";
|
|
6
6
|
import {
|
|
7
7
|
shortenSymbol
|
|
8
8
|
} from "./chunk-QIXNAB5K.js";
|
|
@@ -84,4 +84,4 @@ function uniqueSymbolRows(rows) {
|
|
|
84
84
|
export {
|
|
85
85
|
dataflow
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-XH56HXLC.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QGCEAVJD.js";
|
|
4
4
|
|
|
5
5
|
// src/queries/deep-chains.ts
|
|
6
6
|
function deepChains(db, opts = {}) {
|
|
@@ -41,4 +41,4 @@ function deepChains(db, opts = {}) {
|
|
|
41
41
|
export {
|
|
42
42
|
deepChains
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-ZU2AQQB5.js.map
|