scip-query 0.5.0 → 0.6.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/dist/chunk-2DSS2NGF.js +10 -0
- package/dist/chunk-2RLP74AO.js +2 -0
- package/dist/chunk-4QJ7LVW5.js +2 -0
- package/dist/chunk-4TYGGOLO.js +5 -0
- package/dist/chunk-5IADAU5B.js +7 -0
- package/dist/chunk-7754WFFV.js +18 -0
- package/dist/chunk-7VOF4ZG6.js +2 -0
- package/dist/chunk-7Z4COVMC.js +2 -0
- package/dist/chunk-AJ5PWKD4.js +2 -0
- package/dist/chunk-BDBRZPX3.js +7 -0
- package/dist/chunk-BE6EQIWY.js +2 -0
- package/dist/chunk-BQ3INTYT.js +8 -0
- package/dist/chunk-D7KLLMPB.js +2 -0
- package/dist/chunk-D7YBWSON.js +29 -0
- package/dist/chunk-DE5ZBHMK.js +39 -0
- package/dist/chunk-DHYIJHXZ.js +33 -0
- package/dist/chunk-EEF3YEHW.js +2 -0
- package/dist/chunk-F2LLHRRZ.js +2 -0
- package/dist/chunk-FCC3XJTI.js +2 -0
- package/dist/chunk-GNXRLK5G.js +2 -0
- package/dist/chunk-GXVB36TG.js +62 -0
- package/dist/chunk-HMKJTAZD.js +2 -0
- package/dist/chunk-IBGBI3VU.js +2 -0
- package/dist/chunk-IYFZS4PV.js +84 -0
- package/dist/chunk-JH3A7HTU.js +2 -0
- package/dist/chunk-JS2RNIC7.js +2 -0
- package/dist/chunk-K5FQFCSN.js +41 -0
- package/dist/chunk-K6GBKEQE.js +6 -0
- package/dist/chunk-KO7YJRWP.js +12 -0
- package/dist/chunk-KYT47WU2.js +4 -0
- package/dist/chunk-LORWXBOO.js +2 -0
- package/dist/chunk-LX4H4LLG.js +89 -0
- package/dist/chunk-N3Z2SJCR.js +2 -0
- package/dist/chunk-NTDA4A2D.js +25 -0
- package/dist/chunk-NXMYYHDO.js +24 -0
- package/dist/chunk-PZ6ESKRH.js +7 -0
- package/dist/chunk-QXE6EDY2.js +6 -0
- package/dist/chunk-RJ7SPBJ5.js +5 -0
- package/dist/chunk-RWE6FHG3.js +3 -0
- package/dist/chunk-SDX6MDBL.js +2 -0
- package/dist/chunk-SG35Y7J2.js +2 -0
- package/dist/chunk-STOGKRJH.js +4 -0
- package/dist/chunk-TINPMWJK.js +2 -0
- package/dist/chunk-UJB62HV3.js +2 -0
- package/dist/chunk-VEUMRDHW.js +2 -0
- package/dist/chunk-WCDXJGYT.js +65 -0
- package/dist/chunk-WTSTDJZ7.js +6 -0
- package/dist/chunk-XAZTIDST.js +2 -0
- package/dist/chunk-XVDASCN7.js +35 -0
- package/dist/chunk-Y7H6D2EV.js +2 -0
- package/dist/chunk-Y7LOQSWY.js +2 -0
- package/dist/chunk-YIPCV7M7.js +70 -0
- package/dist/chunk-ZSRXMNMK.js +5 -0
- package/dist/chunk-ZXKURFVB.js +56 -0
- package/dist/cli.js +509 -8758
- package/dist/{db-6F9R9e_t.d.ts → db-BSTtBG_H.d.ts} +146 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +13 -1616
- package/dist/postinstall.js +4 -100
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +1 -8
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +1 -8
- package/dist/queries/by-kind.d.ts +1 -4
- package/dist/queries/by-kind.js +1 -10
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -8
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +1 -8
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -8
- package/dist/queries/complexity-hotspots.d.ts +5 -10
- package/dist/queries/complexity-hotspots.js +1 -8
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +1 -8
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +1 -8
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +1 -10
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +1 -8
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +1 -8
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +1 -9
- package/dist/queries/deep-chains.d.ts +9 -1
- package/dist/queries/deep-chains.js +1 -8
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +1 -10
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +1 -7
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -8
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +1 -8
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +1 -14
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -6
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -20
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +1 -8
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -8
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +1 -12
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +1 -197
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +1 -9
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +1 -8
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +1 -8
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +1 -8
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +1 -8
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +1 -9
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +1 -8
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +1 -8
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +1 -8
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +1 -8
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +1 -10
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +1 -8
- package/dist/queries/stale-abstractions.d.ts +15 -5
- package/dist/queries/stale-abstractions.js +1 -8
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/stats.js +1 -6
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +1 -8
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +1 -9
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +1 -9
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +1 -9
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +1 -8
- package/dist/reindex-worker.js +7 -672
- package/package.json +20 -2
- package/dist/chunk-2MQ5DPY6.js +0 -61
- package/dist/chunk-2QTYIOJ5.js +0 -165
- package/dist/chunk-3VI4YXCL.js +0 -172
- package/dist/chunk-3VV2G6U7.js +0 -34
- package/dist/chunk-44PFXVXG.js +0 -76
- package/dist/chunk-6SLFQR36.js +0 -64
- package/dist/chunk-74RFWB5T.js +0 -24
- package/dist/chunk-7DBPRGMS.js +0 -221
- package/dist/chunk-DTB724R3.js +0 -110
- package/dist/chunk-FLOYI6I4.js +0 -185
- package/dist/chunk-FO2CBB7U.js +0 -23
- package/dist/chunk-GJT3MO2T.js +0 -17
- package/dist/chunk-HAP4LJKX.js +0 -66
- package/dist/chunk-JCOJQ4I6.js +0 -93
- package/dist/chunk-JGQMOS4V.js +0 -59
- package/dist/chunk-JMD4WJ2Q.js +0 -213
- package/dist/chunk-JSQPZOPO.js +0 -64
- package/dist/chunk-JSXGC2EH.js +0 -151
- package/dist/chunk-JZN3DRCT.js +0 -59
- package/dist/chunk-KMWYB3CX.js +0 -71
- package/dist/chunk-MRM755FU.js +0 -37
- package/dist/chunk-N2XO3Z5F.js +0 -69
- package/dist/chunk-OLW5UL36.js +0 -76
- package/dist/chunk-OMCRXXDX.js +0 -2600
- package/dist/chunk-OWJOHUZE.js +0 -44
- package/dist/chunk-P3VCDYMJ.js +0 -269
- package/dist/chunk-PEDH3D4G.js +0 -53
- package/dist/chunk-POAN4SCR.js +0 -46
- package/dist/chunk-PTMGEBU3.js +0 -101
- package/dist/chunk-PU44HK7P.js +0 -87
- package/dist/chunk-QJI7EECA.js +0 -327
- package/dist/chunk-R5HICGMB.js +0 -110
- package/dist/chunk-RJ2D6YWQ.js +0 -49
- package/dist/chunk-RZ5GYPBP.js +0 -79
- package/dist/chunk-SRLQNO6O.js +0 -101
- package/dist/chunk-UGS7HJI4.js +0 -84
- package/dist/chunk-VKUUXOE7.js +0 -105
- package/dist/chunk-VPUJSJCI.js +0 -84
- package/dist/chunk-VRWVV3EP.js +0 -72
- package/dist/chunk-WJWQEU4A.js +0 -162
- package/dist/chunk-WJZHDUSB.js +0 -40
- package/dist/chunk-WWOCQ5W4.js +0 -34
- package/dist/chunk-X3Q2OVRL.js +0 -77
- package/dist/chunk-Y3P7QKKN.js +0 -27
- package/dist/chunk-Y6FAHY4N.js +0 -81
- package/dist/chunk-YMSJCSRG.js +0 -213
- package/dist/chunk-ZDL3U4W2.js +0 -124
- package/dist/chunk-ZXNX5JRE.js +0 -216
- package/dist/queries/clean-signature.d.ts +0 -17
- package/dist/queries/clean-signature.js +0 -9
package/dist/chunk-JCOJQ4I6.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildFileDepGraph
|
|
3
|
-
} from "./chunk-OMCRXXDX.js";
|
|
4
|
-
|
|
5
|
-
// src/queries/similar-files.ts
|
|
6
|
-
function similarFiles(db, opts = {}) {
|
|
7
|
-
const { minSimilarity = 0.5, limit = 20, scope, filePattern } = opts;
|
|
8
|
-
const minDeps = opts.minDeps ?? (filePattern ? 1 : 3);
|
|
9
|
-
const profiles = buildFileProfiles(db, { scope, minDeps });
|
|
10
|
-
const results = [];
|
|
11
|
-
if (filePattern) {
|
|
12
|
-
const target = profiles.find((p) => p.file.includes(filePattern));
|
|
13
|
-
if (!target) return [];
|
|
14
|
-
for (const candidate of profiles) {
|
|
15
|
-
if (candidate.file === target.file) continue;
|
|
16
|
-
const result = compareProfiles(target, candidate, minSimilarity);
|
|
17
|
-
if (result) results.push(result);
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
for (let i = 0; i < profiles.length; i++) {
|
|
21
|
-
for (let j = i + 1; j < profiles.length; j++) {
|
|
22
|
-
const result = compareProfiles(profiles[i], profiles[j], minSimilarity);
|
|
23
|
-
if (result) results.push(result);
|
|
24
|
-
}
|
|
25
|
-
if (results.length > limit * 5) break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
results.sort((a, b) => b.similarity - a.similarity);
|
|
29
|
-
return results.slice(0, limit);
|
|
30
|
-
}
|
|
31
|
-
function buildFileProfiles(db, opts) {
|
|
32
|
-
const { scope, minDeps } = opts;
|
|
33
|
-
const depMap = buildFileDepGraph(db, scope);
|
|
34
|
-
const universalDeps = findUniversalDependencies(depMap);
|
|
35
|
-
const profiles = [];
|
|
36
|
-
for (const [file, deps] of depMap) {
|
|
37
|
-
if (deps.size >= minDeps) {
|
|
38
|
-
profiles.push({
|
|
39
|
-
file,
|
|
40
|
-
deps: new Set([...deps].filter((dep) => !universalDeps.has(dep)))
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return profiles;
|
|
45
|
-
}
|
|
46
|
-
function findUniversalDependencies(depMap) {
|
|
47
|
-
const universalDeps = /* @__PURE__ */ new Set();
|
|
48
|
-
const fileCount = depMap.size;
|
|
49
|
-
if (fileCount === 0) return universalDeps;
|
|
50
|
-
const depCounts = /* @__PURE__ */ new Map();
|
|
51
|
-
for (const deps of depMap.values()) {
|
|
52
|
-
for (const dep of deps) {
|
|
53
|
-
depCounts.set(dep, (depCounts.get(dep) ?? 0) + 1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
for (const [dep, count] of depCounts) {
|
|
57
|
-
if (count >= 6 && count / fileCount > 0.8) {
|
|
58
|
-
universalDeps.add(dep);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return universalDeps;
|
|
62
|
-
}
|
|
63
|
-
function compareProfiles(a, b, minSimilarity) {
|
|
64
|
-
const shared = /* @__PURE__ */ new Set();
|
|
65
|
-
for (const dep of a.deps) {
|
|
66
|
-
if (b.deps.has(dep)) shared.add(dep);
|
|
67
|
-
}
|
|
68
|
-
if (shared.size === 0) return null;
|
|
69
|
-
const unionSize = (/* @__PURE__ */ new Set([...a.deps, ...b.deps])).size;
|
|
70
|
-
const similarity = shared.size / unionSize;
|
|
71
|
-
if (similarity < minSimilarity) return null;
|
|
72
|
-
const uniqueA = [];
|
|
73
|
-
for (const dep of a.deps) {
|
|
74
|
-
if (!b.deps.has(dep)) uniqueA.push(dep);
|
|
75
|
-
}
|
|
76
|
-
const uniqueB = [];
|
|
77
|
-
for (const dep of b.deps) {
|
|
78
|
-
if (!a.deps.has(dep)) uniqueB.push(dep);
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
fileA: a.file,
|
|
82
|
-
fileB: b.file,
|
|
83
|
-
similarity,
|
|
84
|
-
sharedDeps: [...shared],
|
|
85
|
-
uniqueToA: uniqueA,
|
|
86
|
-
uniqueToB: uniqueB
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export {
|
|
91
|
-
similarFiles
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=chunk-JCOJQ4I6.js.map
|
package/dist/chunk-JGQMOS4V.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAllDefinitions,
|
|
3
|
-
getCallerRowsForSymbol
|
|
4
|
-
} from "./chunk-OMCRXXDX.js";
|
|
5
|
-
import {
|
|
6
|
-
shortenSymbol
|
|
7
|
-
} from "./chunk-YMSJCSRG.js";
|
|
8
|
-
|
|
9
|
-
// src/queries/hotspots.ts
|
|
10
|
-
function hotspots(db, opts = {}) {
|
|
11
|
-
const { limit = 30, scope } = opts;
|
|
12
|
-
const scopeFilter = scope ? `AND def_d.relative_path LIKE '%${scope}%'` : "";
|
|
13
|
-
const rows = db.all(
|
|
14
|
-
`SELECT
|
|
15
|
-
gs.symbol,
|
|
16
|
-
COUNT(*) AS ref_count,
|
|
17
|
-
COUNT(DISTINCT ref_d.id) AS file_count,
|
|
18
|
-
def_d.relative_path AS defined_in
|
|
19
|
-
FROM mentions m
|
|
20
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
21
|
-
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
22
|
-
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
23
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
24
|
-
JOIN documents def_d ON der.document_id = def_d.id
|
|
25
|
-
WHERE m.role != 1
|
|
26
|
-
${db.pathExclusionsFor("def_d")}
|
|
27
|
-
${db.symbolNoiseFor("gs")}
|
|
28
|
-
${scopeFilter}
|
|
29
|
-
GROUP BY gs.id
|
|
30
|
-
ORDER BY ref_count DESC
|
|
31
|
-
LIMIT ?`,
|
|
32
|
-
limit
|
|
33
|
-
);
|
|
34
|
-
const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
|
|
35
|
-
symbol: r.symbol,
|
|
36
|
-
shortName: shortenSymbol(r.symbol),
|
|
37
|
-
refCount: r.ref_count,
|
|
38
|
-
fileCount: r.file_count,
|
|
39
|
-
definedIn: r.defined_in
|
|
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);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
hotspots
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=chunk-JGQMOS4V.js.map
|
package/dist/chunk-JMD4WJ2Q.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildFileDepGraph
|
|
3
|
-
} from "./chunk-OMCRXXDX.js";
|
|
4
|
-
|
|
5
|
-
// src/queries/similar-chains.ts
|
|
6
|
-
function similarChains(db, opts = {}) {
|
|
7
|
-
const {
|
|
8
|
-
minSimilarity = 0.5,
|
|
9
|
-
limit = 15,
|
|
10
|
-
scope,
|
|
11
|
-
minChainLength = 3,
|
|
12
|
-
maxChainLength = 8
|
|
13
|
-
} = opts;
|
|
14
|
-
const graph = buildFileDepGraph(db, scope);
|
|
15
|
-
const rawChains = generateChains(graph, minChainLength, maxChainLength);
|
|
16
|
-
if (rawChains.length === 0) return [];
|
|
17
|
-
const nodeFreq = /* @__PURE__ */ new Map();
|
|
18
|
-
const tailFreq = /* @__PURE__ */ new Map();
|
|
19
|
-
for (const chain of rawChains) {
|
|
20
|
-
const seen = /* @__PURE__ */ new Set();
|
|
21
|
-
for (const node of chain) {
|
|
22
|
-
if (!seen.has(node)) {
|
|
23
|
-
nodeFreq.set(node, (nodeFreq.get(node) ?? 0) + 1);
|
|
24
|
-
seen.add(node);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
for (let t = Math.max(0, chain.length - 2); t < chain.length; t++) {
|
|
28
|
-
tailFreq.set(chain[t], (tailFreq.get(chain[t]) ?? 0) + 1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const infraThreshold = rawChains.length * 0.9;
|
|
32
|
-
const tailThreshold = rawChains.length * 0.8;
|
|
33
|
-
const infraNodes = /* @__PURE__ */ new Set();
|
|
34
|
-
for (const [node, freq] of nodeFreq) {
|
|
35
|
-
if (freq > infraThreshold) infraNodes.add(node);
|
|
36
|
-
}
|
|
37
|
-
for (const [node, freq] of tailFreq) {
|
|
38
|
-
if (freq > tailThreshold) infraNodes.add(node);
|
|
39
|
-
}
|
|
40
|
-
const structuralNames = ["index.ts", "index.js", "cli.ts", "main.ts", "health.ts", "health.js"];
|
|
41
|
-
for (const node of nodeFreq.keys()) {
|
|
42
|
-
const basename = node.split("/").pop() ?? "";
|
|
43
|
-
if (structuralNames.includes(basename)) infraNodes.add(node);
|
|
44
|
-
}
|
|
45
|
-
const filteredChains = [];
|
|
46
|
-
for (const chain of rawChains) {
|
|
47
|
-
const filtered = chain.filter((n) => !infraNodes.has(n));
|
|
48
|
-
if (filtered.length >= 2) {
|
|
49
|
-
filteredChains.push({ original: chain, filtered });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (filteredChains.length < 2) return [];
|
|
53
|
-
const results = [];
|
|
54
|
-
for (let i = 0; i < filteredChains.length; i++) {
|
|
55
|
-
for (let j = i + 1; j < filteredChains.length; j++) {
|
|
56
|
-
const a = filteredChains[i];
|
|
57
|
-
const b = filteredChains[j];
|
|
58
|
-
const setA = new Set(a.filtered);
|
|
59
|
-
let hasShared = false;
|
|
60
|
-
for (const node of b.filtered) {
|
|
61
|
-
if (setA.has(node)) {
|
|
62
|
-
hasShared = true;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (!hasShared) continue;
|
|
67
|
-
const { distance, ops } = editDistance(a.filtered, b.filtered);
|
|
68
|
-
const maxLen = Math.max(a.filtered.length, b.filtered.length);
|
|
69
|
-
if (maxLen === 0) continue;
|
|
70
|
-
const similarity = 1 - distance / maxLen;
|
|
71
|
-
if (similarity < minSimilarity) continue;
|
|
72
|
-
if (distance === 0) continue;
|
|
73
|
-
const divergencePoints = ops.filter((op) => op.type === "substitute").map((op) => ({
|
|
74
|
-
index: op.indexA,
|
|
75
|
-
nodeA: a.filtered[op.indexA],
|
|
76
|
-
nodeB: b.filtered[op.indexB]
|
|
77
|
-
}));
|
|
78
|
-
if (divergencePoints.length === 0) continue;
|
|
79
|
-
const matchCount = ops.filter((op) => op.type === "match").length;
|
|
80
|
-
if (matchCount < 2) continue;
|
|
81
|
-
const commonPrefix = getCommonPrefix(a.original, b.original);
|
|
82
|
-
const commonSuffix = getCommonSuffix(a.original, b.original);
|
|
83
|
-
results.push({
|
|
84
|
-
chainA: a.original,
|
|
85
|
-
chainB: b.original,
|
|
86
|
-
similarity,
|
|
87
|
-
editDistance: distance,
|
|
88
|
-
divergencePoints,
|
|
89
|
-
commonPrefix,
|
|
90
|
-
commonSuffix
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (results.length > limit * 10) break;
|
|
94
|
-
}
|
|
95
|
-
results.sort((a, b) => {
|
|
96
|
-
if (Math.abs(b.similarity - a.similarity) > 0.01) return b.similarity - a.similarity;
|
|
97
|
-
return a.divergencePoints.length - b.divergencePoints.length;
|
|
98
|
-
});
|
|
99
|
-
const deduped = [];
|
|
100
|
-
for (const r of results) {
|
|
101
|
-
const isDuplicate = deduped.some(
|
|
102
|
-
(existing) => isSubChain(r.chainA, existing.chainA) && isSubChain(r.chainB, existing.chainB)
|
|
103
|
-
);
|
|
104
|
-
if (!isDuplicate) deduped.push(r);
|
|
105
|
-
if (deduped.length >= limit) break;
|
|
106
|
-
}
|
|
107
|
-
return deduped;
|
|
108
|
-
}
|
|
109
|
-
function generateChains(graph, minLen, maxLen) {
|
|
110
|
-
const chains = [];
|
|
111
|
-
const maxChains = 500;
|
|
112
|
-
for (const startNode of graph.keys()) {
|
|
113
|
-
if (chains.length >= maxChains) break;
|
|
114
|
-
dfsChains(graph, startNode, [startNode], /* @__PURE__ */ new Set([startNode]), minLen, maxLen, chains, maxChains);
|
|
115
|
-
}
|
|
116
|
-
return chains;
|
|
117
|
-
}
|
|
118
|
-
function dfsChains(graph, node, path, visited, minLen, maxLen, results, maxResults) {
|
|
119
|
-
if (results.length >= maxResults) return;
|
|
120
|
-
if (path.length >= maxLen) {
|
|
121
|
-
if (path.length >= minLen) results.push([...path]);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const neighbors = graph.get(node);
|
|
125
|
-
if (!neighbors || neighbors.size === 0) {
|
|
126
|
-
if (path.length >= minLen) results.push([...path]);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
let extended = false;
|
|
130
|
-
for (const next of neighbors) {
|
|
131
|
-
if (visited.has(next)) continue;
|
|
132
|
-
visited.add(next);
|
|
133
|
-
path.push(next);
|
|
134
|
-
dfsChains(graph, next, path, visited, minLen, maxLen, results, maxResults);
|
|
135
|
-
path.pop();
|
|
136
|
-
visited.delete(next);
|
|
137
|
-
extended = true;
|
|
138
|
-
if (results.length >= maxResults) return;
|
|
139
|
-
}
|
|
140
|
-
if (!extended && path.length >= minLen) {
|
|
141
|
-
results.push([...path]);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function editDistance(a, b) {
|
|
145
|
-
const m = a.length;
|
|
146
|
-
const n = b.length;
|
|
147
|
-
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
148
|
-
for (let i2 = 0; i2 <= m; i2++) dp[i2][0] = i2;
|
|
149
|
-
for (let j2 = 0; j2 <= n; j2++) dp[0][j2] = j2;
|
|
150
|
-
for (let i2 = 1; i2 <= m; i2++) {
|
|
151
|
-
for (let j2 = 1; j2 <= n; j2++) {
|
|
152
|
-
if (a[i2 - 1] === b[j2 - 1]) {
|
|
153
|
-
dp[i2][j2] = dp[i2 - 1][j2 - 1];
|
|
154
|
-
} else {
|
|
155
|
-
dp[i2][j2] = 1 + Math.min(
|
|
156
|
-
dp[i2 - 1][j2],
|
|
157
|
-
dp[i2][j2 - 1],
|
|
158
|
-
dp[i2 - 1][j2 - 1]
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
const ops = [];
|
|
164
|
-
let i = m, j = n;
|
|
165
|
-
while (i > 0 || j > 0) {
|
|
166
|
-
if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
|
|
167
|
-
ops.unshift({ type: "match", indexA: i - 1, indexB: j - 1 });
|
|
168
|
-
i--;
|
|
169
|
-
j--;
|
|
170
|
-
} else if (i > 0 && j > 0 && dp[i][j] === dp[i - 1][j - 1] + 1) {
|
|
171
|
-
ops.unshift({ type: "substitute", indexA: i - 1, indexB: j - 1 });
|
|
172
|
-
i--;
|
|
173
|
-
j--;
|
|
174
|
-
} else if (j > 0 && dp[i][j] === dp[i][j - 1] + 1) {
|
|
175
|
-
ops.unshift({ type: "insert", indexA: i, indexB: j - 1 });
|
|
176
|
-
j--;
|
|
177
|
-
} else {
|
|
178
|
-
ops.unshift({ type: "delete", indexA: i - 1, indexB: j });
|
|
179
|
-
i--;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return { distance: dp[m][n], ops };
|
|
183
|
-
}
|
|
184
|
-
function getCommonPrefix(a, b) {
|
|
185
|
-
const prefix = [];
|
|
186
|
-
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
187
|
-
if (a[i] === b[i]) prefix.push(a[i]);
|
|
188
|
-
else break;
|
|
189
|
-
}
|
|
190
|
-
return prefix;
|
|
191
|
-
}
|
|
192
|
-
function getCommonSuffix(a, b) {
|
|
193
|
-
const suffix = [];
|
|
194
|
-
let ai = a.length - 1;
|
|
195
|
-
let bi = b.length - 1;
|
|
196
|
-
while (ai >= 0 && bi >= 0 && a[ai] === b[bi]) {
|
|
197
|
-
suffix.unshift(a[ai]);
|
|
198
|
-
ai--;
|
|
199
|
-
bi--;
|
|
200
|
-
}
|
|
201
|
-
return suffix;
|
|
202
|
-
}
|
|
203
|
-
function isSubChain(sub, full) {
|
|
204
|
-
if (sub.length > full.length) return false;
|
|
205
|
-
const fullStr = full.join("\u2192");
|
|
206
|
-
const subStr = sub.join("\u2192");
|
|
207
|
-
return fullStr.includes(subStr);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export {
|
|
211
|
-
similarChains
|
|
212
|
-
};
|
|
213
|
-
//# sourceMappingURL=chunk-JMD4WJ2Q.js.map
|
package/dist/chunk-JSQPZOPO.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDefinitionsForFile,
|
|
3
|
-
resolveIndexedFile
|
|
4
|
-
} from "./chunk-OMCRXXDX.js";
|
|
5
|
-
import {
|
|
6
|
-
shortenSymbol
|
|
7
|
-
} from "./chunk-YMSJCSRG.js";
|
|
8
|
-
|
|
9
|
-
// src/queries/change-surface.ts
|
|
10
|
-
function changeSurface(db, filePattern) {
|
|
11
|
-
const resolvedFile = resolveIndexedFile(db, filePattern);
|
|
12
|
-
if (!resolvedFile) return null;
|
|
13
|
-
const doc = db.get(
|
|
14
|
-
`SELECT id, relative_path FROM documents
|
|
15
|
-
WHERE relative_path = ?
|
|
16
|
-
${db.pathExclusionsFor("documents")}
|
|
17
|
-
LIMIT 1`,
|
|
18
|
-
resolvedFile
|
|
19
|
-
);
|
|
20
|
-
if (!doc || db.isIgnored(doc.relative_path)) return null;
|
|
21
|
-
const definitions = getDefinitionsForFile(db, doc.relative_path).sort((a, b) => a.startLine - b.startLine || a.endLine - b.endLine);
|
|
22
|
-
const symbols = [];
|
|
23
|
-
let totalExternalConsumers = 0;
|
|
24
|
-
for (const def of definitions) {
|
|
25
|
-
const consumerRow = db.get(
|
|
26
|
-
`SELECT COUNT(DISTINCT c.document_id) AS consumer_count
|
|
27
|
-
FROM mentions m
|
|
28
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
29
|
-
WHERE m.symbol_id = ?
|
|
30
|
-
AND m.role != 1
|
|
31
|
-
AND c.document_id != ?`,
|
|
32
|
-
def.symbolId,
|
|
33
|
-
doc.id
|
|
34
|
-
);
|
|
35
|
-
const externalConsumers = consumerRow?.consumer_count ?? 0;
|
|
36
|
-
let riskLevel;
|
|
37
|
-
if (externalConsumers > 10) {
|
|
38
|
-
riskLevel = "high";
|
|
39
|
-
} else if (externalConsumers > 0) {
|
|
40
|
-
riskLevel = "medium";
|
|
41
|
-
} else {
|
|
42
|
-
riskLevel = "low";
|
|
43
|
-
}
|
|
44
|
-
totalExternalConsumers += externalConsumers;
|
|
45
|
-
symbols.push({
|
|
46
|
-
symbol: def.symbol,
|
|
47
|
-
shortName: shortenSymbol(def.symbol),
|
|
48
|
-
startLine: def.startLine,
|
|
49
|
-
endLine: def.endLine,
|
|
50
|
-
externalConsumers,
|
|
51
|
-
riskLevel
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
file: doc.relative_path,
|
|
56
|
-
symbols,
|
|
57
|
-
totalExternalConsumers
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
changeSurface
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=chunk-JSQPZOPO.js.map
|
package/dist/chunk-JSXGC2EH.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
shortenSymbol
|
|
3
|
-
} from "./chunk-YMSJCSRG.js";
|
|
4
|
-
|
|
5
|
-
// src/queries/diff-impact.ts
|
|
6
|
-
import { execFileSync } from "child_process";
|
|
7
|
-
function diffImpact(db, opts = {}) {
|
|
8
|
-
const { base = "HEAD" } = opts;
|
|
9
|
-
let changedFileLines;
|
|
10
|
-
try {
|
|
11
|
-
changedFileLines = getChangedFiles(db.config.projectRoot, base);
|
|
12
|
-
} catch {
|
|
13
|
-
return {
|
|
14
|
-
changedFiles: [],
|
|
15
|
-
changedSymbols: [],
|
|
16
|
-
affectedConsumers: [],
|
|
17
|
-
summary: {
|
|
18
|
-
totalChangedFiles: 0,
|
|
19
|
-
totalChangedSymbols: 0,
|
|
20
|
-
totalAffectedFiles: 0,
|
|
21
|
-
note: "Unable to compute git diff."
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (changedFileLines.length === 0) {
|
|
26
|
-
return {
|
|
27
|
-
changedFiles: [],
|
|
28
|
-
changedSymbols: [],
|
|
29
|
-
affectedConsumers: [],
|
|
30
|
-
summary: {
|
|
31
|
-
totalChangedFiles: 0,
|
|
32
|
-
totalChangedSymbols: 0,
|
|
33
|
-
totalAffectedFiles: 0,
|
|
34
|
-
note: "No changed files found."
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const changedFiles = [];
|
|
39
|
-
const changedDocIds = [];
|
|
40
|
-
for (const file of changedFileLines) {
|
|
41
|
-
const doc = db.get(
|
|
42
|
-
`SELECT id, relative_path FROM documents
|
|
43
|
-
WHERE relative_path LIKE ?
|
|
44
|
-
LIMIT 1`,
|
|
45
|
-
`%${file}`
|
|
46
|
-
);
|
|
47
|
-
if (doc && !db.isIgnored(doc.relative_path)) {
|
|
48
|
-
changedFiles.push(doc.relative_path);
|
|
49
|
-
changedDocIds.push(doc.id);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (changedDocIds.length === 0) {
|
|
53
|
-
return {
|
|
54
|
-
changedFiles: changedFileLines,
|
|
55
|
-
changedSymbols: [],
|
|
56
|
-
affectedConsumers: [],
|
|
57
|
-
summary: {
|
|
58
|
-
totalChangedFiles: changedFileLines.length,
|
|
59
|
-
totalChangedSymbols: 0,
|
|
60
|
-
totalAffectedFiles: 0,
|
|
61
|
-
note: "Changed files are not present in the current SCIP index."
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const docPlaceholders = changedDocIds.map(() => "?").join(",");
|
|
66
|
-
const syms = db.all(
|
|
67
|
-
`SELECT DISTINCT gs.id AS symbol_id, gs.symbol, d.relative_path
|
|
68
|
-
FROM defn_enclosing_ranges der
|
|
69
|
-
JOIN global_symbols gs ON der.symbol_id = gs.id
|
|
70
|
-
JOIN documents d ON der.document_id = d.id
|
|
71
|
-
WHERE der.document_id IN (${docPlaceholders})
|
|
72
|
-
${db.symbolNoiseFor("gs")}
|
|
73
|
-
ORDER BY d.relative_path`,
|
|
74
|
-
...changedDocIds
|
|
75
|
-
);
|
|
76
|
-
const changedSymbols = [];
|
|
77
|
-
const consumerMap = /* @__PURE__ */ new Map();
|
|
78
|
-
for (const sym of syms) {
|
|
79
|
-
const fanInRow = db.get(
|
|
80
|
-
`SELECT COUNT(DISTINCT c.document_id) AS fan_in
|
|
81
|
-
FROM mentions m
|
|
82
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
83
|
-
WHERE m.symbol_id = ?
|
|
84
|
-
AND m.role != 1`,
|
|
85
|
-
sym.symbol_id
|
|
86
|
-
);
|
|
87
|
-
const fanIn = fanInRow?.fan_in ?? 0;
|
|
88
|
-
const shortName = shortenSymbol(sym.symbol);
|
|
89
|
-
changedSymbols.push({
|
|
90
|
-
symbol: sym.symbol,
|
|
91
|
-
shortName,
|
|
92
|
-
file: sym.relative_path,
|
|
93
|
-
fanIn
|
|
94
|
-
});
|
|
95
|
-
const consumers = db.all(
|
|
96
|
-
`SELECT DISTINCT ref_d.relative_path
|
|
97
|
-
FROM mentions m
|
|
98
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
99
|
-
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
100
|
-
WHERE m.symbol_id = ?
|
|
101
|
-
AND m.role != 1
|
|
102
|
-
AND ref_d.relative_path NOT IN (${changedFiles.map(() => "?").join(",")})
|
|
103
|
-
${db.pathExclusionsFor("ref_d")}`,
|
|
104
|
-
sym.symbol_id,
|
|
105
|
-
...changedFiles
|
|
106
|
-
);
|
|
107
|
-
for (const consumer of consumers) {
|
|
108
|
-
if (db.isIgnored(consumer.relative_path)) continue;
|
|
109
|
-
if (!consumerMap.has(consumer.relative_path)) {
|
|
110
|
-
consumerMap.set(consumer.relative_path, /* @__PURE__ */ new Set());
|
|
111
|
-
}
|
|
112
|
-
consumerMap.get(consumer.relative_path).add(shortName);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const affectedConsumers = [...consumerMap.entries()].map(([file, symbols]) => ({ file, consumedSymbols: symbols.size })).sort((a, b) => b.consumedSymbols - a.consumedSymbols);
|
|
116
|
-
return {
|
|
117
|
-
changedFiles,
|
|
118
|
-
changedSymbols,
|
|
119
|
-
affectedConsumers,
|
|
120
|
-
summary: {
|
|
121
|
-
totalChangedFiles: changedFiles.length,
|
|
122
|
-
totalChangedSymbols: changedSymbols.length,
|
|
123
|
-
totalAffectedFiles: affectedConsumers.length
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function getChangedFiles(projectRoot, base) {
|
|
128
|
-
const diff = execFileSync("git", ["diff", "--name-only", base], {
|
|
129
|
-
encoding: "utf-8",
|
|
130
|
-
cwd: projectRoot,
|
|
131
|
-
timeout: 1e4
|
|
132
|
-
});
|
|
133
|
-
const staged = execFileSync("git", ["diff", "--name-only", "--cached", base], {
|
|
134
|
-
encoding: "utf-8",
|
|
135
|
-
cwd: projectRoot,
|
|
136
|
-
timeout: 1e4
|
|
137
|
-
});
|
|
138
|
-
const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], {
|
|
139
|
-
encoding: "utf-8",
|
|
140
|
-
cwd: projectRoot,
|
|
141
|
-
timeout: 1e4
|
|
142
|
-
});
|
|
143
|
-
return [...new Set(
|
|
144
|
-
[diff, staged, untracked].flatMap((chunk) => chunk.split("\n")).map((line) => line.trim()).filter((line) => line.length > 0)
|
|
145
|
-
)];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export {
|
|
149
|
-
diffImpact
|
|
150
|
-
};
|
|
151
|
-
//# sourceMappingURL=chunk-JSXGC2EH.js.map
|
package/dist/chunk-JZN3DRCT.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDefinitionsForFile,
|
|
3
|
-
resolveIndexedPaths
|
|
4
|
-
} from "./chunk-OMCRXXDX.js";
|
|
5
|
-
import {
|
|
6
|
-
shortenSymbol
|
|
7
|
-
} from "./chunk-YMSJCSRG.js";
|
|
8
|
-
|
|
9
|
-
// src/queries/outline.ts
|
|
10
|
-
function outline(db, filePattern) {
|
|
11
|
-
const resolvedPaths = resolveIndexedPaths(db, filePattern);
|
|
12
|
-
if (resolvedPaths.length === 0) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
const definitions = resolvedPaths.flatMap((relativePath) => getDefinitionsForFile(db, relativePath)).filter((d) => !db.isIgnored(d.relativePath)).sort(
|
|
16
|
-
(a, b) => a.relativePath.localeCompare(b.relativePath) || a.startLine - b.startLine || a.endLine - b.endLine
|
|
17
|
-
);
|
|
18
|
-
const nodes = definitions.map((d) => ({
|
|
19
|
-
symbol: d.symbol,
|
|
20
|
-
shortName: shortenSymbol(d.symbol),
|
|
21
|
-
startLine: d.startLine,
|
|
22
|
-
endLine: d.endLine,
|
|
23
|
-
children: []
|
|
24
|
-
}));
|
|
25
|
-
const nodeMap = /* @__PURE__ */ new Map();
|
|
26
|
-
for (const n of nodes) nodeMap.set(n.symbol, n);
|
|
27
|
-
const roots = [];
|
|
28
|
-
for (let i = 0; i < definitions.length; i++) {
|
|
29
|
-
const d = definitions[i];
|
|
30
|
-
const node = nodes[i];
|
|
31
|
-
if (d.enclosingSymbol && nodeMap.has(d.enclosingSymbol)) {
|
|
32
|
-
nodeMap.get(d.enclosingSymbol).children.push(node);
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
let bestParent = null;
|
|
36
|
-
let bestSize = Infinity;
|
|
37
|
-
for (const candidate of nodes) {
|
|
38
|
-
if (candidate === node) continue;
|
|
39
|
-
if (candidate.startLine <= node.startLine && candidate.endLine >= node.endLine) {
|
|
40
|
-
const size = candidate.endLine - candidate.startLine;
|
|
41
|
-
if (size < bestSize) {
|
|
42
|
-
bestSize = size;
|
|
43
|
-
bestParent = candidate;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (bestParent) {
|
|
48
|
-
bestParent.children.push(node);
|
|
49
|
-
} else {
|
|
50
|
-
roots.push(node);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return roots;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
outline
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=chunk-JZN3DRCT.js.map
|