@syke1/mcp-server 1.5.6 → 1.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/ai/analyzer.js +1 -112
- package/dist/ai/context-extractor.js +1 -224
- package/dist/ai/provider.js +1 -186
- package/dist/ai/realtime-analyzer.js +1 -253
- package/dist/config.js +1 -121
- package/dist/git/change-coupling.js +1 -250
- package/dist/graph/incremental.js +1 -319
- package/dist/graph/memo-cache.js +1 -176
- package/dist/graph/scc.js +1 -206
- package/dist/graph.js +1 -137
- package/dist/index.js +1 -852
- package/dist/license/validator.d.ts +6 -0
- package/dist/license/validator.js +1 -328
- package/dist/scoring/pagerank.js +1 -221
- package/dist/scoring/risk-scorer.js +1 -623
- package/dist/tools/analyze-impact.js +1 -378
- package/dist/tools/gate-build.js +1 -409
- package/dist/watcher/file-cache.js +1 -281
- package/dist/web/server.js +1 -925
- package/package.json +3 -2
package/dist/graph/memo-cache.js
CHANGED
|
@@ -1,176 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Memoized BFS Result Cache for SYKE.
|
|
4
|
-
*
|
|
5
|
-
* Caches impact analysis results (BFS reverse traversals) so that
|
|
6
|
-
* repeated queries for the same file return instantly.
|
|
7
|
-
*
|
|
8
|
-
* Smart invalidation: when a file changes, only cache entries that
|
|
9
|
-
* could be affected are evicted. A reverse index maps each file to
|
|
10
|
-
* the set of cache keys whose impactSet contains it, making
|
|
11
|
-
* invalidation O(affected) instead of O(cache_size).
|
|
12
|
-
*
|
|
13
|
-
* Uses LRU eviction when the cache exceeds maxSize.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.createMemoCache = createMemoCache;
|
|
17
|
-
exports.getMemoCache = getMemoCache;
|
|
18
|
-
exports.resetMemoCache = resetMemoCache;
|
|
19
|
-
// ── Implementation ──
|
|
20
|
-
/**
|
|
21
|
-
* Create a new MemoCache with LRU eviction and reverse-index invalidation.
|
|
22
|
-
*
|
|
23
|
-
* @param maxSize Maximum number of cached entries (default 500).
|
|
24
|
-
*/
|
|
25
|
-
function createMemoCache(maxSize = 500) {
|
|
26
|
-
// Main cache: filePath -> MemoEntry
|
|
27
|
-
const cache = new Map();
|
|
28
|
-
// LRU tracking: most recently accessed key moves to the end
|
|
29
|
-
const accessOrder = [];
|
|
30
|
-
// Reverse index: maps each file to the set of cache keys whose
|
|
31
|
-
// impactSet contains that file. Used for O(affected) invalidation.
|
|
32
|
-
const reverseIndex = new Map();
|
|
33
|
-
// Stats
|
|
34
|
-
let hits = 0;
|
|
35
|
-
let misses = 0;
|
|
36
|
-
/**
|
|
37
|
-
* Move a key to the end of the access order (most recently used).
|
|
38
|
-
*/
|
|
39
|
-
function touchKey(key) {
|
|
40
|
-
const idx = accessOrder.indexOf(key);
|
|
41
|
-
if (idx !== -1) {
|
|
42
|
-
accessOrder.splice(idx, 1);
|
|
43
|
-
}
|
|
44
|
-
accessOrder.push(key);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Remove a single entry from the cache and clean up the reverse index.
|
|
48
|
-
*/
|
|
49
|
-
function removeEntry(key) {
|
|
50
|
-
const entry = cache.get(key);
|
|
51
|
-
if (!entry)
|
|
52
|
-
return;
|
|
53
|
-
// Remove from reverse index
|
|
54
|
-
for (const file of entry.impactSet) {
|
|
55
|
-
const keys = reverseIndex.get(file);
|
|
56
|
-
if (keys) {
|
|
57
|
-
keys.delete(key);
|
|
58
|
-
if (keys.size === 0) {
|
|
59
|
-
reverseIndex.delete(file);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Also remove the key itself from the reverse index
|
|
64
|
-
const selfKeys = reverseIndex.get(key);
|
|
65
|
-
if (selfKeys) {
|
|
66
|
-
selfKeys.delete(key);
|
|
67
|
-
if (selfKeys.size === 0) {
|
|
68
|
-
reverseIndex.delete(key);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
cache.delete(key);
|
|
72
|
-
const orderIdx = accessOrder.indexOf(key);
|
|
73
|
-
if (orderIdx !== -1) {
|
|
74
|
-
accessOrder.splice(orderIdx, 1);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Evict the least recently used entry when cache exceeds maxSize.
|
|
79
|
-
*/
|
|
80
|
-
function evictLRU() {
|
|
81
|
-
while (cache.size > maxSize && accessOrder.length > 0) {
|
|
82
|
-
const lruKey = accessOrder.shift();
|
|
83
|
-
removeEntry(lruKey);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Add a file -> cacheKey mapping to the reverse index.
|
|
88
|
-
*/
|
|
89
|
-
function addToReverseIndex(file, cacheKey) {
|
|
90
|
-
let keys = reverseIndex.get(file);
|
|
91
|
-
if (!keys) {
|
|
92
|
-
keys = new Set();
|
|
93
|
-
reverseIndex.set(file, keys);
|
|
94
|
-
}
|
|
95
|
-
keys.add(cacheKey);
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
get(filePath) {
|
|
99
|
-
const entry = cache.get(filePath);
|
|
100
|
-
if (entry) {
|
|
101
|
-
hits++;
|
|
102
|
-
touchKey(filePath);
|
|
103
|
-
return entry;
|
|
104
|
-
}
|
|
105
|
-
misses++;
|
|
106
|
-
return undefined;
|
|
107
|
-
},
|
|
108
|
-
set(filePath, entry) {
|
|
109
|
-
// If already cached, remove old reverse index entries first
|
|
110
|
-
if (cache.has(filePath)) {
|
|
111
|
-
removeEntry(filePath);
|
|
112
|
-
}
|
|
113
|
-
// Store the entry
|
|
114
|
-
cache.set(filePath, entry);
|
|
115
|
-
touchKey(filePath);
|
|
116
|
-
// Build reverse index: map each file in impactSet -> this cache key
|
|
117
|
-
for (const file of entry.impactSet) {
|
|
118
|
-
addToReverseIndex(file, filePath);
|
|
119
|
-
}
|
|
120
|
-
// Also index the key itself (if the queried file changes, its own
|
|
121
|
-
// cached result is stale)
|
|
122
|
-
addToReverseIndex(filePath, filePath);
|
|
123
|
-
// Evict LRU if over capacity
|
|
124
|
-
evictLRU();
|
|
125
|
-
},
|
|
126
|
-
invalidate(affectedFiles) {
|
|
127
|
-
const keysToInvalidate = new Set();
|
|
128
|
-
for (const file of affectedFiles) {
|
|
129
|
-
// Find all cache keys whose impactSet contains this file
|
|
130
|
-
const keys = reverseIndex.get(file);
|
|
131
|
-
if (keys) {
|
|
132
|
-
for (const key of keys) {
|
|
133
|
-
keysToInvalidate.add(key);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// Remove all identified entries
|
|
138
|
-
for (const key of keysToInvalidate) {
|
|
139
|
-
removeEntry(key);
|
|
140
|
-
}
|
|
141
|
-
return keysToInvalidate.size;
|
|
142
|
-
},
|
|
143
|
-
invalidateAll() {
|
|
144
|
-
cache.clear();
|
|
145
|
-
accessOrder.length = 0;
|
|
146
|
-
reverseIndex.clear();
|
|
147
|
-
// Do NOT reset hits/misses — they are cumulative diagnostics
|
|
148
|
-
},
|
|
149
|
-
stats() {
|
|
150
|
-
return {
|
|
151
|
-
size: cache.size,
|
|
152
|
-
hits,
|
|
153
|
-
misses,
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
// ── Singleton Instance ──
|
|
159
|
-
let globalMemoCache = null;
|
|
160
|
-
/**
|
|
161
|
-
* Get the global memo cache instance (lazy initialization).
|
|
162
|
-
*/
|
|
163
|
-
function getMemoCache() {
|
|
164
|
-
if (!globalMemoCache) {
|
|
165
|
-
globalMemoCache = createMemoCache();
|
|
166
|
-
}
|
|
167
|
-
return globalMemoCache;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Reset the global memo cache (e.g., on full graph rebuild).
|
|
171
|
-
*/
|
|
172
|
-
function resetMemoCache() {
|
|
173
|
-
if (globalMemoCache) {
|
|
174
|
-
globalMemoCache.invalidateAll();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
1
|
+
'use strict';const _0x40ebf2=_0x1223;(function(_0x541f41,_0x37710c){const _0x89f226={_0x1fcb68:0xf2,_0x5103aa:0xe4,_0x24fdcb:0xee,_0x465987:0xe3,_0x495797:0xe6,_0x5636a7:0xf7,_0x430eef:0xea},_0x369d95=_0x1223,_0x26b9ba=_0x541f41();while(!![]){try{const _0x22a1db=parseInt(_0x369d95(0xe0))/0x1*(parseInt(_0x369d95(_0x89f226._0x1fcb68))/0x2)+parseInt(_0x369d95(_0x89f226._0x5103aa))/0x3*(-parseInt(_0x369d95(_0x89f226._0x24fdcb))/0x4)+parseInt(_0x369d95(_0x89f226._0x465987))/0x5*(-parseInt(_0x369d95(0xe5))/0x6)+-parseInt(_0x369d95(0xf3))/0x7+parseInt(_0x369d95(_0x89f226._0x495797))/0x8+parseInt(_0x369d95(0xed))/0x9*(-parseInt(_0x369d95(_0x89f226._0x5636a7))/0xa)+-parseInt(_0x369d95(_0x89f226._0x430eef))/0xb*(-parseInt(_0x369d95(0xf5))/0xc);if(_0x22a1db===_0x37710c)break;else _0x26b9ba['push'](_0x26b9ba['shift']());}catch(_0x2ed3f6){_0x26b9ba['push'](_0x26b9ba['shift']());}}}(_0x120d,0x80cfd));function _0x1223(_0xf86bc4,_0x19b4d2){_0xf86bc4=_0xf86bc4-0xda;const _0x120dd9=_0x120d();let _0x1223ff=_0x120dd9[_0xf86bc4];if(_0x1223['gXvxjc']===undefined){var _0x127045=function(_0x1a0b97){const _0x342481='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3d6c36='',_0x4aebc8='';for(let _0x18550b=0x0,_0x593e59,_0x4f8c27,_0x4292bf=0x0;_0x4f8c27=_0x1a0b97['charAt'](_0x4292bf++);~_0x4f8c27&&(_0x593e59=_0x18550b%0x4?_0x593e59*0x40+_0x4f8c27:_0x4f8c27,_0x18550b++%0x4)?_0x3d6c36+=String['fromCharCode'](0xff&_0x593e59>>(-0x2*_0x18550b&0x6)):0x0){_0x4f8c27=_0x342481['indexOf'](_0x4f8c27);}for(let _0x4e544a=0x0,_0x30f3c2=_0x3d6c36['length'];_0x4e544a<_0x30f3c2;_0x4e544a++){_0x4aebc8+='%'+('00'+_0x3d6c36['charCodeAt'](_0x4e544a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4aebc8);};_0x1223['IsgRos']=_0x127045,_0x1223['hZbRzR']={},_0x1223['gXvxjc']=!![];}const _0x4cc6e1=_0x120dd9[0x0],_0x1a654a=_0xf86bc4+_0x4cc6e1,_0x462df6=_0x1223['hZbRzR'][_0x1a654a];return!_0x462df6?(_0x1223ff=_0x1223['IsgRos'](_0x1223ff),_0x1223['hZbRzR'][_0x1a654a]=_0x1223ff):_0x1223ff=_0x462df6,_0x1223ff;}function _0x120d(){const _0xf3e92=['x19LC01VzhvSzq','zgvSzxrL','ntC3ody5m3vKy0jfwG','mtC5mdGXmNHZswTtsG','zhjLBwi','zgvMAw5LuhjVCgvYDhK','ywLNyvu','mKznA09Jsq','mJi0mtKXohrOD3zzCG','Aw5KzxHpzG','ndHItvzqD0q','DuvNvMC','mtbss2nZDKm','z2v0twvTB0nHy2HL','y2XLyxi','BgvUz3rO','Aw52ywXPzgf0zufSBa','C2v0','Aw1Wywn0u2v0','ChvZAa','ntmYotuXsgnQCgzH','AgfZ','z2v0','mJe5mZvos052A0W','nMngyu5NDW','ntCWDLv2zxz4','mty1nZm3nLjpu05vsq','C2L6zq','BNDWEwe','C2HPzNq','nty3mduZm25tv2DMsW'];_0x120d=function(){return _0xf3e92;};return _0x120d();}const _0x202d9b={};_0x202d9b['value']=!![],Object[_0x40ebf2(0xf0)](exports,_0x40ebf2(0xeb),_0x202d9b),exports['createMemoCache']=createMemoCache,exports[_0x40ebf2(0xf8)]=getMemoCache,exports['resetMemoCache']=resetMemoCache;function createMemoCache(_0x213d54=0x1f4){const _0x4f8671={_0x3b3895:0xda,_0x54e31a:0xdb},_0x7645e7={_0x2db74b:0xe2},_0x5588d6={_0x3d7c9e:0xe1},_0x3ae52a={_0x585178:0xdd},_0x166a59={_0x3aa8a4:0xe8,_0x4a661a:0xe7,_0x2670df:0xe9},_0x55d350={_0x5cb5a1:0xe7,_0x5e1e8d:0xec,_0x18dfca:0xe2,_0x53e1eb:0xef,_0x5c8af3:0xec},_0x52fec8={_0x270273:0xf4,_0x19dc24:0xdf},_0x495930={'aigaU':function(_0x268ea1,_0x68cd39){return _0x268ea1===_0x68cd39;},'dremb':function(_0x56beb2,_0x5de39f){return _0x56beb2===_0x5de39f;},'DwwiW':function(_0x348601,_0x1c4358){return _0x348601!==_0x1c4358;},'nwpya':function(_0x5d3b9a,_0x329c0a){return _0x5d3b9a>_0x329c0a;},'uEgVg':function(_0x15730a,_0x52bb02){return _0x15730a(_0x52bb02);},'wukuE':function(_0x1ad783,_0x10310b,_0x56819a){return _0x1ad783(_0x10310b,_0x56819a);}},_0x119030=new Map(),_0x5127d6=[],_0xd0a073=new Map();let _0x308720=0x0,_0x55cf59=0x0;function _0xc384d8(_0x389470){const _0x49423b=_0x1223,_0x313cac=_0x5127d6[_0x49423b(_0x52fec8._0x270273)](_0x389470);_0x313cac!==-0x1&&_0x5127d6['splice'](_0x313cac,0x1),_0x5127d6[_0x49423b(_0x52fec8._0x19dc24)](_0x389470);}function _0x5e0a4a(_0x3839be){const _0x2a4dd8=_0x1223,_0x566b84=_0x119030[_0x2a4dd8(0xe2)](_0x3839be);if(!_0x566b84)return;for(const _0x3de717 of _0x566b84['impactSet']){const _0x289d90=_0xd0a073['get'](_0x3de717);_0x289d90&&(_0x289d90[_0x2a4dd8(0xec)](_0x3839be),_0x495930[_0x2a4dd8(0xf1)](_0x289d90[_0x2a4dd8(_0x55d350._0x5cb5a1)],0x0)&&_0xd0a073[_0x2a4dd8(_0x55d350._0x5e1e8d)](_0x3de717));}const _0x54e3dd=_0xd0a073[_0x2a4dd8(_0x55d350._0x18dfca)](_0x3839be);_0x54e3dd&&(_0x54e3dd['delete'](_0x3839be),_0x495930[_0x2a4dd8(_0x55d350._0x53e1eb)](_0x54e3dd['size'],0x0)&&_0xd0a073[_0x2a4dd8(_0x55d350._0x5c8af3)](_0x3839be));_0x119030['delete'](_0x3839be);const _0x1d2556=_0x5127d6['indexOf'](_0x3839be);_0x495930['DwwiW'](_0x1d2556,-0x1)&&_0x5127d6['splice'](_0x1d2556,0x1);}function _0x1498f4(){const _0xe5df9d=_0x1223;while(_0x495930[_0xe5df9d(_0x166a59._0x3aa8a4)](_0x119030[_0xe5df9d(_0x166a59._0x4a661a)],_0x213d54)&&_0x5127d6['length']>0x0){const _0xd07acb=_0x5127d6[_0xe5df9d(_0x166a59._0x2670df)]();_0x5e0a4a(_0xd07acb);}}function _0x250c5a(_0x1a82f3,_0x29b141){const _0x733967=_0x1223;let _0x1aaf2e=_0xd0a073['get'](_0x1a82f3);!_0x1aaf2e&&(_0x1aaf2e=new Set(),_0xd0a073[_0x733967(_0x3ae52a._0x585178)](_0x1a82f3,_0x1aaf2e)),_0x1aaf2e['add'](_0x29b141);}return{'get'(_0xdbd540){const _0x18a3eb=_0x119030['get'](_0xdbd540);if(_0x18a3eb)return _0x308720++,_0xc384d8(_0xdbd540),_0x18a3eb;return _0x55cf59++,undefined;},'set'(_0x4ff335,_0x35a1b0){const _0xdb2b28=_0x1223;_0x119030[_0xdb2b28(_0x5588d6._0x3d7c9e)](_0x4ff335)&&_0x495930[_0xdb2b28(0xf6)](_0x5e0a4a,_0x4ff335);_0x119030[_0xdb2b28(0xdd)](_0x4ff335,_0x35a1b0),_0xc384d8(_0x4ff335);for(const _0x492f5d of _0x35a1b0[_0xdb2b28(0xde)]){_0x495930['wukuE'](_0x250c5a,_0x492f5d,_0x4ff335);}_0x250c5a(_0x4ff335,_0x4ff335),_0x1498f4();},'invalidate'(_0x27fa1b){const _0x4fa894=_0x1223,_0x1bab80=new Set();for(const _0x1b0553 of _0x27fa1b){const _0x5438d7=_0xd0a073[_0x4fa894(_0x7645e7._0x2db74b)](_0x1b0553);if(_0x5438d7)for(const _0xf4b407 of _0x5438d7){_0x1bab80['add'](_0xf4b407);}}for(const _0x12e75e of _0x1bab80){_0x495930['uEgVg'](_0x5e0a4a,_0x12e75e);}return _0x1bab80[_0x4fa894(0xe7)];},'invalidateAll'(){const _0x1cf59a=_0x1223;_0x119030[_0x1cf59a(_0x4f8671._0x3b3895)](),_0x5127d6[_0x1cf59a(_0x4f8671._0x54e31a)]=0x0,_0xd0a073['clear']();},'stats'(){const _0xb7da25={};return _0xb7da25['size']=_0x119030['size'],_0xb7da25['hits']=_0x308720,_0xb7da25['misses']=_0x55cf59,_0xb7da25;}};}let globalMemoCache=null;function getMemoCache(){return!globalMemoCache&&(globalMemoCache=createMemoCache()),globalMemoCache;}function resetMemoCache(){const _0x2fae9f={_0x297302:0xdc},_0x41302a=_0x40ebf2;globalMemoCache&&globalMemoCache[_0x41302a(_0x2fae9f._0x297302)]();}
|
package/dist/graph/scc.js
CHANGED
|
@@ -1,206 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Strongly Connected Components (SCC) via Tarjan's algorithm,
|
|
4
|
-
* graph condensation into a DAG, and topological sort via Kahn's algorithm.
|
|
5
|
-
*
|
|
6
|
-
* Used to detect circular dependencies and provide accurate cascade-level
|
|
7
|
-
* impact analysis on the condensed (acyclic) dependency graph.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.computeSCC = computeSCC;
|
|
11
|
-
exports.condenseGraph = condenseGraph;
|
|
12
|
-
exports.topologicalSort = topologicalSort;
|
|
13
|
-
// ── Tarjan's SCC Algorithm ──
|
|
14
|
-
/**
|
|
15
|
-
* Compute all Strongly Connected Components of the dependency graph
|
|
16
|
-
* using Tarjan's algorithm. Returns SCCs, a file-to-SCC mapping,
|
|
17
|
-
* and the condensed DAG with topological ordering.
|
|
18
|
-
*/
|
|
19
|
-
function computeSCC(graph) {
|
|
20
|
-
// Handle empty graph
|
|
21
|
-
if (graph.files.size === 0) {
|
|
22
|
-
const emptyDAG = {
|
|
23
|
-
nodes: [],
|
|
24
|
-
forward: new Map(),
|
|
25
|
-
reverse: new Map(),
|
|
26
|
-
topologicalOrder: [],
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
components: [],
|
|
30
|
-
nodeToComponent: new Map(),
|
|
31
|
-
condensed: emptyDAG,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const components = [];
|
|
35
|
-
// Tarjan state
|
|
36
|
-
let indexCounter = 0;
|
|
37
|
-
const nodeIndex = new Map();
|
|
38
|
-
const nodeLowlink = new Map();
|
|
39
|
-
const onStack = new Set();
|
|
40
|
-
const stack = [];
|
|
41
|
-
function strongConnect(node) {
|
|
42
|
-
nodeIndex.set(node, indexCounter);
|
|
43
|
-
nodeLowlink.set(node, indexCounter);
|
|
44
|
-
indexCounter++;
|
|
45
|
-
stack.push(node);
|
|
46
|
-
onStack.add(node);
|
|
47
|
-
const successors = graph.forward.get(node) || [];
|
|
48
|
-
for (const successor of successors) {
|
|
49
|
-
// Only process nodes that exist in the graph
|
|
50
|
-
if (!graph.files.has(successor))
|
|
51
|
-
continue;
|
|
52
|
-
if (!nodeIndex.has(successor)) {
|
|
53
|
-
// Successor not yet visited — recurse
|
|
54
|
-
strongConnect(successor);
|
|
55
|
-
nodeLowlink.set(node, Math.min(nodeLowlink.get(node), nodeLowlink.get(successor)));
|
|
56
|
-
}
|
|
57
|
-
else if (onStack.has(successor)) {
|
|
58
|
-
// Successor is on the stack — part of current SCC
|
|
59
|
-
nodeLowlink.set(node, Math.min(nodeLowlink.get(node), nodeIndex.get(successor)));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// If node is a root of an SCC, pop the stack to form a component
|
|
63
|
-
if (nodeLowlink.get(node) === nodeIndex.get(node)) {
|
|
64
|
-
const component = [];
|
|
65
|
-
let w;
|
|
66
|
-
do {
|
|
67
|
-
w = stack.pop();
|
|
68
|
-
onStack.delete(w);
|
|
69
|
-
component.push(w);
|
|
70
|
-
} while (w !== node);
|
|
71
|
-
components.push(component);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Visit all nodes (handles disconnected components)
|
|
75
|
-
for (const file of graph.files) {
|
|
76
|
-
if (!nodeIndex.has(file)) {
|
|
77
|
-
strongConnect(file);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Build file-to-component mapping
|
|
81
|
-
const nodeToComponent = new Map();
|
|
82
|
-
for (let i = 0; i < components.length; i++) {
|
|
83
|
-
for (const file of components[i]) {
|
|
84
|
-
nodeToComponent.set(file, i);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// Build the condensed DAG
|
|
88
|
-
const condensed = condenseGraph(graph, components, nodeToComponent);
|
|
89
|
-
return { components, nodeToComponent, condensed };
|
|
90
|
-
}
|
|
91
|
-
// ── Graph Condensation ──
|
|
92
|
-
/**
|
|
93
|
-
* Build a DAG where each node represents one SCC.
|
|
94
|
-
* Edges between SCCs are derived from the original graph's edges
|
|
95
|
-
* between files belonging to different SCCs.
|
|
96
|
-
*/
|
|
97
|
-
function condenseGraph(graph, components, nodeToComponent) {
|
|
98
|
-
const numComponents = components.length;
|
|
99
|
-
// Build condensed nodes
|
|
100
|
-
const nodes = components.map((files, index) => ({
|
|
101
|
-
index,
|
|
102
|
-
files,
|
|
103
|
-
size: files.length,
|
|
104
|
-
isCyclic: files.length > 1,
|
|
105
|
-
}));
|
|
106
|
-
// Build forward and reverse edges between SCCs (deduplicated)
|
|
107
|
-
const forwardSets = new Map();
|
|
108
|
-
const reverseSets = new Map();
|
|
109
|
-
for (let i = 0; i < numComponents; i++) {
|
|
110
|
-
forwardSets.set(i, new Set());
|
|
111
|
-
reverseSets.set(i, new Set());
|
|
112
|
-
}
|
|
113
|
-
for (const [file, deps] of graph.forward) {
|
|
114
|
-
const srcSCC = nodeToComponent.get(file);
|
|
115
|
-
if (srcSCC === undefined)
|
|
116
|
-
continue;
|
|
117
|
-
for (const dep of deps) {
|
|
118
|
-
const dstSCC = nodeToComponent.get(dep);
|
|
119
|
-
if (dstSCC === undefined)
|
|
120
|
-
continue;
|
|
121
|
-
// Skip self-edges (within the same SCC)
|
|
122
|
-
if (srcSCC === dstSCC)
|
|
123
|
-
continue;
|
|
124
|
-
forwardSets.get(srcSCC).add(dstSCC);
|
|
125
|
-
reverseSets.get(dstSCC).add(srcSCC);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// Convert sets to arrays
|
|
129
|
-
const forward = new Map();
|
|
130
|
-
const reverse = new Map();
|
|
131
|
-
for (const [key, set] of forwardSets) {
|
|
132
|
-
forward.set(key, [...set]);
|
|
133
|
-
}
|
|
134
|
-
for (const [key, set] of reverseSets) {
|
|
135
|
-
reverse.set(key, [...set]);
|
|
136
|
-
}
|
|
137
|
-
const dag = {
|
|
138
|
-
nodes,
|
|
139
|
-
forward,
|
|
140
|
-
reverse,
|
|
141
|
-
topologicalOrder: [],
|
|
142
|
-
};
|
|
143
|
-
// Compute topological order
|
|
144
|
-
dag.topologicalOrder = topologicalSort(dag);
|
|
145
|
-
return dag;
|
|
146
|
-
}
|
|
147
|
-
// ── Topological Sort (Kahn's Algorithm) ──
|
|
148
|
-
/**
|
|
149
|
-
* Compute a topological ordering of the condensed DAG using Kahn's algorithm.
|
|
150
|
-
* The condensed graph is guaranteed to be acyclic after SCC condensation.
|
|
151
|
-
*
|
|
152
|
-
* Returns SCC indices in dependency order: dependencies come before dependents.
|
|
153
|
-
* This uses the `forward` edges (file A imports B means A -> B in forward),
|
|
154
|
-
* so we process nodes with no incoming forward edges first (leaf dependencies).
|
|
155
|
-
*/
|
|
156
|
-
function topologicalSort(dag) {
|
|
157
|
-
const numNodes = dag.nodes.length;
|
|
158
|
-
if (numNodes === 0)
|
|
159
|
-
return [];
|
|
160
|
-
// In-degree = number of dependencies (forward edges out of each node).
|
|
161
|
-
// forward[A] = [B] means A imports B, so A depends on B.
|
|
162
|
-
// For "dependencies first" ordering, nodes with zero dependencies come first.
|
|
163
|
-
const inDegree = new Map();
|
|
164
|
-
for (let i = 0; i < numNodes; i++) {
|
|
165
|
-
inDegree.set(i, 0);
|
|
166
|
-
}
|
|
167
|
-
for (const [src, dsts] of dag.forward) {
|
|
168
|
-
inDegree.set(src, (inDegree.get(src) || 0) + dsts.length);
|
|
169
|
-
}
|
|
170
|
-
// Start with nodes that have no dependencies (in-degree 0 in forward)
|
|
171
|
-
const queue = [];
|
|
172
|
-
for (const [node, degree] of inDegree) {
|
|
173
|
-
if (degree === 0) {
|
|
174
|
-
queue.push(node);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const order = [];
|
|
178
|
-
while (queue.length > 0) {
|
|
179
|
-
const current = queue.shift();
|
|
180
|
-
order.push(current);
|
|
181
|
-
// current has no remaining dependencies.
|
|
182
|
-
// For all nodes that depend on current (reverse edges: who imports current),
|
|
183
|
-
// decrement their in-degree.
|
|
184
|
-
const dependents = dag.reverse.get(current) || [];
|
|
185
|
-
for (const dependent of dependents) {
|
|
186
|
-
const newDegree = (inDegree.get(dependent) || 0) - 1;
|
|
187
|
-
inDegree.set(dependent, newDegree);
|
|
188
|
-
if (newDegree === 0) {
|
|
189
|
-
queue.push(dependent);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// If order doesn't contain all nodes, there's a bug (shouldn't happen after SCC condensation)
|
|
194
|
-
if (order.length !== numNodes) {
|
|
195
|
-
console.error(`[syke:scc] WARNING: Topological sort produced ${order.length}/${numNodes} nodes. ` +
|
|
196
|
-
`This indicates a bug in SCC condensation.`);
|
|
197
|
-
// Add remaining nodes at the end
|
|
198
|
-
const ordered = new Set(order);
|
|
199
|
-
for (let i = 0; i < numNodes; i++) {
|
|
200
|
-
if (!ordered.has(i)) {
|
|
201
|
-
order.push(i);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return order;
|
|
206
|
-
}
|
|
1
|
+
'use strict';const _0x2b80e1=_0x492e;function _0x63c1(){const _0x2ebd45=['mtaZmZmXmtbbEMjpzNm','AgfZ','ywrK','mtC2EwzbtxnZ','uKPAqM4','mJm0nty3uwr6Evv4','C2fqrvC','zgvMAw5LuhjVCgvYDhK','ChvZAa','nZe4odm1wLzIBg9A','mtjku0TLzeq','rK5oqwW','BwLU','BgvUz3rO','C2HPzNq','BwfW','mJqWmtHfEwfNtKW','ig5VzgvZlIa','nJC2ntGXnKPxB3fiEa','zxjYB3i','Dg9WB2XVz2LJywXtB3j0','Dg9WB2XVz2LJywXpCMrLCG','y29TChv0zvndqW','Bu16suC','zvrjDhi','mteYntmXm0XUuM9lAa','mtm0Cvrxv2LT','C2v0','y29TCg9Uzw50CW','z2v0','zgvSzxrL','zM9YD2fYza','BM9KzvrVq29TCg9Uzw50','vwTTAeC','CMv2zxjZzq','ody3mZL5CLvODuq','vg5ezLK','Au9js04','C2L6zq'];_0x63c1=function(){return _0x2ebd45;};return _0x63c1();}function _0x492e(_0x14db61,_0x4c8533){_0x14db61=_0x14db61-0x1c0;const _0x63c150=_0x63c1();let _0x492e5b=_0x63c150[_0x14db61];if(_0x492e['YQrQuT']===undefined){var _0x56bf57=function(_0x524d98){const _0x272341='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x321491='',_0x5e0416='';for(let _0x406489=0x0,_0x252914,_0x493ca3,_0x1f766b=0x0;_0x493ca3=_0x524d98['charAt'](_0x1f766b++);~_0x493ca3&&(_0x252914=_0x406489%0x4?_0x252914*0x40+_0x493ca3:_0x493ca3,_0x406489++%0x4)?_0x321491+=String['fromCharCode'](0xff&_0x252914>>(-0x2*_0x406489&0x6)):0x0){_0x493ca3=_0x272341['indexOf'](_0x493ca3);}for(let _0x4f800b=0x0,_0x6a76a6=_0x321491['length'];_0x4f800b<_0x6a76a6;_0x4f800b++){_0x5e0416+='%'+('00'+_0x321491['charCodeAt'](_0x4f800b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5e0416);};_0x492e['rORoVB']=_0x56bf57,_0x492e['dnVGFE']={},_0x492e['YQrQuT']=!![];}const _0x2f5dc4=_0x63c150[0x0],_0x5cea52=_0x14db61+_0x2f5dc4,_0x49f343=_0x492e['dnVGFE'][_0x5cea52];return!_0x49f343?(_0x492e5b=_0x492e['rORoVB'](_0x492e5b),_0x492e['dnVGFE'][_0x5cea52]=_0x492e5b):_0x492e5b=_0x49f343,_0x492e5b;}(function(_0x458568,_0x421356){const _0x2990fc={_0x3aa0f1:0x1db,_0x181149:0x1c4,_0x34dcec:0x1d5,_0x5284a4:0x1d2},_0x50f885=_0x492e,_0x599137=_0x458568();while(!![]){try{const _0x4bb39e=parseInt(_0x50f885(0x1ce))/0x1+-parseInt(_0x50f885(0x1c5))/0x2*(parseInt(_0x50f885(0x1e2))/0x3)+parseInt(_0x50f885(0x1dc))/0x4*(parseInt(_0x50f885(_0x2990fc._0x3aa0f1))/0x5)+parseInt(_0x50f885(0x1e4))/0x6+parseInt(_0x50f885(_0x2990fc._0x181149))/0x7+-parseInt(_0x50f885(_0x2990fc._0x34dcec))/0x8*(-parseInt(_0x50f885(0x1d7))/0x9)+-parseInt(_0x50f885(_0x2990fc._0x5284a4))/0xa;if(_0x4bb39e===_0x421356)break;else _0x599137['push'](_0x599137['shift']());}catch(_0x36fb7d){_0x599137['push'](_0x599137['shift']());}}}(_0x63c1,0xc5c7c));const _0xda3dbf={};_0xda3dbf['value']=!![],Object[_0x2b80e1(0x1d9)](exports,'__esModule',_0xda3dbf),exports[_0x2b80e1(0x1c1)]=computeSCC,exports['condenseGraph']=condenseGraph,exports[_0x2b80e1(0x1e6)]=topologicalSort;function computeSCC(_0x4a8aa6){const _0x1a55e7={_0x266fb3:0x1d1,_0xd6a5f:0x1c7},_0x3bbd19={_0x53408f:0x1d3,_0x453904:0x1de,_0x2bf556:0x1c8,_0x3d4d06:0x1c9},_0x301188=_0x2b80e1,_0x176386={'dFWne':function(_0x352889,_0xa0e3b8){return _0x352889(_0xa0e3b8);},'iOIKN':function(_0x1f2848,_0x14d4f1){return _0x1f2848===_0x14d4f1;},'TnDfY':function(_0x4d6cc4,_0x920db){return _0x4d6cc4<_0x920db;},'zQhJC':function(_0x392926,_0x494d91,_0x3856d8,_0x30829e){return _0x392926(_0x494d91,_0x3856d8,_0x30829e);}};if(_0x4a8aa6['files'][_0x301188(_0x1a55e7._0x266fb3)]===0x0){const _0x3787e0={'nodes':[],'forward':new Map(),'reverse':new Map(),'topologicalOrder':[]};return{'components':[],'nodeToComponent':new Map(),'condensed':_0x3787e0};}const _0x38968e=[];let _0x938252=0x0;const _0x3c3f55=new Map(),_0x167151=new Map(),_0x645424=new Set(),_0x22e11c=[];function _0x5510fb(_0x308bcf){const _0x45f6a7=_0x301188;_0x3c3f55[_0x45f6a7(0x1c6)](_0x308bcf,_0x938252),_0x167151['set'](_0x308bcf,_0x938252),_0x938252++,_0x22e11c[_0x45f6a7(0x1da)](_0x308bcf),_0x645424[_0x45f6a7(0x1d4)](_0x308bcf);const _0x40176b=_0x4a8aa6['forward']['get'](_0x308bcf)||[];for(const _0xf42402 of _0x40176b){if(!_0x4a8aa6['files'][_0x45f6a7(_0x3bbd19._0x53408f)](_0xf42402))continue;if(!_0x3c3f55['has'](_0xf42402))_0x176386['dFWne'](_0x5510fb,_0xf42402),_0x167151['set'](_0x308bcf,Math[_0x45f6a7(_0x3bbd19._0x453904)](_0x167151[_0x45f6a7(_0x3bbd19._0x2bf556)](_0x308bcf),_0x167151[_0x45f6a7(_0x3bbd19._0x2bf556)](_0xf42402)));else _0x645424['has'](_0xf42402)&&_0x167151['set'](_0x308bcf,Math['min'](_0x167151[_0x45f6a7(0x1c8)](_0x308bcf),_0x3c3f55['get'](_0xf42402)));}if(_0x176386[_0x45f6a7(0x1d0)](_0x167151['get'](_0x308bcf),_0x3c3f55[_0x45f6a7(0x1c8)](_0x308bcf))){const _0x3a72b5=[];let _0x5758fb;do{_0x5758fb=_0x22e11c['pop'](),_0x645424[_0x45f6a7(_0x3bbd19._0x3d4d06)](_0x5758fb),_0x3a72b5['push'](_0x5758fb);}while(_0x5758fb!==_0x308bcf);_0x38968e['push'](_0x3a72b5);}}for(const _0x380237 of _0x4a8aa6['files']){!_0x3c3f55[_0x301188(0x1d3)](_0x380237)&&_0x5510fb(_0x380237);}const _0x12c14c=new Map();for(let _0x5e4ba6=0x0;_0x176386[_0x301188(0x1cf)](_0x5e4ba6,_0x38968e['length']);_0x5e4ba6++){for(const _0x4e4d6a of _0x38968e[_0x5e4ba6]){_0x12c14c[_0x301188(0x1c6)](_0x4e4d6a,_0x5e4ba6);}}const _0x3d0078=_0x176386['zQhJC'](condenseGraph,_0x4a8aa6,_0x38968e,_0x12c14c),_0x109451={};return _0x109451[_0x301188(_0x1a55e7._0xd6a5f)]=_0x38968e,_0x109451[_0x301188(0x1cb)]=_0x12c14c,_0x109451['condensed']=_0x3d0078,_0x109451;}function condenseGraph(_0x7af3a9,_0x3a3453,_0x37a7e3){const _0xae34fa={_0x33ae11:0x1df,_0x26734d:0x1e1,_0x3146a3:0x1d8,_0x4abfe9:0x1c8,_0x526970:0x1d4,_0x1ec668:0x1cd,_0x35415b:0x1c0},_0x1d0991=_0x2b80e1,_0x4c9102={'hTwMA':function(_0x2e8aaf,_0x339045){return _0x2e8aaf<_0x339045;},'vctrR':function(_0xf316e5,_0x17f806){return _0xf316e5===_0x17f806;},'saPEW':function(_0x45a3d2,_0x184199){return _0x45a3d2===_0x184199;},'Mayrh':function(_0x13927b,_0x30f317){return _0x13927b(_0x30f317);}},_0x13d510=_0x3a3453[_0x1d0991(_0xae34fa._0x33ae11)],_0xb69f13=_0x3a3453[_0x1d0991(_0xae34fa._0x26734d)]((_0x42670c,_0x4af98f)=>({'index':_0x4af98f,'files':_0x42670c,'size':_0x42670c['length'],'isCyclic':_0x42670c['length']>0x1})),_0x6bee21=new Map(),_0x34b0f7=new Map();for(let _0x46fdcf=0x0;_0x4c9102['hTwMA'](_0x46fdcf,_0x13d510);_0x46fdcf++){_0x6bee21['set'](_0x46fdcf,new Set()),_0x34b0f7['set'](_0x46fdcf,new Set());}for(const [_0x7cd7f9,_0x504ab9]of _0x7af3a9['forward']){const _0x10198c=_0x37a7e3['get'](_0x7cd7f9);if(_0x4c9102['vctrR'](_0x10198c,undefined))continue;for(const _0x3aa17d of _0x504ab9){const _0x469bd=_0x37a7e3['get'](_0x3aa17d);if(_0x4c9102['vctrR'](_0x469bd,undefined))continue;if(_0x4c9102[_0x1d0991(_0xae34fa._0x3146a3)](_0x10198c,_0x469bd))continue;_0x6bee21['get'](_0x10198c)['add'](_0x469bd),_0x34b0f7[_0x1d0991(_0xae34fa._0x4abfe9)](_0x469bd)[_0x1d0991(_0xae34fa._0x526970)](_0x10198c);}}const _0x4e4533=new Map(),_0x489fe7=new Map();for(const [_0x38dbe9,_0x417cec]of _0x6bee21){_0x4e4533[_0x1d0991(0x1c6)](_0x38dbe9,[..._0x417cec]);}for(const [_0x28b080,_0x434fdc]of _0x34b0f7){_0x489fe7['set'](_0x28b080,[..._0x434fdc]);}const _0x3c9b89={};_0x3c9b89['nodes']=_0xb69f13,_0x3c9b89[_0x1d0991(0x1ca)]=_0x4e4533,_0x3c9b89[_0x1d0991(_0xae34fa._0x1ec668)]=_0x489fe7,_0x3c9b89[_0x1d0991(_0xae34fa._0x35415b)]=[];const _0x16bcdb=_0x3c9b89;return _0x16bcdb['topologicalOrder']=_0x4c9102['Mayrh'](topologicalSort,_0x16bcdb),_0x16bcdb;}function topologicalSort(_0x260073){const _0x5f0de6={_0x49ee13:0x1d6,_0x29044a:0x1dd,_0x52608b:0x1df,_0x22130b:0x1c3,_0x5eb778:0x1c6,_0x4533ef:0x1c8,_0x21ec92:0x1d3,_0x6db218:0x1da},_0x321a89=_0x2b80e1,_0x10e3b1={};_0x10e3b1[_0x321a89(0x1c2)]=function(_0x24858a,_0x47e690){return _0x24858a===_0x47e690;},_0x10e3b1[_0x321a89(0x1c3)]=function(_0x46aa31,_0x24683c){return _0x46aa31<_0x24683c;},_0x10e3b1['GDMLy']=function(_0x5be82e,_0x19eda2){return _0x5be82e===_0x19eda2;},_0x10e3b1['UkmhG']=function(_0x23ceb0,_0x32e420){return _0x23ceb0-_0x32e420;},_0x10e3b1[_0x321a89(_0x5f0de6._0x49ee13)]=function(_0x40f956,_0x481616){return _0x40f956===_0x481616;},_0x10e3b1[_0x321a89(_0x5f0de6._0x29044a)]=function(_0x378f3,_0x2e1c7b){return _0x378f3!==_0x2e1c7b;};const _0x1bd2d2=_0x10e3b1,_0x433434=_0x260073['nodes'][_0x321a89(_0x5f0de6._0x52608b)];if(_0x1bd2d2['mMzIG'](_0x433434,0x0))return[];const _0x2deda8=new Map();for(let _0x2919ea=0x0;_0x1bd2d2[_0x321a89(_0x5f0de6._0x22130b)](_0x2919ea,_0x433434);_0x2919ea++){_0x2deda8['set'](_0x2919ea,0x0);}for(const [_0x574bcd,_0x174966]of _0x260073[_0x321a89(0x1ca)]){_0x2deda8[_0x321a89(_0x5f0de6._0x5eb778)](_0x574bcd,(_0x2deda8[_0x321a89(_0x5f0de6._0x4533ef)](_0x574bcd)||0x0)+_0x174966[_0x321a89(0x1df)]);}const _0x1625b8=[];for(const [_0x1294b8,_0x24093a]of _0x2deda8){_0x1bd2d2['GDMLy'](_0x24093a,0x0)&&_0x1625b8[_0x321a89(0x1da)](_0x1294b8);}const _0x213743=[];while(_0x1625b8[_0x321a89(0x1df)]>0x0){const _0x2f5a9c=_0x1625b8[_0x321a89(0x1e0)]();_0x213743['push'](_0x2f5a9c);const _0x5beb24=_0x260073[_0x321a89(0x1cd)]['get'](_0x2f5a9c)||[];for(const _0x57b520 of _0x5beb24){const _0x3a473b=_0x1bd2d2[_0x321a89(0x1cc)](_0x2deda8[_0x321a89(0x1c8)](_0x57b520)||0x0,0x1);_0x2deda8[_0x321a89(0x1c6)](_0x57b520,_0x3a473b),_0x1bd2d2['RJZBn'](_0x3a473b,0x0)&&_0x1625b8['push'](_0x57b520);}}if(_0x1bd2d2['FNNAl'](_0x213743['length'],_0x433434)){console[_0x321a89(0x1e5)]('[syke:scc]\x20WARNING:\x20Topological\x20sort\x20produced\x20'+_0x213743['length']+'/'+_0x433434+_0x321a89(0x1e3)+'This\x20indicates\x20a\x20bug\x20in\x20SCC\x20condensation.');const _0x48f58c=new Set(_0x213743);for(let _0x529af0=0x0;_0x1bd2d2['eTItr'](_0x529af0,_0x433434);_0x529af0++){!_0x48f58c[_0x321a89(_0x5f0de6._0x21ec92)](_0x529af0)&&_0x213743[_0x321a89(_0x5f0de6._0x6db218)](_0x529af0);}}return _0x213743;}
|
package/dist/graph.js
CHANGED
|
@@ -1,137 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.buildGraph = buildGraph;
|
|
37
|
-
exports.getGraph = getGraph;
|
|
38
|
-
exports.rebuildGraph = rebuildGraph;
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
const plugin_1 = require("./languages/plugin");
|
|
41
|
-
const typescript_1 = require("./languages/typescript");
|
|
42
|
-
const scc_1 = require("./graph/scc");
|
|
43
|
-
const risk_scorer_1 = require("./scoring/risk-scorer");
|
|
44
|
-
const pagerank_1 = require("./scoring/pagerank");
|
|
45
|
-
const memo_cache_1 = require("./graph/memo-cache");
|
|
46
|
-
let cachedGraph = null;
|
|
47
|
-
function buildGraph(projectRoot, packageName, maxFiles) {
|
|
48
|
-
const detectedPlugins = (0, plugin_1.detectLanguages)(projectRoot);
|
|
49
|
-
const languages = detectedPlugins.map(p => p.id);
|
|
50
|
-
const forward = new Map();
|
|
51
|
-
const reverse = new Map();
|
|
52
|
-
const files = new Set();
|
|
53
|
-
const allSourceDirs = [];
|
|
54
|
-
let totalDiscovered = 0;
|
|
55
|
-
let fileLimitHit = false;
|
|
56
|
-
for (const plugin of detectedPlugins) {
|
|
57
|
-
const dirs = plugin.getSourceDirs(projectRoot);
|
|
58
|
-
console.error(`[syke:debug] ${plugin.id} getSourceDirs(${projectRoot}) => ${dirs.length} dirs: ${dirs.join(", ")}`);
|
|
59
|
-
for (const dir of dirs) {
|
|
60
|
-
if (!allSourceDirs.includes(dir))
|
|
61
|
-
allSourceDirs.push(dir);
|
|
62
|
-
const sourceFiles = plugin.discoverFiles(dir);
|
|
63
|
-
console.error(`[syke:debug] ${plugin.id} discoverFiles(${dir}) => ${sourceFiles.length} files`);
|
|
64
|
-
totalDiscovered += sourceFiles.length;
|
|
65
|
-
for (const f of sourceFiles) {
|
|
66
|
-
if (maxFiles && files.size >= maxFiles) {
|
|
67
|
-
fileLimitHit = true;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
files.add(f);
|
|
71
|
-
if (!forward.has(f))
|
|
72
|
-
forward.set(f, []);
|
|
73
|
-
}
|
|
74
|
-
for (const f of sourceFiles) {
|
|
75
|
-
if (!files.has(f))
|
|
76
|
-
continue;
|
|
77
|
-
const imports = plugin.parseImports(f, projectRoot, dir);
|
|
78
|
-
const validImports = [];
|
|
79
|
-
for (const imp of imports) {
|
|
80
|
-
if (!files.has(imp))
|
|
81
|
-
continue;
|
|
82
|
-
validImports.push(imp);
|
|
83
|
-
const rev = reverse.get(imp) || [];
|
|
84
|
-
rev.push(f);
|
|
85
|
-
reverse.set(imp, rev);
|
|
86
|
-
}
|
|
87
|
-
forward.set(f, validImports);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (fileLimitHit) {
|
|
92
|
-
console.error(`[syke] Free tier: loaded ${files.size}/${totalDiscovered} files (limit: ${maxFiles}). Upgrade to Pro for unlimited.`);
|
|
93
|
-
}
|
|
94
|
-
const sourceDir = allSourceDirs[0] || path.join(projectRoot, "src");
|
|
95
|
-
const graph = {
|
|
96
|
-
forward,
|
|
97
|
-
reverse,
|
|
98
|
-
files,
|
|
99
|
-
projectRoot,
|
|
100
|
-
languages,
|
|
101
|
-
sourceDirs: allSourceDirs,
|
|
102
|
-
sourceDir,
|
|
103
|
-
};
|
|
104
|
-
// Invalidate memo cache (full rebuild means all cached BFS results are stale)
|
|
105
|
-
(0, memo_cache_1.resetMemoCache)();
|
|
106
|
-
// Compute SCC and attach to graph
|
|
107
|
-
const scc = (0, scc_1.computeSCC)(graph);
|
|
108
|
-
graph.scc = scc;
|
|
109
|
-
// Compute PageRank importance scores
|
|
110
|
-
(0, pagerank_1.invalidatePageRank)();
|
|
111
|
-
graph.pageRank = (0, pagerank_1.computePageRank)(graph);
|
|
112
|
-
const cyclicCount = scc.condensed.nodes.filter(n => n.isCyclic).length;
|
|
113
|
-
cachedGraph = graph;
|
|
114
|
-
console.error(`[syke] Graph built (${languages.join("+")}): ${files.size} files, ${countEdges(forward)} edges, ${scc.components.length} SCCs (${cyclicCount} cyclic)`);
|
|
115
|
-
return graph;
|
|
116
|
-
}
|
|
117
|
-
function countEdges(forward) {
|
|
118
|
-
let count = 0;
|
|
119
|
-
for (const deps of forward.values()) {
|
|
120
|
-
count += deps.length;
|
|
121
|
-
}
|
|
122
|
-
return count;
|
|
123
|
-
}
|
|
124
|
-
function getGraph(projectRoot, packageName, maxFiles) {
|
|
125
|
-
if (cachedGraph && cachedGraph.projectRoot === projectRoot) {
|
|
126
|
-
return cachedGraph;
|
|
127
|
-
}
|
|
128
|
-
return buildGraph(projectRoot, packageName, maxFiles);
|
|
129
|
-
}
|
|
130
|
-
function rebuildGraph(projectRoot, packageName, maxFiles) {
|
|
131
|
-
cachedGraph = null;
|
|
132
|
-
(0, typescript_1.clearAliasCache)();
|
|
133
|
-
(0, risk_scorer_1.invalidateProjectMetrics)();
|
|
134
|
-
(0, pagerank_1.invalidatePageRank)();
|
|
135
|
-
(0, memo_cache_1.resetMemoCache)();
|
|
136
|
-
return buildGraph(projectRoot, packageName, maxFiles);
|
|
137
|
-
}
|
|
1
|
+
'use strict';const _0x5c54c1=_0x5bfe;(function(_0x25f668,_0x362444){const _0x3ef357={_0x29471:0x1b8,_0x429269:0x1ba,_0x40b157:0x1a2,_0x6da95a:0x1b5,_0x59595a:0x1bf},_0x29323e=_0x5bfe,_0x13ff04=_0x25f668();while(!![]){try{const _0x5c7abf=parseInt(_0x29323e(0x1cf))/0x1*(parseInt(_0x29323e(_0x3ef357._0x29471))/0x2)+-parseInt(_0x29323e(_0x3ef357._0x429269))/0x3+parseInt(_0x29323e(_0x3ef357._0x40b157))/0x4+parseInt(_0x29323e(0x1ae))/0x5+-parseInt(_0x29323e(_0x3ef357._0x6da95a))/0x6+-parseInt(_0x29323e(0x1a3))/0x7*(-parseInt(_0x29323e(0x1c0))/0x8)+-parseInt(_0x29323e(_0x3ef357._0x59595a))/0x9*(-parseInt(_0x29323e(0x1b2))/0xa);if(_0x5c7abf===_0x362444)break;else _0x13ff04['push'](_0x13ff04['shift']());}catch(_0x36974e){_0x13ff04['push'](_0x13ff04['shift']());}}}(_0x3803,0xe8aa3));function _0x5bfe(_0x2774fa,_0x2f7661){_0x2774fa=_0x2774fa-0x1a2;const _0x380365=_0x3803();let _0x5bfe78=_0x380365[_0x2774fa];if(_0x5bfe['lUsreh']===undefined){var _0x511b41=function(_0x1e694e){const _0x4e3c5b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4d3dcc='',_0xf9e95f='';for(let _0x31a682=0x0,_0x4e95e4,_0x4ea1cb,_0x54a624=0x0;_0x4ea1cb=_0x1e694e['charAt'](_0x54a624++);~_0x4ea1cb&&(_0x4e95e4=_0x31a682%0x4?_0x4e95e4*0x40+_0x4ea1cb:_0x4ea1cb,_0x31a682++%0x4)?_0x4d3dcc+=String['fromCharCode'](0xff&_0x4e95e4>>(-0x2*_0x31a682&0x6)):0x0){_0x4ea1cb=_0x4e3c5b['indexOf'](_0x4ea1cb);}for(let _0x290b1c=0x0,_0x1c33a3=_0x4d3dcc['length'];_0x290b1c<_0x1c33a3;_0x290b1c++){_0xf9e95f+='%'+('00'+_0x4d3dcc['charCodeAt'](_0x290b1c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xf9e95f);};_0x5bfe['PBpyrD']=_0x511b41,_0x5bfe['ieYGnx']={},_0x5bfe['lUsreh']=!![];}const _0x40a6a8=_0x380365[0x0],_0x36fb22=_0x2774fa+_0x40a6a8,_0x47861c=_0x5bfe['ieYGnx'][_0x36fb22];return!_0x47861c?(_0x5bfe78=_0x5bfe['PBpyrD'](_0x5bfe78),_0x5bfe['ieYGnx'][_0x36fb22]=_0x5bfe78):_0x5bfe78=_0x47861c,_0x5bfe78;}var __createBinding=this&&this[_0x5c54c1(0x1b3)]||(Object['create']?function(_0x4fe668,_0x4f5932,_0x51164c,_0xde319a){const _0x8dfb32={_0x360098:0x1c3},_0x50e3f7=_0x5c54c1,_0x285466={};_0x285466[_0x50e3f7(_0x8dfb32._0x360098)]='get';const _0x2dcf85=_0x285466;if(_0xde319a===undefined)_0xde319a=_0x51164c;var _0x320c00=Object['getOwnPropertyDescriptor'](_0x4f5932,_0x51164c);if(!_0x320c00||(_0x2dcf85['kkJpr']in _0x320c00?!_0x4f5932['__esModule']:_0x320c00['writable']||_0x320c00['configurable'])){const _0x4fc7ef={};_0x4fc7ef['enumerable']=!![],_0x4fc7ef['get']=function(){return _0x4f5932[_0x51164c];},_0x320c00=_0x4fc7ef;}Object['defineProperty'](_0x4fe668,_0xde319a,_0x320c00);}:function(_0x8e1989,_0x1850cc,_0x23cfbf,_0x3e9e03){if(_0x3e9e03===undefined)_0x3e9e03=_0x23cfbf;_0x8e1989[_0x3e9e03]=_0x1850cc[_0x23cfbf];}),__setModuleDefault=this&&this[_0x5c54c1(0x1aa)]||(Object['create']?function(_0x1ca784,_0x4414b6){const _0x1be0d8={_0x1f9821:0x1cb},_0x59837d=_0x5c54c1,_0x38b926={};_0x38b926[_0x59837d(0x1c8)]=!![],_0x38b926['value']=_0x4414b6,Object[_0x59837d(0x1b1)](_0x1ca784,_0x59837d(_0x1be0d8._0x1f9821),_0x38b926);}:function(_0x19ab70,_0x2e7f71){const _0x1834d0={_0x30843a:0x1b6},_0x14bceb=_0x5c54c1,_0xf701a9={};_0xf701a9[_0x14bceb(_0x1834d0._0x30843a)]=_0x14bceb(0x1cb);const _0x5c7bee=_0xf701a9;_0x19ab70[_0x5c7bee[_0x14bceb(0x1b6)]]=_0x2e7f71;}),__importStar=this&&this[_0x5c54c1(0x1c5)]||(function(){const _0x53b5c3={_0x4b7c11:0x1bb},_0x1c01f1={_0x10be6d:0x1c6},_0x91ca8d={'ptvzb':function(_0x2283fc,_0x42d24d){return _0x2283fc(_0x42d24d);},'luxMW':function(_0x1be260,_0x336dac){return _0x1be260<_0x336dac;},'jgvYc':function(_0x51625b,_0x2fbfc2){return _0x51625b!==_0x2fbfc2;}};var _0x27c614=function(_0xcdb793){return _0x27c614=Object['getOwnPropertyNames']||function(_0x3bb046){const _0x435f89=_0x5bfe;var _0x40852a=[];for(var _0x19a823 in _0x3bb046)if(Object[_0x435f89(_0x1c01f1._0x10be6d)]['hasOwnProperty'][_0x435f89(0x1be)](_0x3bb046,_0x19a823))_0x40852a[_0x40852a['length']]=_0x19a823;return _0x40852a;},_0x91ca8d['ptvzb'](_0x27c614,_0xcdb793);};return function(_0x5f3fb6){const _0x2ba0e7=_0x5bfe;if(_0x5f3fb6&&_0x5f3fb6['__esModule'])return _0x5f3fb6;var _0x562c4d={};if(_0x5f3fb6!=null){for(var _0x58cc8a=_0x27c614(_0x5f3fb6),_0x3247bf=0x0;_0x91ca8d[_0x2ba0e7(_0x53b5c3._0x4b7c11)](_0x3247bf,_0x58cc8a['length']);_0x3247bf++)if(_0x91ca8d['jgvYc'](_0x58cc8a[_0x3247bf],_0x2ba0e7(0x1cb)))__createBinding(_0x562c4d,_0x5f3fb6,_0x58cc8a[_0x3247bf]);}return __setModuleDefault(_0x562c4d,_0x5f3fb6),_0x562c4d;};}());const _0x3eb87d={};_0x3eb87d['value']=!![],Object[_0x5c54c1(0x1b1)](exports,'__esModule',_0x3eb87d),exports['buildGraph']=buildGraph,exports['getGraph']=getGraph,exports[_0x5c54c1(0x1ce)]=rebuildGraph;const path=__importStar(require('path')),plugin_1=require('./languages/plugin'),typescript_1=require('./languages/typescript'),scc_1=require('./graph/scc'),risk_scorer_1=require('./scoring/risk-scorer'),pagerank_1=require('./scoring/pagerank'),memo_cache_1=require(_0x5c54c1(0x1b0));let cachedGraph=null;function buildGraph(_0xf5a20c,_0x575355,_0x3248f4){const _0x7c7bfe={_0x3e0c00:0x1bd,_0x3c4c4f:0x1a8,_0x275772:0x1c9,_0x3d8164:0x1ab,_0x5bb81e:0x1c1,_0xe3a3c6:0x1b4,_0x283b10:0x1cd,_0x1591f2:0x1ca,_0x255e63:0x1a4,_0x1a5daf:0x1cc},_0x3be85c=_0x5c54c1,_0x55d3f4={'mycoI':'src','xUZDv':function(_0x45ca52,_0xf2a108){return _0x45ca52(_0xf2a108);}},_0x406dce=(0x0,plugin_1[_0x3be85c(_0x7c7bfe._0x3e0c00)])(_0xf5a20c),_0xe69acc=_0x406dce[_0x3be85c(_0x7c7bfe._0x3c4c4f)](_0x4c0ea2=>_0x4c0ea2['id']),_0x30db4d=new Map(),_0x168a11=new Map(),_0x776905=new Set(),_0x33e1f6=[];let _0x46ccb1=0x0,_0x385482=![];for(const _0x3b7727 of _0x406dce){const _0x453e77=_0x3b7727['getSourceDirs'](_0xf5a20c);console['error'](_0x3be85c(0x1af)+_0x3b7727['id']+'\x20getSourceDirs('+_0xf5a20c+')\x20=>\x20'+_0x453e77['length']+_0x3be85c(0x1c2)+_0x453e77[_0x3be85c(0x1a9)](',\x20'));for(const _0x173e3f of _0x453e77){if(!_0x33e1f6['includes'](_0x173e3f))_0x33e1f6[_0x3be85c(_0x7c7bfe._0x275772)](_0x173e3f);const _0x2051d5=_0x3b7727['discoverFiles'](_0x173e3f);console['error']('[syke:debug]\x20'+_0x3b7727['id']+'\x20discoverFiles('+_0x173e3f+')\x20=>\x20'+_0x2051d5[_0x3be85c(0x1ab)]+'\x20files'),_0x46ccb1+=_0x2051d5[_0x3be85c(_0x7c7bfe._0x3d8164)];for(const _0x8f67b2 of _0x2051d5){if(_0x3248f4&&_0x776905[_0x3be85c(0x1a4)]>=_0x3248f4){_0x385482=!![];break;}_0x776905[_0x3be85c(0x1b9)](_0x8f67b2);if(!_0x30db4d['has'](_0x8f67b2))_0x30db4d['set'](_0x8f67b2,[]);}for(const _0xef2676 of _0x2051d5){if(!_0x776905['has'](_0xef2676))continue;const _0x3685b1=_0x3b7727['parseImports'](_0xef2676,_0xf5a20c,_0x173e3f),_0x53b0dd=[];for(const _0x5d0c5f of _0x3685b1){if(!_0x776905[_0x3be85c(0x1a5)](_0x5d0c5f))continue;_0x53b0dd['push'](_0x5d0c5f);const _0x32e616=_0x168a11['get'](_0x5d0c5f)||[];_0x32e616[_0x3be85c(0x1c9)](_0xef2676),_0x168a11['set'](_0x5d0c5f,_0x32e616);}_0x30db4d[_0x3be85c(_0x7c7bfe._0x5bb81e)](_0xef2676,_0x53b0dd);}}}_0x385482&&console['error'](_0x3be85c(_0x7c7bfe._0xe3a3c6)+_0x776905[_0x3be85c(0x1a4)]+'/'+_0x46ccb1+'\x20files\x20(limit:\x20'+_0x3248f4+').\x20Upgrade\x20to\x20Pro\x20for\x20unlimited.');const _0x2baf31=_0x33e1f6[0x0]||path['join'](_0xf5a20c,_0x55d3f4['mycoI']),_0x4d02d6={};_0x4d02d6['forward']=_0x30db4d,_0x4d02d6['reverse']=_0x168a11,_0x4d02d6['files']=_0x776905,_0x4d02d6[_0x3be85c(0x1ac)]=_0xf5a20c,_0x4d02d6[_0x3be85c(_0x7c7bfe._0x283b10)]=_0xe69acc,_0x4d02d6['sourceDirs']=_0x33e1f6,_0x4d02d6['sourceDir']=_0x2baf31;const _0x1324b6=_0x4d02d6;(0x0,memo_cache_1['resetMemoCache'])();const _0x14a567=(0x0,scc_1['computeSCC'])(_0x1324b6);_0x1324b6['scc']=_0x14a567,(0x0,pagerank_1['invalidatePageRank'])(),_0x1324b6['pageRank']=(0x0,pagerank_1[_0x3be85c(_0x7c7bfe._0x1591f2)])(_0x1324b6);const _0x350265=_0x14a567['condensed']['nodes']['filter'](_0x28101e=>_0x28101e['isCyclic'])['length'];return cachedGraph=_0x1324b6,console[_0x3be85c(0x1ad)](_0x3be85c(0x1a6)+_0xe69acc[_0x3be85c(0x1a9)]('+')+_0x3be85c(0x1b7)+_0x776905[_0x3be85c(_0x7c7bfe._0x255e63)]+'\x20files,\x20'+_0x55d3f4['xUZDv'](countEdges,_0x30db4d)+_0x3be85c(_0x7c7bfe._0x1a5daf)+_0x14a567['components'][_0x3be85c(0x1ab)]+'\x20SCCs\x20('+_0x350265+'\x20cyclic)'),_0x1324b6;}function _0x3803(){const _0x1539d0=['nduXntqYou9vrufuuW','Bhv4tvC','CMvZzxrnzw1Vq2fJAgu','zgv0zwn0tgfUz3vHz2vZ','y2fSBa','nZe1ntKWBhn3ExDR','ndb4Dhb5yxy','C2v0','igrPCNm6ia','A2TkChi','D1LbDKK','x19PBxbVCNrtDgfY','ChjVDg90ExbL','DMfSDwvZ','zw51BwvYywjSzq','ChvZAa','y29TChv0zvbHz2vsyw5R','zgvMyxvSDa','igvKz2vZlca','BgfUz3vHz2vZ','CMvIDwLSzeDYyxbO','ndq2m2zeEKXrAG','ntq4ndi4oe1Ny2TRDq','nZK0mZyWvNvxAfng','C2L6zq','AgfZ','w3n5A2vDieDYyxbOigj1AwX0icG','qK1cqve','BwfW','AM9PBG','x19ZzxrnB2r1BgvezwzHDwX0','BgvUz3rO','ChjVAMvJDfjVB3q','zxjYB3i','ntG5nti1zfnNA1z0','w3n5A2u6zgvIDwDDia','lI9NCMfWAc9Tzw1VlwnHy2HL','zgvMAw5LuhjVCgvYDhK','nJbhsvvxuKe','x19JCMvHDgvcAw5KAw5N','w3n5A2vDiezYzwuGDgLLCJOGBg9HzgvKia','mJy0nZu5mePyEwLWqq','yuzZrey','ktOG','mty0C0Tkz1nX','ywrK'];_0x3803=function(){return _0x1539d0;};return _0x3803();}function countEdges(_0x53edb8){const _0x1813d7={_0x4aa701:0x1c7,_0x3ff1ee:0x1ab},_0x58ec1a=_0x5c54c1;let _0x1151f7=0x0;for(const _0x3d65eb of _0x53edb8[_0x58ec1a(_0x1813d7._0x4aa701)]()){_0x1151f7+=_0x3d65eb[_0x58ec1a(_0x1813d7._0x3ff1ee)];}return _0x1151f7;}function getGraph(_0x2162dd,_0x4becab,_0x50222b){const _0x39687a={_0x57c096:0x1a7,_0x540cb6:0x1ac},_0x17fba3=_0x5c54c1,_0x3fc546={'BMBAQ':function(_0x260a8a,_0x3971d4){return _0x260a8a===_0x3971d4;},'wYAvI':function(_0x9ab672,_0x16cc91,_0x507449,_0xffcd30){return _0x9ab672(_0x16cc91,_0x507449,_0xffcd30);}};if(cachedGraph&&_0x3fc546[_0x17fba3(_0x39687a._0x57c096)](cachedGraph[_0x17fba3(_0x39687a._0x540cb6)],_0x2162dd))return cachedGraph;return _0x3fc546[_0x17fba3(0x1c4)](buildGraph,_0x2162dd,_0x4becab,_0x50222b);}function rebuildGraph(_0x273230,_0x527756,_0x3e3178){const _0x404ab0=_0x5c54c1,_0x1e4e05={'SyVXx':function(_0x498a5a,_0x502144,_0x2adb40,_0x539856){return _0x498a5a(_0x502144,_0x2adb40,_0x539856);}};return cachedGraph=null,(0x0,typescript_1['clearAliasCache'])(),(0x0,risk_scorer_1['invalidateProjectMetrics'])(),(0x0,pagerank_1['invalidatePageRank'])(),(0x0,memo_cache_1[_0x404ab0(0x1bc)])(),_0x1e4e05['SyVXx'](buildGraph,_0x273230,_0x527756,_0x3e3178);}
|