@syke1/mcp-server 1.6.0 → 1.7.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/LICENSE +13 -57
- package/README.md +18 -21
- package/dist/ai/analyzer.js +112 -1
- package/dist/ai/context-extractor.js +224 -1
- package/dist/ai/provider.js +186 -1
- package/dist/ai/realtime-analyzer.js +253 -1
- package/dist/config.js +121 -1
- package/dist/git/change-coupling.js +250 -1
- package/dist/graph/incremental.js +313 -1
- package/dist/graph/memo-cache.js +176 -1
- package/dist/graph/scc.js +206 -1
- package/dist/graph.d.ts +0 -3
- package/dist/graph.js +130 -1
- package/dist/index.js +825 -1
- package/dist/license/validator.d.ts +0 -3
- package/dist/license/validator.js +344 -1
- package/dist/remote/proxy.d.ts +34 -0
- package/dist/remote/proxy.js +214 -0
- package/dist/remote/types.d.ts +81 -0
- package/dist/remote/types.js +8 -0
- package/dist/tools/analyze-impact.d.ts +5 -5
- package/dist/tools/analyze-impact.js +326 -1
- package/dist/tools/gate-build.d.ts +0 -3
- package/dist/tools/gate-build.js +361 -1
- package/dist/watcher/file-cache.js +281 -1
- package/dist/web/server.js +925 -1
- package/package.json +52 -69
- package/dist/scoring/pagerank.d.ts +0 -67
- package/dist/scoring/pagerank.js +0 -1
- package/dist/scoring/risk-scorer.d.ts +0 -99
- package/dist/scoring/risk-scorer.js +0 -1
|
@@ -1 +1,281 @@
|
|
|
1
|
-
'use strict';const _0x4bb2cc=_0x12e5;(function(_0x19ad6b,_0xc3b032){const _0x4daf36={_0x45d67c:0x1b5,_0x4c2b28:0x19b,_0x2de600:0x1cd,_0x2ae3d4:0x19f},_0x2fc08f=_0x12e5,_0x29273b=_0x19ad6b();while(!![]){try{const _0x5683a1=-parseInt(_0x2fc08f(0x1ed))/0x1+parseInt(_0x2fc08f(_0x4daf36._0x45d67c))/0x2+parseInt(_0x2fc08f(_0x4daf36._0x4c2b28))/0x3*(-parseInt(_0x2fc08f(0x1cf))/0x4)+-parseInt(_0x2fc08f(_0x4daf36._0x2de600))/0x5+-parseInt(_0x2fc08f(0x199))/0x6*(-parseInt(_0x2fc08f(0x1d3))/0x7)+parseInt(_0x2fc08f(0x1c7))/0x8*(-parseInt(_0x2fc08f(_0x4daf36._0x2ae3d4))/0x9)+parseInt(_0x2fc08f(0x197))/0xa;if(_0x5683a1===_0xc3b032)break;else _0x29273b['push'](_0x29273b['shift']());}catch(_0x23afa3){_0x29273b['push'](_0x29273b['shift']());}}}(_0x3276,0xaed7e));function _0x12e5(_0x5e88cb,_0x578942){_0x5e88cb=_0x5e88cb-0x196;const _0x327637=_0x3276();let _0x12e536=_0x327637[_0x5e88cb];if(_0x12e5['LjXWWr']===undefined){var _0x23aa0c=function(_0x9aff1b){const _0x1c4907='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x47676e='',_0x433cad='';for(let _0x4d85bd=0x0,_0x149c4f,_0x44acfd,_0x17a23f=0x0;_0x44acfd=_0x9aff1b['charAt'](_0x17a23f++);~_0x44acfd&&(_0x149c4f=_0x4d85bd%0x4?_0x149c4f*0x40+_0x44acfd:_0x44acfd,_0x4d85bd++%0x4)?_0x47676e+=String['fromCharCode'](0xff&_0x149c4f>>(-0x2*_0x4d85bd&0x6)):0x0){_0x44acfd=_0x1c4907['indexOf'](_0x44acfd);}for(let _0x13b501=0x0,_0x1d2674=_0x47676e['length'];_0x13b501<_0x1d2674;_0x13b501++){_0x433cad+='%'+('00'+_0x47676e['charCodeAt'](_0x13b501)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x433cad);};_0x12e5['AuQCwk']=_0x23aa0c,_0x12e5['UVbiHH']={},_0x12e5['LjXWWr']=!![];}const _0x1f4b7b=_0x327637[0x0],_0x83f429=_0x5e88cb+_0x1f4b7b,_0x560c95=_0x12e5['UVbiHH'][_0x83f429];return!_0x560c95?(_0x12e536=_0x12e5['AuQCwk'](_0x12e536),_0x12e5['UVbiHH'][_0x83f429]=_0x12e536):_0x12e536=_0x560c95,_0x12e536;}var __createBinding=this&&this['__createBinding']||(Object[_0x4bb2cc(0x1e0)]?function(_0x180fef,_0x52a68c,_0x51b497,_0x5b3065){const _0x3bc237={_0x1fb82c:0x1af,_0x1b98f3:0x1c3,_0x296800:0x1bf,_0x1213a5:0x19c,_0x7c5380:0x1a6},_0x2ca792=_0x4bb2cc,_0x109398={};_0x109398[_0x2ca792(_0x3bc237._0x1fb82c)]='get';const _0x19ac5b=_0x109398;if(_0x5b3065===undefined)_0x5b3065=_0x51b497;var _0x3837c5=Object[_0x2ca792(_0x3bc237._0x1b98f3)](_0x52a68c,_0x51b497);if(!_0x3837c5||(_0x19ac5b['PEaEq']in _0x3837c5?!_0x52a68c[_0x2ca792(_0x3bc237._0x296800)]:_0x3837c5['writable']||_0x3837c5['configurable'])){const _0x4d29ff={};_0x4d29ff['enumerable']=!![],_0x4d29ff[_0x2ca792(_0x3bc237._0x1213a5)]=function(){return _0x52a68c[_0x51b497];},_0x3837c5=_0x4d29ff;}Object[_0x2ca792(_0x3bc237._0x7c5380)](_0x180fef,_0x5b3065,_0x3837c5);}:function(_0x3a8fc6,_0x25bf1f,_0x488853,_0x5a77a5){const _0x151e6f={};_0x151e6f['abVfo']=function(_0x2d5ed5,_0x118c52){return _0x2d5ed5===_0x118c52;};const _0x57ab84=_0x151e6f;if(_0x57ab84['abVfo'](_0x5a77a5,undefined))_0x5a77a5=_0x488853;_0x3a8fc6[_0x5a77a5]=_0x25bf1f[_0x488853];}),__setModuleDefault=this&&this[_0x4bb2cc(0x1eb)]||(Object['create']?function(_0x4bae67,_0x4c2cc0){const _0x2c49a4={_0x391c5d:0x1d0},_0x2b9131=_0x4bb2cc,_0x31589f={};_0x31589f['enumerable']=!![],_0x31589f['value']=_0x4c2cc0,Object['defineProperty'](_0x4bae67,_0x2b9131(_0x2c49a4._0x391c5d),_0x31589f);}:function(_0x1624b3,_0x14eadb){const _0x172a4d={_0x203796:0x1c1,_0x471438:0x1c1},_0x20c01f=_0x4bb2cc,_0x30d315={};_0x30d315[_0x20c01f(_0x172a4d._0x203796)]='default';const _0x14ad24=_0x30d315;_0x1624b3[_0x14ad24[_0x20c01f(_0x172a4d._0x471438)]]=_0x14eadb;}),__importStar=this&&this['__importStar']||(function(){const _0xb515cf={_0x11f0b6:0x1e5,_0x47ab30:0x19d},_0x37c0ae={_0x4cf56f:0x1e9},_0x4fafa1={'TCsNY':function(_0xd0fa89,_0xbc11a8){return _0xd0fa89(_0xbc11a8);},'CubAe':function(_0x5e2d04,_0x41db73){return _0x5e2d04!==_0x41db73;},'vvSru':'default'};var _0x12b933=function(_0x262a3f){const _0x1a6168=_0x12e5;return _0x12b933=Object[_0x1a6168(_0x37c0ae._0x4cf56f)]||function(_0x3638fb){const _0xe1f9ab=_0x1a6168;var _0x4c6763=[];for(var _0x5e7075 in _0x3638fb)if(Object['prototype']['hasOwnProperty']['call'](_0x3638fb,_0x5e7075))_0x4c6763[_0x4c6763[_0xe1f9ab(0x19d)]]=_0x5e7075;return _0x4c6763;},_0x12b933(_0x262a3f);};return function(_0x13d493){const _0x438ba8=_0x12e5,_0x2b80f7='2|0|1|4|3'['split']('|');let _0x5d6902=0x0;while(!![]){switch(_0x2b80f7[_0x5d6902++]){case'0':var _0x17e3de={};continue;case'1':if(_0x13d493!=null){for(var _0x4433bd=_0x4fafa1[_0x438ba8(_0xb515cf._0x11f0b6)](_0x12b933,_0x13d493),_0x5bf183=0x0;_0x5bf183<_0x4433bd[_0x438ba8(_0xb515cf._0x47ab30)];_0x5bf183++)if(_0x4fafa1[_0x438ba8(0x1d5)](_0x4433bd[_0x5bf183],_0x4fafa1['vvSru']))__createBinding(_0x17e3de,_0x13d493,_0x4433bd[_0x5bf183]);}continue;case'2':if(_0x13d493&&_0x13d493[_0x438ba8(0x1bf)])return _0x13d493;continue;case'3':return _0x17e3de;case'4':__setModuleDefault(_0x17e3de,_0x13d493);continue;}break;}};}());const _0x15940f={};function _0x3276(){const _0x5765c5=['y2XVC2u','C2v0','zenoDui','Dg9mB2nHBgvtDhjPBMC','y3jLyxrL','AgTyvui','igzPBgvZicG','ChjVAMvJDfjVB3q','tNbPDNa','venZtLK','zgvSzxrL','ywrKzwq','w3n5A2u6Aw5JCMvTzw50ywXDievYCM9YihvWzgf0Aw5NigDYyxbOigzVCIa','z2v0t3DUuhjVCgvYDhLoyw1LCW','AxnxyxrJAgvKrMLSzq','x19ZzxrnB2r1BgvezwzHDwX0','sLnuthK','mteXmJmZmeTdsevVEG','iokaLca','BM9YBwfSAxPL','CMvHzezPBgvtEw5J','zxjYB3i','DMfSDwvZ','y2fJAgu','Bw9KAwzPzwq','mJu2otCZnJbgDvLfrvG','CuriuLC','mZzjs0vwt1e','igvKz2vZlca','mtjNruHLtfa','z2v0','BgvUz3rO','w3n5A2u6y2fJAgvDia','mJC5vMfNs0PM','u0X5wwO','z3jHCgGTDxbKyxrLza','zw5KC1DPDgG','ywzMzwn0zwrgAwXLCW','C0TZwue','zgvSzxrLza','zgvMAw5LuhjVCgvYDhK','AM9PBG','zgvIB3vUy2vuAw1LCNm','zxzLBNrZ','C2L6zq','ChvZAa','igzVCIbJAgfUz2vZ','DxbKyxrLr3jHCgHgB3jgAwXL','z2v0u291CMnLrgLYCW','uevHrxe','BM93','C291CMnLrgLYCW','BMrhCeq','DMfSDwu','C3rHCNrxyxrJAgLUzW','mJiZntu2CgHzwKzt','D1Hqufm','CMvWBgfJzq','Bwf4','Aw5JBhvKzxm','z2v0qwXSrMLSzxm','D2f0y2HLCG','sg5Ryxq','z3jHCgG','zxH0zw5ZAw9UCW','x19LC01VzhvSzq','EwHQze4','uMvbvvy','D2f0y2G','z2v0t3DUuhjVCgvYDhLezxnJCMLWDg9Y','q0nhBwq','CgX1z2LUCW','zwrNzxndAgfUz2vK','mJeXodGWvgHnzMDu','y3jptM8','C3jJ','AwfcEM4','lI4VBgfUz3vHz2vZl3bSDwDPBG','CffQDMe','mZG5mZK2nufOyunQrW','Cgf0Aa','mJm0otK2uNreEhPX','zgvMyxvSDa','Dg90ywXmAw5LCW','rgTcwe4','mte0ntqZmuHKsuXIzW','Aw5PDgLHBgL6zq','q3vIqwu','C3bSAxq','ywrKzwrfzgDLCW','Aw52ywXPzgf0zq','y29TChv0zurPzMy','C291CMnLrgLY','CMvJDxjZAxzL'];_0x3276=function(){return _0x5765c5;};return _0x3276();}_0x15940f[_0x4bb2cc(0x1b3)]=!![],Object['defineProperty'](exports,'__esModule',_0x15940f),exports['FileCache']=void 0x0;const fs=__importStar(require('fs')),path=__importStar(require(_0x4bb2cc(0x1ce))),events_1=require(_0x4bb2cc(0x1a9)),plugin_1=require(_0x4bb2cc(0x1cb)),incremental_1=require('../graph/incremental'),memo_cache_1=require('../graph/memo-cache');class FileCache extends events_1['EventEmitter']{constructor(_0x506d9e){const _0x2dd6fe={_0x2496a5:0x1e3,_0x4abbdf:0x1b1,_0x3d9d3e:0x1bb,_0x44cbb1:0x1be,_0x4c9f5c:0x1c4,_0x545531:0x1ae},_0x2f3cf1=_0x4bb2cc,_0x287605={};_0x287605[_0x2f3cf1(0x1c4)]='.ts';const _0x37b1a9=_0x287605;super(),this[_0x2f3cf1(_0x2dd6fe._0x2496a5)]=_0x506d9e,this['cache']=new Map(),this[_0x2f3cf1(_0x2dd6fe._0x4abbdf)]=[],this[_0x2f3cf1(_0x2dd6fe._0x3d9d3e)]=null,this['debounceTimers']=new Map(),this['DEBOUNCE_MS']=0x5dc,this[_0x2f3cf1(0x1bd)]=null,this[_0x2f3cf1(0x1c5)]=(0x0,plugin_1['detectLanguages'])(_0x506d9e);const _0x24aa1b=new Set();for(const _0x6c77ea of this[_0x2f3cf1(0x1c5)]){for(const _0x4e082f of _0x6c77ea[_0x2f3cf1(_0x2dd6fe._0x44cbb1)]){_0x24aa1b['add'](_0x4e082f);}}this['extensions']=_0x24aa1b['size']>0x0?_0x24aa1b:new Set([_0x37b1a9[_0x2f3cf1(_0x2dd6fe._0x4c9f5c)]]);for(const _0x312be3 of this['plugins']){for(const _0x4f9ae8 of _0x312be3[_0x2f3cf1(_0x2dd6fe._0x545531)](_0x506d9e)){!this[_0x2f3cf1(0x1b1)][_0x2f3cf1(0x1b9)](_0x4f9ae8)&&this['sourceDirs']['push'](_0x4f9ae8);}}}get['sourceDir'](){const _0xec6d87={_0x371755:0x1c0},_0x17f103=_0x4bb2cc,_0x55cde8={};_0x55cde8['yhjdN']=_0x17f103(0x1c9);const _0x5dd2e6=_0x55cde8;return this[_0x17f103(0x1b1)][0x0]||path[_0x17f103(0x1a7)](this[_0x17f103(0x1e3)],_0x5dd2e6[_0x17f103(_0xec6d87._0x371755)]);}['setGraph'](_0x25e8f3){const _0x162027=_0x4bb2cc;this[_0x162027(0x1bd)]=_0x25e8f3;}[_0x4bb2cc(0x1d4)](){const _0x5e60c6={_0x177ef7:0x1d6,_0x534801:0x19d,_0x184939:0x1f3,_0x41c60f:0x1aa,_0x3cebb6:0x1d1},_0x3adeef=_0x4bb2cc;let _0x4ca544=0x0;for(const _0x2ad57a of this[_0x3adeef(0x1c5)]){for(const _0x3b799a of _0x2ad57a['getSourceDirs'](this[_0x3adeef(0x1e3)])){const _0x2964d9=_0x2ad57a['discoverFiles'](_0x3b799a);for(const _0x3d6e86 of _0x2964d9){try{const _0x30f840=fs[_0x3adeef(0x1f0)](_0x3d6e86,'utf-8');this['cache']['set'](path['normalize'](_0x3d6e86),_0x30f840),_0x4ca544+=_0x30f840[_0x3adeef(_0x5e60c6._0x177ef7)]('\x0a')[_0x3adeef(_0x5e60c6._0x534801)];}catch(_0x1c60c3){}}}}console['error']('[syke:cache]\x20Loaded\x20'+this[_0x3adeef(_0x5e60c6._0x184939)]['size']+_0x3adeef(0x1e2)+_0x4ca544[_0x3adeef(0x1df)]()+'\x20lines)\x20into\x20memory');const _0xabd5c1={};return _0xabd5c1['fileCount']=this['cache'][_0x3adeef(_0x5e60c6._0x41c60f)],_0xabd5c1[_0x3adeef(_0x5e60c6._0x3cebb6)]=_0x4ca544,_0xabd5c1;}[_0x4bb2cc(0x1b4)](){const _0x3b999f={_0x791826:0x1c2,_0x52a39c:0x1bb,_0x3d5194:0x1f1,_0x3965d9:0x1ac},_0x1c5ade={_0x2dca3b:0x1b7,_0x2f1d98:0x1a8,_0x42d994:0x1dd},_0x21b95c={_0x5c880e:0x1e6},_0x50d435=_0x4bb2cc,_0x16e3cb={'blVfE':function(_0x35298e,_0x1bb9e8){return _0x35298e(_0x1bb9e8);},'ReZYX':function(_0xa7881c,_0x2a08ca,_0x4d2813){return _0xa7881c(_0x2a08ca,_0x4d2813);}};if(this['watcher'])return;for(const _0x11dea6 of this['sourceDirs']){try{const _0x358c56={};_0x358c56[_0x50d435(0x1db)]=!![];const _0x29b22a=fs[_0x50d435(_0x3b999f._0x791826)](_0x11dea6,_0x358c56,(_0x1e154c,_0x343486)=>{const _0x4d1f31=_0x50d435;if(!_0x343486)return;if(!this[_0x4d1f31(0x1ea)](_0x343486))return;const _0x3a79f9=path[_0x4d1f31(0x1ef)](path['join'](_0x11dea6,_0x343486)),_0x453655=_0x343486[_0x4d1f31(_0x1c5ade._0x2dca3b)](/\\/g,'/'),_0x57d720=this[_0x4d1f31(0x1a8)]['get'](_0x3a79f9);if(_0x57d720)_0x16e3cb['blVfE'](clearTimeout,_0x57d720);this[_0x4d1f31(_0x1c5ade._0x2f1d98)][_0x4d1f31(_0x1c5ade._0x42d994)](_0x3a79f9,_0x16e3cb['ReZYX'](setTimeout,()=>{const _0x2696b5=_0x4d1f31;this['debounceTimers'][_0x2696b5(_0x21b95c._0x5c880e)](_0x3a79f9),this['handleFileEvent'](_0x3a79f9,_0x453655);},this['DEBOUNCE_MS']));});if(!this[_0x50d435(_0x3b999f._0x52a39c)])this[_0x50d435(0x1bb)]=_0x29b22a;console[_0x50d435(_0x3b999f._0x3d5194)]('[syke:cache]\x20Watching\x20'+_0x11dea6+_0x50d435(_0x3b999f._0x3965d9));}catch(_0x4ddf38){console['error']('[syke:cache]\x20Watch\x20failed\x20for\x20'+_0x11dea6+':\x20'+_0x4ddf38['message']);}}}['isWatchedFile'](_0x1ec96b){const _0x49a720={_0x3b7c70:0x1be},_0x546c7e=_0x4bb2cc,_0x543530={};_0x543530[_0x546c7e(0x1ca)]='.d.ts';const _0x30d138=_0x543530;if(_0x1ec96b['endsWith'](_0x30d138[_0x546c7e(0x1ca)]))return![];for(const _0x100390 of this[_0x546c7e(_0x49a720._0x3b7c70)]){if(_0x1ec96b[_0x546c7e(0x1a2)](_0x100390))return!![];}return![];}['handleFileEvent'](_0x468970,_0x5d581c){const _0x2bf095={_0x576443:0x1c8,_0x3f7f55:0x1a0,_0x38ead7:0x1d9,_0x52d425:0x19e,_0x480757:0x1b6,_0x250078:0x1ad,_0x173274:0x1e3,_0x9efe03:0x1c8,_0x478478:0x1a3,_0x29555b:0x1d8,_0x13bcc3:0x1f1,_0x4d20d3:0x1ee,_0x4b1c40:0x1d7,_0x2e1101:0x19a,_0x3c4e9e:0x1a3,_0x527b85:0x19d,_0x3752d2:0x1e8},_0x40b1be=_0x4bb2cc,_0xdc45d4={};_0xdc45d4['SLyYj']=function(_0x4c4378,_0x161ed0){return _0x4c4378===_0x161ed0;},_0xdc45d4[_0x40b1be(_0x2bf095._0x576443)]=_0x40b1be(0x1e7),_0xdc45d4['EXAEP']=_0x40b1be(0x1a5),_0xdc45d4[_0x40b1be(0x1ec)]='change',_0xdc45d4['wXPPS']=_0x40b1be(0x196),_0xdc45d4['Npivp']=_0x40b1be(0x1a1);const _0x2f8301=_0xdc45d4,_0x17074b=this[_0x40b1be(0x1f3)]['get'](_0x468970)||null;let _0x405ba0=null,_0xd47e8;try{if(fs['existsSync'](_0x468970)){_0x405ba0=fs[_0x40b1be(0x1f0)](_0x468970,'utf-8');if(_0x2f8301[_0x40b1be(_0x2bf095._0x3f7f55)](_0x17074b,null))_0xd47e8=_0x2f8301[_0x40b1be(0x1c8)];else{if(_0x17074b===_0x405ba0)return;else _0xd47e8='modified';}this[_0x40b1be(0x1f3)]['set'](_0x468970,_0x405ba0);}else _0xd47e8=_0x2f8301['EXAEP'],this['cache'][_0x40b1be(0x1e6)](_0x468970);}catch(_0x295cb9){return;}const _0x212b43=this[_0x40b1be(_0x2bf095._0x38ead7)](_0x17074b,_0x405ba0),_0x4b7766={'filePath':_0x468970,'relativePath':_0x5d581c,'type':_0xd47e8,'oldContent':_0x17074b,'newContent':_0x405ba0,'diff':_0x212b43,'timestamp':Date[_0x40b1be(0x1b0)]()};console['error'](_0x40b1be(_0x2bf095._0x52d425)+_0xd47e8['toUpperCase']()+':\x20'+_0x5d581c+'\x20('+_0x212b43[_0x40b1be(0x19d)]+'\x20changes)'),this['emit'](_0x2f8301['JSTLy'],_0x4b7766);if(this['graph'])try{let _0x22df64;if(_0xd47e8===_0x2f8301[_0x40b1be(_0x2bf095._0x480757)])_0x22df64=(0x0,incremental_1[_0x40b1be(_0x2bf095._0x250078)])(this[_0x40b1be(0x1bd)],_0x468970,this[_0x40b1be(_0x2bf095._0x173274)]);else _0xd47e8===_0x2f8301[_0x40b1be(_0x2bf095._0x9efe03)]?_0x22df64=(0x0,incremental_1['addFileToGraph'])(this['graph'],_0x468970,this['projectRoot']):_0x22df64=(0x0,incremental_1['removeFileFromGraph'])(this['graph'],_0x468970);if(_0x22df64[_0x40b1be(0x1c6)]&&_0x22df64[_0x40b1be(_0x2bf095._0x478478)]['length']>0x0){const _0x2b56b8=(0x0,memo_cache_1['getMemoCache'])()[_0x40b1be(_0x2bf095._0x29555b)](_0x22df64[_0x40b1be(0x1a3)]);console[_0x40b1be(_0x2bf095._0x13bcc3)]('[syke:incremental]\x20'+_0xd47e8+':\x20'+_0x5d581c+_0x40b1be(_0x2bf095._0x4d20d3)+('+'+_0x22df64[_0x40b1be(_0x2bf095._0x4b1c40)]['length']+'/-'+_0x22df64['removedEdges'][_0x40b1be(0x19d)]+_0x40b1be(_0x2bf095._0x2e1101))+(_0x22df64[_0x40b1be(_0x2bf095._0x3c4e9e)][_0x40b1be(_0x2bf095._0x527b85)]+'\x20affected,\x20'+_0x2b56b8+'\x20cache\x20entries\x20invalidated'));}this['emit'](_0x2f8301[_0x40b1be(0x1e4)],_0x22df64);}catch(_0x2b5fef){console['error'](_0x40b1be(_0x2bf095._0x3752d2)+_0x5d581c+':\x20'+_0x2b5fef['message']);}}[_0x4bb2cc(0x1d9)](_0x2adaa8,_0x4b0356){const _0xa567fb={_0x638791:0x1b2,_0x4c9055:0x1d6,_0x33466b:0x1b8,_0x1f2d86:0x19d,_0x3d3d57:0x1bc,_0x8dbbd6:0x1b2,_0x3a2dd3:0x1ab,_0x3ba7f3:0x1a4},_0xa5663c=_0x4bb2cc,_0x3b5ccf={};_0x3b5ccf['JRuXs']=function(_0x50bfc8,_0x3a6e54){return _0x50bfc8<_0x3a6e54;},_0x3b5ccf[_0xa5663c(0x1cc)]=function(_0x3fb896,_0x308d74){return _0x3fb896!==_0x308d74;},_0x3b5ccf[_0xa5663c(0x1e1)]=function(_0x251012,_0x847158){return _0x251012+_0x847158;},_0x3b5ccf['Hnkat']='added',_0x3b5ccf[_0xa5663c(0x1d2)]=function(_0x5dd551,_0x454d72){return _0x5dd551!==_0x454d72;},_0x3b5ccf[_0xa5663c(_0xa567fb._0x638791)]=function(_0x1c11b5,_0x2d83ab){return _0x1c11b5===_0x2d83ab;},_0x3b5ccf[_0xa5663c(0x198)]='removed',_0x3b5ccf[_0xa5663c(0x1a4)]='changed';const _0x565cc8=_0x3b5ccf,_0xb0906e=[],_0x4703f5=_0x2adaa8?_0x2adaa8[_0xa5663c(0x1d6)]('\x0a'):[],_0x5d6816=_0x4b0356?_0x4b0356[_0xa5663c(_0xa567fb._0x4c9055)]('\x0a'):[],_0x2dce93=Math[_0xa5663c(_0xa567fb._0x33466b)](_0x4703f5['length'],_0x5d6816[_0xa5663c(0x19d)]);for(let _0x4b36f2=0x0;_0x4b36f2<_0x2dce93;_0x4b36f2++){const _0x279cf7=_0x565cc8['JRuXs'](_0x4b36f2,_0x4703f5[_0xa5663c(_0xa567fb._0x1f2d86)])?_0x4703f5[_0x4b36f2]:undefined,_0x5bffd5=_0x4b36f2<_0x5d6816['length']?_0x5d6816[_0x4b36f2]:undefined;if(_0x279cf7===undefined&&_0x565cc8['pQjva'](_0x5bffd5,undefined))_0xb0906e['push']({'line':_0x565cc8[_0xa5663c(0x1e1)](_0x4b36f2,0x1),'type':_0x565cc8[_0xa5663c(_0xa567fb._0x3d3d57)],'new':_0x5bffd5});else{if(_0x565cc8['DkBXN'](_0x279cf7,undefined)&&_0x565cc8[_0xa5663c(_0xa567fb._0x8dbbd6)](_0x5bffd5,undefined))_0xb0906e['push']({'line':_0x565cc8['hkXUB'](_0x4b36f2,0x1),'type':_0x565cc8['qDHRW'],'old':_0x279cf7});else _0x565cc8['pQjva'](_0x279cf7,_0x5bffd5)&&_0xb0906e[_0xa5663c(_0xa567fb._0x3a2dd3)]({'line':_0x565cc8[_0xa5663c(0x1e1)](_0x4b36f2,0x1),'type':_0x565cc8[_0xa5663c(_0xa567fb._0x3ba7f3)],'old':_0x279cf7,'new':_0x5bffd5});}}return _0xb0906e;}['getFile'](_0xa64b0a){const _0x2c117a={_0x80a812:0x1f3},_0x4f3a7b=_0x4bb2cc;return this[_0x4f3a7b(_0x2c117a._0x80a812)]['get'](path[_0x4f3a7b(0x1ef)](_0xa64b0a))??null;}['getFileByRelPath'](_0x5fec93){const _0x543055={_0x5462b7:0x1f3},_0x48ef28=_0x4bb2cc,_0x24b7a3=path['normalize'](path[_0x48ef28(0x1a7)](this['sourceDir'],_0x5fec93));return this[_0x48ef28(_0x543055._0x5462b7)]['get'](_0x24b7a3)??null;}[_0x4bb2cc(0x1ba)](){const _0x4fd92a={_0x1c7a9e:0x1dd},_0x2a5548=_0x4bb2cc,_0x4dc5e6=new Map();for(const [_0xe201f2,_0x1ac591]of this[_0x2a5548(0x1f3)]){const _0x493c58=path['relative'](this[_0x2a5548(0x1da)],_0xe201f2)['replace'](/\\/g,'/');_0x4dc5e6[_0x2a5548(_0x4fd92a._0x1c7a9e)](_0x493c58,_0x1ac591);}return _0x4dc5e6;}get['size'](){const _0x41039a={_0xc11d0d:0x1aa},_0x1454f6=_0x4bb2cc;return this['cache'][_0x1454f6(_0x41039a._0xc11d0d)];}get[_0x4bb2cc(0x1d1)](){const _0x41cde3={_0x543b7a:0x19d},_0x4410f9=_0x4bb2cc;let _0xfd5210=0x0;for(const _0x2db32c of this[_0x4410f9(0x1f3)][_0x4410f9(0x1f2)]()){_0xfd5210+=_0x2db32c['split']('\x0a')[_0x4410f9(_0x41cde3._0x543b7a)];}return _0xfd5210;}['stop'](){const _0x140618={_0x19d46:0x1bb},_0x47d2a2=_0x4bb2cc,_0x36bced={'dCNuB':function(_0x36d500,_0x8c2a49){return _0x36d500(_0x8c2a49);},'TdHWA':'[syke:cache]\x20Watcher\x20stopped'};this[_0x47d2a2(_0x140618._0x19d46)]&&(this['watcher'][_0x47d2a2(0x1dc)](),this['watcher']=null);for(const _0x51b33d of this['debounceTimers']['values']()){_0x36bced[_0x47d2a2(0x1de)](clearTimeout,_0x51b33d);}this['debounceTimers']['clear'](),console['error'](_0x36bced['TdHWA']);}}exports['FileCache']=FileCache;
|
|
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.FileCache = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const events_1 = require("events");
|
|
40
|
+
const plugin_1 = require("../languages/plugin");
|
|
41
|
+
const incremental_1 = require("../graph/incremental");
|
|
42
|
+
const memo_cache_1 = require("../graph/memo-cache");
|
|
43
|
+
/**
|
|
44
|
+
* FileCache: Holds ALL source files in memory.
|
|
45
|
+
* Emits "change" events when files are modified on disk.
|
|
46
|
+
*/
|
|
47
|
+
class FileCache extends events_1.EventEmitter {
|
|
48
|
+
constructor(projectRoot) {
|
|
49
|
+
super();
|
|
50
|
+
this.projectRoot = projectRoot;
|
|
51
|
+
this.cache = new Map(); // abs path → content
|
|
52
|
+
this.sourceDirs = [];
|
|
53
|
+
this.watcher = null;
|
|
54
|
+
this.debounceTimers = new Map();
|
|
55
|
+
this.DEBOUNCE_MS = 1500;
|
|
56
|
+
this.graph = null;
|
|
57
|
+
this.plugins = (0, plugin_1.detectLanguages)(projectRoot);
|
|
58
|
+
// Collect all extensions from detected plugins
|
|
59
|
+
const allExts = new Set();
|
|
60
|
+
for (const plugin of this.plugins) {
|
|
61
|
+
for (const ext of plugin.extensions) {
|
|
62
|
+
allExts.add(ext);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.extensions = allExts.size > 0 ? allExts : new Set([".ts"]);
|
|
66
|
+
// Collect all source dirs
|
|
67
|
+
for (const plugin of this.plugins) {
|
|
68
|
+
for (const dir of plugin.getSourceDirs(projectRoot)) {
|
|
69
|
+
if (!this.sourceDirs.includes(dir)) {
|
|
70
|
+
this.sourceDirs.push(dir);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Primary source directory (backward compat) */
|
|
76
|
+
get sourceDir() {
|
|
77
|
+
return this.sourceDirs[0] || path.join(this.projectRoot, "src");
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Set the dependency graph reference for incremental updates.
|
|
81
|
+
* When a graph is set, file changes will trigger incremental
|
|
82
|
+
* edge updates and memo cache invalidation instead of requiring
|
|
83
|
+
* a full graph rebuild.
|
|
84
|
+
*/
|
|
85
|
+
setGraph(graph) {
|
|
86
|
+
this.graph = graph;
|
|
87
|
+
}
|
|
88
|
+
/** Load ALL source files into memory on startup */
|
|
89
|
+
initialize() {
|
|
90
|
+
let totalLines = 0;
|
|
91
|
+
for (const plugin of this.plugins) {
|
|
92
|
+
for (const dir of plugin.getSourceDirs(this.projectRoot)) {
|
|
93
|
+
const files = plugin.discoverFiles(dir);
|
|
94
|
+
for (const file of files) {
|
|
95
|
+
try {
|
|
96
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
97
|
+
this.cache.set(path.normalize(file), content);
|
|
98
|
+
totalLines += content.split("\n").length;
|
|
99
|
+
}
|
|
100
|
+
catch (_) {
|
|
101
|
+
// skip unreadable files
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
console.error(`[syke:cache] Loaded ${this.cache.size} files (${totalLines.toLocaleString()} lines) into memory`);
|
|
107
|
+
return { fileCount: this.cache.size, totalLines };
|
|
108
|
+
}
|
|
109
|
+
/** Start watching source directories for changes */
|
|
110
|
+
startWatching() {
|
|
111
|
+
if (this.watcher)
|
|
112
|
+
return;
|
|
113
|
+
// Watch each source directory
|
|
114
|
+
for (const dir of this.sourceDirs) {
|
|
115
|
+
try {
|
|
116
|
+
const watcher = fs.watch(dir, { recursive: true }, (eventType, filename) => {
|
|
117
|
+
if (!filename)
|
|
118
|
+
return;
|
|
119
|
+
if (!this.isWatchedFile(filename))
|
|
120
|
+
return;
|
|
121
|
+
const absPath = path.normalize(path.join(dir, filename));
|
|
122
|
+
const relPath = filename.replace(/\\/g, "/");
|
|
123
|
+
const existing = this.debounceTimers.get(absPath);
|
|
124
|
+
if (existing)
|
|
125
|
+
clearTimeout(existing);
|
|
126
|
+
this.debounceTimers.set(absPath, setTimeout(() => {
|
|
127
|
+
this.debounceTimers.delete(absPath);
|
|
128
|
+
this.handleFileEvent(absPath, relPath);
|
|
129
|
+
}, this.DEBOUNCE_MS));
|
|
130
|
+
});
|
|
131
|
+
// Store first watcher for backward compat
|
|
132
|
+
if (!this.watcher)
|
|
133
|
+
this.watcher = watcher;
|
|
134
|
+
console.error(`[syke:cache] Watching ${dir} for changes`);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
console.error(`[syke:cache] Watch failed for ${dir}: ${err.message}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
isWatchedFile(filename) {
|
|
142
|
+
if (filename.endsWith(".d.ts"))
|
|
143
|
+
return false;
|
|
144
|
+
for (const ext of this.extensions) {
|
|
145
|
+
if (filename.endsWith(ext))
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
handleFileEvent(absPath, relPath) {
|
|
151
|
+
const oldContent = this.cache.get(absPath) || null;
|
|
152
|
+
let newContent = null;
|
|
153
|
+
let type;
|
|
154
|
+
try {
|
|
155
|
+
if (fs.existsSync(absPath)) {
|
|
156
|
+
newContent = fs.readFileSync(absPath, "utf-8");
|
|
157
|
+
if (oldContent === null) {
|
|
158
|
+
type = "added";
|
|
159
|
+
}
|
|
160
|
+
else if (oldContent === newContent) {
|
|
161
|
+
return; // no actual change
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
type = "modified";
|
|
165
|
+
}
|
|
166
|
+
this.cache.set(absPath, newContent);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
type = "deleted";
|
|
170
|
+
this.cache.delete(absPath);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (_) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const diff = this.computeDiff(oldContent, newContent);
|
|
177
|
+
const change = {
|
|
178
|
+
filePath: absPath,
|
|
179
|
+
relativePath: relPath,
|
|
180
|
+
type,
|
|
181
|
+
oldContent,
|
|
182
|
+
newContent,
|
|
183
|
+
diff,
|
|
184
|
+
timestamp: Date.now(),
|
|
185
|
+
};
|
|
186
|
+
console.error(`[syke:cache] ${type.toUpperCase()}: ${relPath} (${diff.length} changes)`);
|
|
187
|
+
this.emit("change", change);
|
|
188
|
+
// Incremental graph update (if graph is available)
|
|
189
|
+
if (this.graph) {
|
|
190
|
+
try {
|
|
191
|
+
let result;
|
|
192
|
+
if (type === "modified") {
|
|
193
|
+
result = (0, incremental_1.updateGraphForFile)(this.graph, absPath, this.projectRoot);
|
|
194
|
+
}
|
|
195
|
+
else if (type === "added") {
|
|
196
|
+
result = (0, incremental_1.addFileToGraph)(this.graph, absPath, this.projectRoot);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// deleted
|
|
200
|
+
result = (0, incremental_1.removeFileFromGraph)(this.graph, absPath);
|
|
201
|
+
}
|
|
202
|
+
// Invalidate memo cache for affected files
|
|
203
|
+
if (result.edgesChanged && result.affectedFiles.length > 0) {
|
|
204
|
+
const invalidated = (0, memo_cache_1.getMemoCache)().invalidate(result.affectedFiles);
|
|
205
|
+
console.error(`[syke:incremental] ${type}: ${relPath} — ` +
|
|
206
|
+
`+${result.addedEdges.length}/-${result.removedEdges.length} edges, ` +
|
|
207
|
+
`${result.affectedFiles.length} affected, ${invalidated} cache entries invalidated`);
|
|
208
|
+
}
|
|
209
|
+
// Emit graph-updated event for downstream consumers (e.g., SSE broadcast)
|
|
210
|
+
this.emit("graph-updated", result);
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
console.error(`[syke:incremental] Error updating graph for ${relPath}: ${err.message}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** Simple line-by-line diff */
|
|
218
|
+
computeDiff(oldContent, newContent) {
|
|
219
|
+
const diffs = [];
|
|
220
|
+
const oldLines = oldContent ? oldContent.split("\n") : [];
|
|
221
|
+
const newLines = newContent ? newContent.split("\n") : [];
|
|
222
|
+
const maxLen = Math.max(oldLines.length, newLines.length);
|
|
223
|
+
for (let i = 0; i < maxLen; i++) {
|
|
224
|
+
const oldLine = i < oldLines.length ? oldLines[i] : undefined;
|
|
225
|
+
const newLine = i < newLines.length ? newLines[i] : undefined;
|
|
226
|
+
if (oldLine === undefined && newLine !== undefined) {
|
|
227
|
+
diffs.push({ line: i + 1, type: "added", new: newLine });
|
|
228
|
+
}
|
|
229
|
+
else if (oldLine !== undefined && newLine === undefined) {
|
|
230
|
+
diffs.push({ line: i + 1, type: "removed", old: oldLine });
|
|
231
|
+
}
|
|
232
|
+
else if (oldLine !== newLine) {
|
|
233
|
+
diffs.push({ line: i + 1, type: "changed", old: oldLine, new: newLine });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return diffs;
|
|
237
|
+
}
|
|
238
|
+
/** Get content of a specific file from cache */
|
|
239
|
+
getFile(absPath) {
|
|
240
|
+
return this.cache.get(path.normalize(absPath)) ?? null;
|
|
241
|
+
}
|
|
242
|
+
/** Get content by relative path (relative to first sourceDir) */
|
|
243
|
+
getFileByRelPath(relPath) {
|
|
244
|
+
const absPath = path.normalize(path.join(this.sourceDir, relPath));
|
|
245
|
+
return this.cache.get(absPath) ?? null;
|
|
246
|
+
}
|
|
247
|
+
/** Get all cached files as {relativePath → content} */
|
|
248
|
+
getAllFiles() {
|
|
249
|
+
const result = new Map();
|
|
250
|
+
for (const [absPath, content] of this.cache) {
|
|
251
|
+
const rel = path.relative(this.sourceDir, absPath).replace(/\\/g, "/");
|
|
252
|
+
result.set(rel, content);
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
/** Get file count */
|
|
257
|
+
get size() {
|
|
258
|
+
return this.cache.size;
|
|
259
|
+
}
|
|
260
|
+
/** Get total lines across all files */
|
|
261
|
+
get totalLines() {
|
|
262
|
+
let total = 0;
|
|
263
|
+
for (const content of this.cache.values()) {
|
|
264
|
+
total += content.split("\n").length;
|
|
265
|
+
}
|
|
266
|
+
return total;
|
|
267
|
+
}
|
|
268
|
+
/** Cleanup */
|
|
269
|
+
stop() {
|
|
270
|
+
if (this.watcher) {
|
|
271
|
+
this.watcher.close();
|
|
272
|
+
this.watcher = null;
|
|
273
|
+
}
|
|
274
|
+
for (const timer of this.debounceTimers.values()) {
|
|
275
|
+
clearTimeout(timer);
|
|
276
|
+
}
|
|
277
|
+
this.debounceTimers.clear();
|
|
278
|
+
console.error("[syke:cache] Watcher stopped");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.FileCache = FileCache;
|