@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.
@@ -1 +1,361 @@
1
- 'use strict';const _0x36c162=_0x1385;(function(_0x992ced,_0xbb32ba){const _0x4a9f8c={_0x5ec1c0:0xe9,_0x3efce2:0xbe,_0x1fda5e:0xfd,_0x4ca343:0xd9,_0x56f14f:0xfb,_0x4346c4:0xc4,_0x4b7083:0x11a},_0x5cd7be=_0x1385,_0x42c34c=_0x992ced();while(!![]){try{const _0xce4c83=parseInt(_0x5cd7be(0xc6))/0x1+-parseInt(_0x5cd7be(_0x4a9f8c._0x5ec1c0))/0x2+-parseInt(_0x5cd7be(_0x4a9f8c._0x3efce2))/0x3*(parseInt(_0x5cd7be(_0x4a9f8c._0x1fda5e))/0x4)+parseInt(_0x5cd7be(_0x4a9f8c._0x4ca343))/0x5*(-parseInt(_0x5cd7be(0xdf))/0x6)+-parseInt(_0x5cd7be(_0x4a9f8c._0x56f14f))/0x7+-parseInt(_0x5cd7be(_0x4a9f8c._0x4346c4))/0x8*(parseInt(_0x5cd7be(_0x4a9f8c._0x4b7083))/0x9)+parseInt(_0x5cd7be(0x126))/0xa;if(_0xce4c83===_0xbb32ba)break;else _0x42c34c['push'](_0x42c34c['shift']());}catch(_0x26a0f6){_0x42c34c['push'](_0x42c34c['shift']());}}}(_0x4e98,0xe9f6f));function _0x1385(_0x29cc4e,_0x1af598){_0x29cc4e=_0x29cc4e-0xb1;const _0x4e98a1=_0x4e98();let _0x138575=_0x4e98a1[_0x29cc4e];if(_0x1385['eoubXm']===undefined){var _0x4a2ed8=function(_0x3cee0f){const _0x24f9f0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5b7eed='',_0x310614='';for(let _0x3cfb90=0x0,_0x422089,_0x424d28,_0x15af7b=0x0;_0x424d28=_0x3cee0f['charAt'](_0x15af7b++);~_0x424d28&&(_0x422089=_0x3cfb90%0x4?_0x422089*0x40+_0x424d28:_0x424d28,_0x3cfb90++%0x4)?_0x5b7eed+=String['fromCharCode'](0xff&_0x422089>>(-0x2*_0x3cfb90&0x6)):0x0){_0x424d28=_0x24f9f0['indexOf'](_0x424d28);}for(let _0x55eb49=0x0,_0x4caaf3=_0x5b7eed['length'];_0x55eb49<_0x4caaf3;_0x55eb49++){_0x310614+='%'+('00'+_0x5b7eed['charCodeAt'](_0x55eb49)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x310614);};_0x1385['dfTsmh']=_0x4a2ed8,_0x1385['SNgdhr']={},_0x1385['eoubXm']=!![];}const _0x44849e=_0x4e98a1[0x0],_0x1ce343=_0x29cc4e+_0x44849e,_0x346fc9=_0x1385['SNgdhr'][_0x1ce343];return!_0x346fc9?(_0x138575=_0x1385['dfTsmh'](_0x138575),_0x1385['SNgdhr'][_0x1ce343]=_0x138575):_0x138575=_0x346fc9,_0x138575;}var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x4dcff1,_0x5cd06f,_0x4a96ea,_0x28abdc){const _0xd39132={_0x28065c:0xd6},_0x2f40b6=_0x1385,_0x4a44e1={};_0x4a44e1['zPlEa']=function(_0x3f5aaa,_0x478cbe){return _0x3f5aaa in _0x478cbe;};const _0x45fc73=_0x4a44e1;if(_0x28abdc===undefined)_0x28abdc=_0x4a96ea;var _0x440e2d=Object[_0x2f40b6(_0xd39132._0x28065c)](_0x5cd06f,_0x4a96ea);if(!_0x440e2d||(_0x45fc73[_0x2f40b6(0x114)]('get',_0x440e2d)?!_0x5cd06f['__esModule']:_0x440e2d['writable']||_0x440e2d['configurable'])){const _0x16ac7c={};_0x16ac7c[_0x2f40b6(0xca)]=!![],_0x16ac7c['get']=function(){return _0x5cd06f[_0x4a96ea];},_0x440e2d=_0x16ac7c;}Object[_0x2f40b6(0xbb)](_0x4dcff1,_0x28abdc,_0x440e2d);}:function(_0x5151a8,_0x5cc455,_0x5c0356,_0x5f352d){const _0x2706bb=_0x1385,_0x1417ff={};_0x1417ff[_0x2706bb(0xbc)]=function(_0x5d4ad1,_0x1313dc){return _0x5d4ad1===_0x1313dc;};const _0xe58d85=_0x1417ff;if(_0xe58d85['zmojG'](_0x5f352d,undefined))_0x5f352d=_0x5c0356;_0x5151a8[_0x5f352d]=_0x5cc455[_0x5c0356];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x6279e6,_0x47644d){const _0x2a808c={_0x4e97a4:0xca,_0x4164ab:0xbf},_0x1ab0a2=_0x1385,_0x2ccd52={};_0x2ccd52['swexG']='default';const _0x2f220e=_0x2ccd52,_0x15b5d1={};_0x15b5d1[_0x1ab0a2(_0x2a808c._0x4e97a4)]=!![],_0x15b5d1['value']=_0x47644d,Object[_0x1ab0a2(0xbb)](_0x6279e6,_0x2f220e[_0x1ab0a2(_0x2a808c._0x4164ab)],_0x15b5d1);}:function(_0x178117,_0xc055ee){const _0x56058e={_0xe57b18:0xf0},_0x535f65=_0x1385;_0x178117[_0x535f65(_0x56058e._0xe57b18)]=_0xc055ee;}),__importStar=this&&this['__importStar']||(function(){const _0x42b530={'BfnHH':function(_0x3e166f,_0x389763){return _0x3e166f(_0x389763);},'QNJmE':function(_0x484081,_0x36509b){return _0x484081<_0x36509b;},'xZLNq':'default','bAuFh':function(_0x21c0e9,_0x36fe4d,_0x2cddd1){return _0x21c0e9(_0x36fe4d,_0x2cddd1);}};var _0x37c22d=function(_0x35354c){const _0x2947b0=_0x1385;return _0x37c22d=Object['getOwnPropertyNames']||function(_0x2672db){const _0x3c102b=_0x1385;var _0x43f8bd=[];for(var _0x5507ee in _0x2672db)if(Object[_0x3c102b(0x119)][_0x3c102b(0x118)][_0x3c102b(0x103)](_0x2672db,_0x5507ee))_0x43f8bd[_0x43f8bd['length']]=_0x5507ee;return _0x43f8bd;},_0x42b530[_0x2947b0(0xde)](_0x37c22d,_0x35354c);};return function(_0x578451){const _0x71c3f6=_0x1385;if(_0x578451&&_0x578451[_0x71c3f6(0xcb)])return _0x578451;var _0x37d985={};if(_0x578451!=null){for(var _0x2f9ef4=_0x42b530['BfnHH'](_0x37c22d,_0x578451),_0x26a077=0x0;_0x42b530['QNJmE'](_0x26a077,_0x2f9ef4['length']);_0x26a077++)if(_0x2f9ef4[_0x26a077]!==_0x42b530['xZLNq'])__createBinding(_0x37d985,_0x578451,_0x2f9ef4[_0x26a077]);}return _0x42b530['bAuFh'](__setModuleDefault,_0x37d985,_0x578451),_0x37d985;};}());const _0x8027c9={};_0x8027c9['value']=!![],Object[_0x36c162(0xbb)](exports,'__esModule',_0x8027c9),exports['gateCheck']=gateCheck,exports['formatGateResult']=formatGateResult;const path=__importStar(require('path')),server_1=require(_0x36c162(0x11f)),analyze_impact_1=require(_0x36c162(0x11b)),risk_scorer_1=require('../scoring/risk-scorer'),change_coupling_1=require(_0x36c162(0xce));function detectCyclesWithSCC(_0x3e52c0,_0x47bf32){const _0x4af00e={_0x5b86f6:0xcc,_0x5b8813:0xe6,_0x112f2a:0xcc,_0x15b538:0x111,_0x464336:0xe3},_0x45b70a=_0x36c162,_0x40bcd5={};_0x40bcd5[_0x45b70a(_0x4af00e._0x5b86f6)]=function(_0xbeec62,_0x2afeee){return _0xbeec62===_0x2afeee;};const _0x15a6fa=_0x40bcd5,_0x1debd0=_0x47bf32['scc'];if(!_0x1debd0)return detectCyclesForFilesDFS(_0x3e52c0,_0x47bf32,0xa);const _0x52de67=[],_0x2df539=new Set();for(const _0x303f98 of _0x3e52c0){if(!_0x47bf32[_0x45b70a(0x111)]['has'](_0x303f98))continue;const _0x6d8b98=_0x1debd0['nodeToComponent'][_0x45b70a(_0x4af00e._0x5b8813)](_0x303f98);if(_0x15a6fa[_0x45b70a(_0x4af00e._0x112f2a)](_0x6d8b98,undefined))continue;const _0x4a1ace=_0x1debd0['condensed']['nodes'][_0x6d8b98];if(!_0x4a1ace['isCyclic'])continue;if(_0x2df539[_0x45b70a(0xbd)](_0x6d8b98))continue;_0x2df539[_0x45b70a(0xc0)](_0x6d8b98);const _0x503c15=[..._0x4a1ace[_0x45b70a(0x111)],_0x4a1ace[_0x45b70a(_0x4af00e._0x15b538)][0x0]],_0x1d753d={};_0x1d753d['cycle']=_0x503c15,_0x1d753d[_0x45b70a(0x125)]=_0x303f98,_0x52de67[_0x45b70a(_0x4af00e._0x464336)](_0x1d753d);}return _0x52de67;}function detectAllCycles(_0x1129dc){const _0x59e439={_0x29b6eb:0x113},_0x46622a=_0x36c162,_0x19ebc0=_0x1129dc['scc'];if(!_0x19ebc0)return[];const _0x593407=[];for(const _0x4a4133 of _0x19ebc0['condensed']['nodes']){if(!_0x4a4133['isCyclic'])continue;const _0xb950aa=[..._0x4a4133['files'],_0x4a4133[_0x46622a(0x111)][0x0]],_0x2b199d={};_0x2b199d[_0x46622a(_0x59e439._0x29b6eb)]=_0xb950aa,_0x2b199d['file']=_0x4a4133['files'][0x0],_0x593407['push'](_0x2b199d);}return _0x593407;}function detectCyclesForFilesDFS(_0x7cd3b4,_0xac4b8d,_0x158ef1=0xa){const _0x306639={_0x51f4f5:0xbd},_0x5434ff={_0xff0d41:0xbd},_0x3d467a=_0x36c162,_0x58adaf={'ihgtb':function(_0x18a685,_0x28b7fc){return _0x18a685>=_0x28b7fc;},'dpDiG':function(_0x10d275,_0x515901){return _0x10d275(_0x515901);}},_0x5a251e=[],_0x5b19de=new Set();for(const _0x393d4a of _0x7cd3b4){if(!_0xac4b8d['files'][_0x3d467a(_0x306639._0x51f4f5)](_0x393d4a))continue;const _0x3788f7=new Set(),_0x36cce0=[];function _0x5d9622(_0x174df1){const _0x158fda=_0x3d467a;if(_0x58adaf['ihgtb'](_0x5a251e['length'],_0x158ef1))return;if(_0x5b19de[_0x158fda(_0x5434ff._0xff0d41)](_0x174df1))return;_0x3788f7['add'](_0x174df1),_0x36cce0['push'](_0x174df1);const _0x5377f2=_0xac4b8d['forward'][_0x158fda(0xe6)](_0x174df1)||[];for(const _0x11c0dc of _0x5377f2){if(_0x58adaf['ihgtb'](_0x5a251e[_0x158fda(0xf4)],_0x158ef1))break;if(_0x3788f7['has'](_0x11c0dc)){const _0x5e8e30=_0x36cce0['indexOf'](_0x11c0dc);_0x5e8e30>=0x0&&_0x5a251e[_0x158fda(0xe3)]({'cycle':[..._0x36cce0['slice'](_0x5e8e30),_0x11c0dc],'file':_0x393d4a});}else!_0x5b19de['has'](_0x11c0dc)&&_0x5d9622(_0x11c0dc);}_0x3788f7['delete'](_0x174df1),_0x36cce0['pop']();}_0x58adaf[_0x3d467a(0xd8)](_0x5d9622,_0x393d4a);for(const _0xec66b of _0x3788f7)_0x5b19de[_0x3d467a(0xc0)](_0xec66b);}return _0x5a251e[_0x3d467a(0xc7)](0x0,_0x158ef1);}async function gateCheck(_0x153a45,_0x2a6fe5){const _0x18fc06={_0x1b8bb0:0xd1,_0xfd296b:0xf5,_0x28af4e:0xec,_0x220647:0x115,_0x1e725b:0xb4,_0x580557:0x10c,_0x251819:0x10f,_0x12649a:0xf4,_0x52414c:0xe3,_0x508767:0x125,_0x563589:0xd5,_0x5272bb:0xf4,_0x38b3e4:0xd5,_0x2e8e63:0xfc,_0x787996:0xba,_0x54f377:0x106,_0x45daa6:0x116,_0x49beaf:0x110,_0x5d57cd:0xe4,_0x571a25:0x11d,_0x37bfd4:0xb6,_0x3ae1b5:0xe4,_0x50d1cc:0xd0,_0x145c16:0x10e,_0x42dac2:0x127,_0x1e6d93:0xb7,_0x5c93b9:0xf9,_0x326588:0x123,_0x2d2559:0xf1,_0x514e24:0xf2,_0x1f927e:0xe4,_0x2df6c1:0xe4,_0x4b7d82:0x112,_0x428631:0xf8,_0x21c93a:0x124,_0x23ac2c:0xea,_0x92590a:0x109,_0xa53d19:0xbd,_0x52c3a6:0xc5,_0x464b05:0x10a,_0x39b061:0xe6,_0x2e29ea:0xb2,_0xfff02d:0xda,_0x23803e:0x11e,_0x3abcd2:0xe0,_0x93643f:0xf6,_0x34a153:0xe1,_0x154711:0x107,_0x13bfb5:0xe5,_0x37cb2d:0xe3,_0x2e83a4:0xb3,_0x526655:0xd4,_0x41c40f:0x10d},_0xf21e06=_0x36c162,_0x104c22={};_0x104c22[_0xf21e06(0xe1)]=function(_0x43f280,_0x307f85){return _0x43f280>_0x307f85;},_0x104c22['NltRD']='CRITICAL',_0x104c22['evDgc']=function(_0x566351,_0x36fbe3){return _0x566351-_0x36fbe3;},_0x104c22[_0xf21e06(_0x18fc06._0x1b8bb0)]=function(_0x36843f,_0x176467){return _0x36843f===_0x176467;},_0x104c22['PHLXg']=_0xf21e06(_0x18fc06._0xfd296b),_0x104c22['SkMqX']=_0xf21e06(0xf1),_0x104c22['BeCcQ']=_0xf21e06(_0x18fc06._0x28af4e),_0x104c22['DQIZW']='LOW',_0x104c22[_0xf21e06(0x105)]=function(_0x4dd6fe,_0x4c492d){return _0x4dd6fe>_0x4c492d;},_0x104c22['qZxjn']='Fix\x20the\x20issues\x20above\x20before\x20building.\x20Use\x20`check_warnings`\x20for\x20details,\x20then\x20`analyze_impact`\x20on\x20affected\x20files.',_0x104c22[_0xf21e06(_0x18fc06._0x220647)]='WARN',_0x104c22[_0xf21e06(_0x18fc06._0x1e725b)]='Review\x20the\x20issues.\x20If\x20you\x27ve\x20verified\x20they\x27re\x20safe,\x20proceed\x20with\x20the\x20build.\x20Use\x20`check_warnings\x20acknowledge=true`\x20to\x20clear\x20warnings.',_0x104c22[_0xf21e06(_0x18fc06._0x580557)]='PASS';const _0x170574=_0x104c22,_0xf41d5c=(0x0,server_1['getUnacknowledgedWarnings'])(),_0x55b0ae=_0x153a45['scc']?.[_0xf21e06(_0x18fc06._0x251819)]['nodes'][_0xf21e06(0xf4)],_0x3771f0=_0x153a45['scc']?.['condensed']['nodes']['filter'](_0x5cc410=>_0x5cc410[_0xf21e06(0xe2)])[_0xf21e06(_0x18fc06._0x12649a)],_0x4f13a5={};_0x4f13a5['filesInGraph']=_0x153a45['files']['size'],_0x4f13a5['unresolvedWarnings']=_0xf41d5c['length'],_0x4f13a5['sccCount']=_0x55b0ae,_0x4f13a5[_0xf21e06(0xb5)]=_0x3771f0;const _0x720e01=_0x4f13a5,_0x106d08=_0x2a6fe5?_0xf41d5c[_0xf21e06(0xcf)](_0x25e3e7=>_0x2a6fe5['some'](_0x23d9ae=>_0x25e3e7['file']===_0x23d9ae||_0x23d9ae['endsWith'](_0x25e3e7[_0xf21e06(0x125)])||_0x25e3e7['file']['endsWith'](_0x23d9ae['replace'](/\\/g,'/')))):_0xf41d5c,_0x185a52=[];for(const _0x4993d6 of _0x106d08){const _0x51709c=mapRiskToSeverity(_0x4993d6['riskLevel']);_0x51709c&&_0x185a52[_0xf21e06(_0x18fc06._0x52414c)]({'file':_0x4993d6[_0xf21e06(_0x18fc06._0x508767)],'severity':_0x51709c,'description':_0x4993d6['summary']+(_0x170574['qynOe'](_0x4993d6[_0xf21e06(_0x18fc06._0x563589)][_0xf21e06(_0x18fc06._0x5272bb)],0x0)?'\x20(broken\x20imports:\x20'+_0x4993d6[_0xf21e06(_0x18fc06._0x38b3e4)][_0xf21e06(_0x18fc06._0x2e8e63)](',\x20')+')':'')});}const _0x55e12c=_0x2a6fe5||[],_0x5c8f3d=detectCyclesWithSCC(_0x55e12c,_0x153a45);for(const _0x259bfe of _0x5c8f3d){const _0x15402f=_0x259bfe['cycle']['map'](_0x2d8154=>path['relative'](_0x153a45['sourceDir'],_0x2d8154)[_0xf21e06(0xba)](/\\/g,'/'))['join']('\x20->\x20');_0x185a52['push']({'file':path['relative'](_0x153a45['sourceDir'],_0x259bfe[_0xf21e06(0x125)])[_0xf21e06(_0x18fc06._0x787996)](/\\/g,'/'),'severity':_0x170574[_0xf21e06(_0x18fc06._0x54f377)],'description':_0xf21e06(0xc9)+_0x170574['evDgc'](_0x259bfe[_0xf21e06(0x113)][_0xf21e06(_0x18fc06._0x12649a)],0x1)+'\x20files):\x20'+_0x15402f});}const _0x2dcc36=new Map();if(_0x2a6fe5){try{(0x0,risk_scorer_1[_0xf21e06(_0x18fc06._0x45daa6)])(_0x153a45);}catch{}const _0x542025=(0x0,analyze_impact_1[_0xf21e06(_0x18fc06._0x49beaf)])(_0x153a45,0x5),_0x913dd0=new Set(_0x542025['map'](_0x489db3=>_0x489db3[_0xf21e06(0xd7)]));for(const _0x10a9df of _0x2a6fe5){if(!_0x153a45['files']['has'](_0x10a9df))continue;const _0x12b93c=path['relative'](_0x153a45[_0xf21e06(0xda)],_0x10a9df)['replace'](/\\/g,'/');try{const _0x56da98=(0x0,risk_scorer_1[_0xf21e06(0x101)])(_0x10a9df,_0x153a45);_0x2dcc36[_0xf21e06(0xf7)](_0x12b93c,_0x56da98);if(_0x170574[_0xf21e06(0xd1)](_0x56da98[_0xf21e06(_0x18fc06._0x5d57cd)],'CRITICAL'))_0x185a52['push']({'file':_0x12b93c,'severity':'CRITICAL','description':'Critical\x20risk\x20score\x20'+_0x56da98[_0xf21e06(_0x18fc06._0x571a25)]['toFixed'](0x2)+'\x20(fan-in:\x20'+_0x56da98[_0xf21e06(0xb7)]+',\x20cascade:\x20'+_0x56da98['cascadeDepth']+'\x20levels,\x20complexity:\x20'+_0x56da98[_0xf21e06(_0x18fc06._0x37bfd4)]+')'});else _0x170574[_0xf21e06(0xd1)](_0x56da98[_0xf21e06(_0x18fc06._0x3ae1b5)],_0x170574[_0xf21e06(0xd0)])&&_0x185a52['push']({'file':_0x12b93c,'severity':_0x170574[_0xf21e06(_0x18fc06._0x50d1cc)],'description':_0xf21e06(_0x18fc06._0x145c16)+_0x56da98['composite']['toFixed'](0x2)+_0xf21e06(_0x18fc06._0x42dac2)+_0x56da98[_0xf21e06(_0x18fc06._0x1e6d93)]+_0xf21e06(_0x18fc06._0x5c93b9)+_0x56da98['cascadeDepth']+_0xf21e06(0x120)+_0x56da98['complexity']+')'});}catch{}if(_0x913dd0['has'](_0x12b93c)&&!_0x2dcc36['has'](_0x12b93c)){const _0x147372=_0x542025['find'](_0x3d1df0=>_0x3d1df0[_0xf21e06(0xd7)]===_0x12b93c),_0x3ab177={};_0x3ab177['file']=_0x12b93c,_0x3ab177[_0xf21e06(_0x18fc06._0x326588)]=_0xf21e06(_0x18fc06._0x2d2559),_0x3ab177['description']='Hub\x20file\x20modified\x20('+_0x147372['dependentCount']+'\x20dependents,\x20'+_0x147372['riskLevel']+_0xf21e06(_0x18fc06._0x514e24),_0x185a52[_0xf21e06(0xe3)](_0x3ab177);}else{if(_0x913dd0['has'](_0x12b93c)){const _0x4ef605=_0x2dcc36[_0xf21e06(0xe6)](_0x12b93c);if(_0x4ef605&&(_0x4ef605[_0xf21e06(_0x18fc06._0x1f927e)]==='LOW'||_0x4ef605[_0xf21e06(_0x18fc06._0x2df6c1)]===_0x170574[_0xf21e06(_0x18fc06._0x4b7d82)]||_0x4ef605[_0xf21e06(0xe4)]===_0x170574[_0xf21e06(_0x18fc06._0x428631)])){const _0x4a1db8=_0x542025['find'](_0xe87be6=>_0xe87be6[_0xf21e06(0xd7)]===_0x12b93c);_0x185a52['push']({'file':_0x12b93c,'severity':_0xf21e06(0xf1),'description':_0xf21e06(0xd2)+_0x4a1db8[_0xf21e06(_0x18fc06._0x21c93a)]+_0xf21e06(_0x18fc06._0x23ac2c)+_0x4ef605['composite']['toFixed'](0x2)});}}}}try{const _0x52f09b=await(0x0,change_coupling_1['mineGitHistory'])(_0x153a45[_0xf21e06(_0x18fc06._0x92590a)]);if(_0x52f09b['totalCommitsAnalyzed']>0x0){const _0x42fdde=new Set(_0x2a6fe5['map'](_0x316390=>path[_0xf21e06(0xdd)](_0x153a45[_0xf21e06(0x109)],_0x316390)[_0xf21e06(0xba)](/\\/g,'/')));for(const _0x54be07 of _0x2a6fe5){if(!_0x153a45['files'][_0xf21e06(_0x18fc06._0xa53d19)](_0x54be07))continue;const _0x49147e=path['relative'](_0x153a45['projectRoot'],_0x54be07)['replace'](/\\/g,'/'),_0x2ef5b6=(0x0,change_coupling_1[_0xf21e06(_0x18fc06._0x52c3a6)])(_0x49147e,_0x52f09b);for(const _0xda3dbe of _0x2ef5b6){const _0x4ab615=_0xda3dbe['file1']===_0x49147e?_0xda3dbe[_0xf21e06(_0x18fc06._0x464b05)]:_0xda3dbe['file1'];if(_0x42fdde['has'](_0x4ab615))continue;const _0xe37449=path['normalize'](path[_0xf21e06(0xfc)](_0x153a45['projectRoot'],_0x4ab615)),_0x51c06c=_0x153a45['forward']['get'](_0x54be07)||[],_0x21eb93=_0x153a45['reverse'][_0xf21e06(_0x18fc06._0x39b061)](_0x54be07)||[],_0x3d7b4b=_0x51c06c[_0xf21e06(_0x18fc06._0x2e29ea)](_0xe37449)||_0x21eb93[_0xf21e06(0xb2)](_0xe37449);if(_0x3d7b4b)continue;if(_0xda3dbe['confidence']<0.3)continue;const _0x147644=_0xda3dbe[_0xf21e06(0xb8)]>=0.5?'MEDIUM':_0x170574['DQIZW'],_0x194807=Math['round'](_0xda3dbe['confidence']*0x64),_0xb41509=path['relative'](_0x153a45[_0xf21e06(_0x18fc06._0xfff02d)],_0x54be07)['replace'](/\\/g,'/'),_0x39cab7={};_0x39cab7[_0xf21e06(_0x18fc06._0x508767)]=_0xb41509,_0x39cab7[_0xf21e06(0x123)]=_0x147644,_0x39cab7[_0xf21e06(_0x18fc06._0x23803e)]=_0xf21e06(0x104)+_0x4ab615+_0xf21e06(_0x18fc06._0x3abcd2)+_0x194807+'%\x20of\x20commits\x20('+_0xda3dbe[_0xf21e06(_0x18fc06._0x93643f)]+'\x20times)\x20--\x20consider\x20reviewing',_0x185a52['push'](_0x39cab7);}}}}catch{}}const _0x27fa08=_0x185a52['some'](_0x4ac38f=>_0x4ac38f[_0xf21e06(0x123)]===_0xf21e06(0xef)),_0x18cd5f=_0x185a52[_0xf21e06(0xcf)](_0x3ce4c0=>_0x3ce4c0[_0xf21e06(0x123)]===_0xf21e06(0xf5)),_0x15c51a=_0x170574[_0xf21e06(_0x18fc06._0x34a153)](_0x18cd5f['length'],0x0)&&_0x106d08['some'](_0x56bc4f=>_0x56bc4f[_0xf21e06(0xe4)]===_0xf21e06(0xf5)&&_0x56bc4f['brokenImports'][_0xf21e06(0xf4)]>0x0),_0x506e77=_0x170574['lLcdD'](_0x5c8f3d['length'],0x0);let _0x148f72,_0x4ac9a0,_0x5192f7,_0x2f6e3d=0x0;if(_0x27fa08||_0x15c51a||_0x506e77){_0x148f72='FAIL';const _0x4c4c95=[];if(_0x27fa08)_0x4c4c95['push'](_0xf21e06(_0x18fc06._0x154711));if(_0x15c51a)_0x4c4c95[_0xf21e06(0xe3)](_0xf21e06(_0x18fc06._0x13bfb5));if(_0x506e77)_0x4c4c95[_0xf21e06(_0x18fc06._0x37cb2d)](_0x5c8f3d['length']+_0xf21e06(0x102));_0x4ac9a0='BUILD\x20BLOCKED\x20—\x20'+_0x4c4c95['join'](',\x20'),_0x5192f7=_0x170574[_0xf21e06(0xd3)];}else _0x18cd5f[_0xf21e06(0xf4)]>0x0||_0x185a52[_0xf21e06(_0x18fc06._0x2e83a4)](_0x544595=>_0x544595['severity']===_0xf21e06(0xf1))?(_0x148f72=_0x170574['JXdDs'],_0x4ac9a0=_0xf21e06(0xed)+_0x185a52['length']+'\x20issue(s)\x20detected',_0x5192f7=_0x170574[_0xf21e06(0xb4)]):(_0x148f72=_0x170574['NITha'],_0x4ac9a0=_0xf21e06(0x122),_0x5192f7=_0xf21e06(0x121),_0x2f6e3d=(0x0,server_1[_0xf21e06(0x10b)])());const _0xfdad3a={};return _0xfdad3a['verdict']=_0x148f72,_0xfdad3a[_0xf21e06(0x11c)]=_0x4ac9a0,_0xfdad3a['issues']=_0x185a52,_0xfdad3a[_0xf21e06(0xcd)]=_0x5192f7,_0xfdad3a['stats']=_0x720e01,_0xfdad3a[_0xf21e06(_0x18fc06._0x526655)]=_0x2f6e3d,_0xfdad3a[_0xf21e06(_0x18fc06._0x41c40f)]=_0x2dcc36['size']>0x0?_0x2dcc36:undefined,_0xfdad3a;}function _0x4e98(){const _0x1ac5cb=['igrLCgvUzgvUDhmPlcbJB21WB3nPDguGC2nVCMu6ia','lsbbDxrVlwfJA25VD2XLzgDLzdOG','u0fgrq','ufjpq0vfrcbxsvriienbvvrjt04G4Ocuia','iYmJieLZC3vLCW','q1jjveLdquW','zgvMyxvSDa','tuvesvvn','ihjPC2SP','Eg9SDeu','BgvUz3rO','seLhsa','y29dAgfUz2vdB3vUDa','C2v0','qMvdy1e','lcbJyxnJywrLoIa','lsbtDhjVBMDSEsbdB25Uzwn0zwqGq29TCg9Uzw50CZOG','mZG0otG0nKDMrvn4sW','AM9PBG','oeDqCfDHCW','C3rHDhm','DMvYzgLJDa','C2nJq291BNq','z2v0uMLZA1nJB3jL','ignPCMn1BgfYigrLCgvUzgvUy3KOAwvZkq','y2fSBa','sgLZDg9YAwnHBcbJB3vWBgLUzZOG','BeXJzeq','tMX0uKq','q1jjveLdquWGD2fYBMLUz3m','BuTpzKq','ChjVAMvJDfjVB3q','zMLSzti','ywnRBM93BgvKz2vxyxjUAw5NCW','tKLuAge','CMLZA1nJB3jLCW','sgLNAcbYAxnRihnJB3jLia','y29UzgvUC2vK','z2v0shvIrMLSzxm','zMLSzxm','u2TnCvG','y3LJBgu','ELbSrwe','sLHKrhm','y29TChv0zvbYB2PLy3rnzxrYAwnZ','iYmJifn0yxrZ','AgfZt3DUuhjVCgvYDhK','ChjVDg90ExbL','ndu2otu3EgDjsvDP','lI9HBMfSExPLlwLTCgfJDa','C3rHDhvZtgLUzq','y29TCg9ZAxrL','zgvZy3jPChrPB24','lI4VD2vIl3nLCNzLCG','igXLDMvSCYWGy29TCgXLEgL0EtOG','tM8GAxnZDwvZigrLDgvJDgvKlIbzB3uGBwf5ihbYB2nLzwqGD2L0AcbIDwLSzc9KzxbSB3KU','qwXSignSzwfYiokaLcbZywzLihrVigj1AwXK','C2v2zxjPDhK','zgvWzw5Kzw50q291BNq','zMLSzq','nJe3ntG4odb5tNjwExK','icHMyw4TAw46ia','iYmJifjPC2SGu2nVCMvZ','Aw5JBhvKzxm','C29Tzq','rMPgBwC','y3LJBgLJu0ndCW','y29TCgXLEgL0Eq','DhjHBNnPDgL2zuzHBKLU','y29UzMLKzw5Jzq','ufjisLG','CMvWBgfJzq','zgvMAw5LuhjVCgvYDhK','EM1VAKC','AgfZ','otmYotqZr0P4Ew5e','C3DLEeC','ywrK','C2L6zq','DLnNqwS','De5Uy3q','mJmYA21PwwvT','z2v0q291CgXLzezPBgvZ','mJeZntC2qvr5q1ri','C2XPy2u','zgz6tLq','q2LYy3vSyxiGzgvWzw5Kzw5JEsbKzxrLy3rLzcaO','zw51BwvYywjSzq','x19LC01VzhvSzq','wNbAwLm','CMvJB21Tzw5KyxrPB24','lI4Vz2L0l2nOyw5Nzs1JB3vWBgLUzW','zMLSDgvY','ueHmwgC','D2Lqrhy','shvIigzPBguGBw9KAwzPzwqGka','CvP4AM4','yxv0B0fJA25VD2XLzgDLza','yNjVA2vUsw1WB3j0CW','z2v0t3DUuhjVCgvYDhLezxnJCMLWDg9Y','CMvSyxrPDMvqyxrO','zhbeAuC','ndy5mZu1uhD5zvnQ','C291CMnLrgLY','iYmJifn0yxr1CW','ChrUC2W','CMvSyxrPDMu','qMzUseG','mtaYvfHfyMrH','ignOyw5NzxmGD2L0Acb0AgLZigzPBguGAw4G','CxLUt2u','AxndEwnSAwm','ChvZAa','CMLZA0XLDMvS','seLhscb3yxjUAw5NCYb3AxrOigjYB2TLBIbPBxbVCNrZ','z2v0','zM1cvw4','xsOQia','mJm4mtK2mNPdy2rUCq'];_0x4e98=function(){return _0x1ac5cb;};return _0x4e98();}function formatGateResult(_0x3de4d6){const _0x3a1a54={_0xbd48a:0xc3,_0xb205e3:0xe7,_0x27779f:0xb9,_0x2ffb87:0x117,_0x373f9b:0xc2,_0x145770:0xf3,_0x4e1a49:0xff,_0x47977d:0xc3,_0x492e42:0x11c,_0x937203:0xf4,_0x4f76f0:0xf5,_0x5ee0e8:0xcd,_0x5b0574:0xfe,_0x22d312:0x100,_0x45046a:0xfa,_0x21df1b:0xeb,_0x53e493:0xd4,_0x9b806b:0x10d,_0x2bad64:0xc1,_0x38186a:0xe3},_0x6c8ce1=_0x36c162,_0x511413={};_0x511413['dfzNT']=function(_0x599a2a,_0x2fbe2f){return _0x599a2a===_0x2fbe2f;},_0x511413['iPZjn']=function(_0x3def1a,_0x1f9dc2){return _0x3def1a===_0x1f9dc2;},_0x511413[_0x6c8ce1(_0x3a1a54._0xbd48a)]='WARN',_0x511413['Xsngy']=_0x6c8ce1(0xdb),_0x511413[_0x6c8ce1(_0x3a1a54._0xb205e3)]=function(_0x233da5,_0x74e28c){return _0x233da5>_0x74e28c;},_0x511413[_0x6c8ce1(0xdc)]=function(_0x1e1f66,_0x47fe1a){return _0x1e1f66===_0x47fe1a;},_0x511413[_0x6c8ce1(_0x3a1a54._0x27779f)]=_0x6c8ce1(_0x3a1a54._0x2ffb87),_0x511413[_0x6c8ce1(_0x3a1a54._0x373f9b)]=function(_0x5e79cf,_0x2c6cba){return _0x5e79cf!==_0x2c6cba;},_0x511413[_0x6c8ce1(_0x3a1a54._0x145770)]=function(_0x438439,_0x3e2c97){return _0x438439>_0x3e2c97;},_0x511413['EQgAY']=_0x6c8ce1(0xb1);const _0x1cf948=_0x511413,_0x32fbb3=_0x1cf948[_0x6c8ce1(0xc8)](_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x4e1a49)],'PASS')?'✅':_0x1cf948['iPZjn'](_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x4e1a49)],_0x1cf948[_0x6c8ce1(_0x3a1a54._0x47977d)])?'⚠️':'🚫',_0x3aa84d=['##\x20SYKE\x20Build\x20Gate\x20—\x20'+_0x32fbb3+'\x20'+_0x3de4d6['verdict'],'',_0x1cf948['Xsngy'],_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x492e42)]];if(_0x1cf948[_0x6c8ce1(_0x3a1a54._0xb205e3)](_0x3de4d6['issues'][_0x6c8ce1(_0x3a1a54._0x937203)],0x0)){_0x3aa84d[_0x6c8ce1(0xe3)]('',_0x6c8ce1(0xee));for(const _0x255bcc of _0x3de4d6['issues']){const _0x105d29=_0x1cf948['ptnsl'](_0x255bcc['severity'],'CRITICAL')?'🚫':_0x1cf948['iPZjn'](_0x255bcc[_0x6c8ce1(0x123)],_0x6c8ce1(_0x3a1a54._0x4f76f0))?'🔴':_0x1cf948['dfzNT'](_0x255bcc['severity'],'MEDIUM')?'🟡':'🔵';_0x3aa84d['push']('-\x20'+_0x105d29+'\x20**['+_0x255bcc[_0x6c8ce1(0x123)]+_0x6c8ce1(0xe8)+_0x255bcc[_0x6c8ce1(0x125)]+':\x20'+_0x255bcc['description']);}}_0x3aa84d['push']('','###\x20Recommendation',_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x5ee0e8)]),_0x3aa84d[_0x6c8ce1(0xe3)]('',_0x1cf948['PRHJX'],'-\x20Files\x20in\x20graph:\x20'+_0x3de4d6['stats']['filesInGraph'],'-\x20Unresolved\x20warnings:\x20'+_0x3de4d6['stats']['unresolvedWarnings']);_0x1cf948[_0x6c8ce1(0xc2)](_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x5b0574)][_0x6c8ce1(_0x3a1a54._0x22d312)],undefined)&&_0x3aa84d['push'](_0x6c8ce1(_0x3a1a54._0x45046a)+_0x3de4d6['stats'][_0x6c8ce1(0x100)]);_0x1cf948['vSgAk'](_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x5b0574)]['cyclicSCCs'],undefined)&&_0x1cf948[_0x6c8ce1(0xe7)](_0x3de4d6[_0x6c8ce1(0xfe)]['cyclicSCCs'],0x0)&&_0x3aa84d['push']('-\x20Circular\x20dependency\x20clusters:\x20'+_0x3de4d6['stats']['cyclicSCCs']);_0x1cf948['xoltE'](_0x3de4d6['autoAcknowledged'],0x0)&&_0x3aa84d['push'](_0x6c8ce1(_0x3a1a54._0x21df1b)+_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x53e493)]+'\x20warning(s)');if(_0x3de4d6[_0x6c8ce1(_0x3a1a54._0x9b806b)]&&_0x3de4d6[_0x6c8ce1(0x10d)][_0x6c8ce1(_0x3a1a54._0x2bad64)]>0x0){_0x3aa84d[_0x6c8ce1(_0x3a1a54._0x38186a)]('',_0x1cf948['EQgAY']);for(const [_0x5f2c17,_0x2ba5a9]of _0x3de4d6['riskScores']){_0x3aa84d[_0x6c8ce1(0xe3)]('**'+_0x5f2c17+':**'),_0x3aa84d['push']((0x0,risk_scorer_1['formatRiskScore'])(_0x2ba5a9)),_0x3aa84d['push']('');}}return _0x3aa84d[_0x6c8ce1(0xfc)]('\x0a');}function mapRiskToSeverity(_0x39baa7){const _0x555a2e={_0x1fff60:0x108,_0x5d0a03:0xf5},_0x3b7bfb=_0x36c162,_0x309c02={};_0x309c02[_0x3b7bfb(_0x555a2e._0x1fff60)]=_0x3b7bfb(_0x555a2e._0x5d0a03),_0x309c02['aqjJN']='LOW';const _0x2b7fe3=_0x309c02;switch(_0x39baa7){case'CRITICAL':return'CRITICAL';case _0x2b7fe3[_0x3b7bfb(0x108)]:return _0x3b7bfb(0xf5);case'MEDIUM':return _0x3b7bfb(0xf1);case _0x2b7fe3['aqjJN']:return'LOW';default:return null;}}
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.gateCheck = gateCheck;
37
+ exports.formatGateResult = formatGateResult;
38
+ const path = __importStar(require("path"));
39
+ const server_1 = require("../web/server");
40
+ const change_coupling_1 = require("../git/change-coupling");
41
+ /**
42
+ * Detect circular dependencies using SCC data.
43
+ * Much faster and more complete than DFS-based cycle detection.
44
+ * Returns all cyclic SCCs that contain any of the specified files.
45
+ */
46
+ function detectCyclesWithSCC(files, graph) {
47
+ const scc = graph.scc;
48
+ if (!scc) {
49
+ // Fallback to old DFS if SCC data not available
50
+ return detectCyclesForFilesDFS(files, graph, 10);
51
+ }
52
+ const cycles = [];
53
+ const reportedSCCs = new Set();
54
+ for (const file of files) {
55
+ if (!graph.files.has(file))
56
+ continue;
57
+ const sccIndex = scc.nodeToComponent.get(file);
58
+ if (sccIndex === undefined)
59
+ continue;
60
+ const node = scc.condensed.nodes[sccIndex];
61
+ if (!node.isCyclic)
62
+ continue;
63
+ // Only report each cyclic SCC once
64
+ if (reportedSCCs.has(sccIndex))
65
+ continue;
66
+ reportedSCCs.add(sccIndex);
67
+ // Build a cycle representation: all files in the SCC form a cycle
68
+ // For display, show the circular path by appending the first file at the end
69
+ const cyclePath = [...node.files, node.files[0]];
70
+ cycles.push({
71
+ cycle: cyclePath,
72
+ file,
73
+ });
74
+ }
75
+ return cycles;
76
+ }
77
+ /**
78
+ * Also scan the entire graph for cyclic SCCs (not just specified files).
79
+ * Returns summary info about all cycles in the project.
80
+ */
81
+ function detectAllCycles(graph) {
82
+ const scc = graph.scc;
83
+ if (!scc)
84
+ return [];
85
+ const cycles = [];
86
+ for (const node of scc.condensed.nodes) {
87
+ if (!node.isCyclic)
88
+ continue;
89
+ const cyclePath = [...node.files, node.files[0]];
90
+ cycles.push({
91
+ cycle: cyclePath,
92
+ file: node.files[0],
93
+ });
94
+ }
95
+ return cycles;
96
+ }
97
+ /**
98
+ * Legacy DFS forward traversal from specified files to detect circular dependencies.
99
+ * Used as fallback when SCC data is not available.
100
+ */
101
+ function detectCyclesForFilesDFS(files, graph, maxCycles = 10) {
102
+ const cycles = [];
103
+ const globalVisited = new Set();
104
+ for (const startFile of files) {
105
+ if (!graph.files.has(startFile))
106
+ continue;
107
+ const stack = new Set();
108
+ const pathStack = [];
109
+ function dfs(file) {
110
+ if (cycles.length >= maxCycles)
111
+ return;
112
+ if (globalVisited.has(file))
113
+ return;
114
+ stack.add(file);
115
+ pathStack.push(file);
116
+ const deps = graph.forward.get(file) || [];
117
+ for (const dep of deps) {
118
+ if (cycles.length >= maxCycles)
119
+ break;
120
+ if (stack.has(dep)) {
121
+ // Back-edge found: cycle
122
+ const idx = pathStack.indexOf(dep);
123
+ if (idx >= 0) {
124
+ cycles.push({
125
+ cycle: [...pathStack.slice(idx), dep],
126
+ file: startFile,
127
+ });
128
+ }
129
+ }
130
+ else if (!globalVisited.has(dep)) {
131
+ dfs(dep);
132
+ }
133
+ }
134
+ stack.delete(file);
135
+ pathStack.pop();
136
+ }
137
+ dfs(startFile);
138
+ for (const f of stack)
139
+ globalVisited.add(f);
140
+ }
141
+ return cycles.slice(0, maxCycles);
142
+ }
143
+ // ── Gate Check ──
144
+ /**
145
+ * Run the build gate check.
146
+ * If `specifiedFiles` is provided, only warnings for those files are considered.
147
+ * Cycle detection uses SCC data when available (faster and more complete).
148
+ */
149
+ async function gateCheck(graph, specifiedFiles) {
150
+ const allWarnings = (0, server_1.getUnacknowledgedWarnings)();
151
+ const sccCount = graph.scc?.condensed.nodes.length;
152
+ const cyclicSCCs = graph.scc?.condensed.nodes.filter(n => n.isCyclic).length;
153
+ const stats = {
154
+ filesInGraph: graph.files.size,
155
+ unresolvedWarnings: allWarnings.length,
156
+ sccCount,
157
+ cyclicSCCs,
158
+ };
159
+ // Filter warnings to specified files if provided
160
+ const warnings = specifiedFiles
161
+ ? allWarnings.filter((w) => specifiedFiles.some((f) => w.file === f ||
162
+ f.endsWith(w.file) ||
163
+ w.file.endsWith(f.replace(/\\/g, "/"))))
164
+ : allWarnings;
165
+ const issues = [];
166
+ // 1. Check warnings by severity
167
+ for (const w of warnings) {
168
+ const severity = mapRiskToSeverity(w.riskLevel);
169
+ if (severity) {
170
+ issues.push({
171
+ file: w.file,
172
+ severity,
173
+ description: w.summary +
174
+ (w.brokenImports.length > 0
175
+ ? ` (broken imports: ${w.brokenImports.join(", ")})`
176
+ : ""),
177
+ });
178
+ }
179
+ }
180
+ // 2. Detect cycles using SCC (or fallback to DFS)
181
+ const filesToCheck = specifiedFiles || [];
182
+ const cycles = detectCyclesWithSCC(filesToCheck, graph);
183
+ for (const c of cycles) {
184
+ const cyclePath = c.cycle
185
+ .map((f) => path.relative(graph.sourceDir, f).replace(/\\/g, "/"))
186
+ .join(" -> ");
187
+ issues.push({
188
+ file: path.relative(graph.sourceDir, c.file).replace(/\\/g, "/"),
189
+ severity: "CRITICAL",
190
+ description: `Circular dependency detected (${c.cycle.length - 1} files): ${cyclePath}`,
191
+ });
192
+ }
193
+ // 3. Check if hub files were modified (simplified — no Pro scoring)
194
+ if (specifiedFiles) {
195
+ // Simple hub detection: files with most reverse dependents
196
+ const hubEntries = [];
197
+ for (const f of graph.files) {
198
+ const revDeps = graph.reverse.get(f) || [];
199
+ hubEntries.push({ file: f, count: revDeps.length });
200
+ }
201
+ hubEntries.sort((a, b) => b.count - a.count);
202
+ const top5 = hubEntries.slice(0, 5);
203
+ const hubPathSet = new Set(top5.map(h => path.relative(graph.sourceDir, h.file).replace(/\\/g, "/")));
204
+ for (const f of specifiedFiles) {
205
+ if (!graph.files.has(f))
206
+ continue;
207
+ const rel = path.relative(graph.sourceDir, f).replace(/\\/g, "/");
208
+ // Check if this file is a hub file
209
+ if (hubPathSet.has(rel)) {
210
+ const hub = top5.find(h => path.relative(graph.sourceDir, h.file).replace(/\\/g, "/") === rel);
211
+ if (hub) {
212
+ const riskLevel = hub.count >= 10 ? "HIGH" : hub.count >= 5 ? "MEDIUM" : "LOW";
213
+ issues.push({
214
+ file: rel,
215
+ severity: riskLevel === "HIGH" ? "HIGH" : "MEDIUM",
216
+ description: `Hub file modified (${hub.count} dependents, ${riskLevel} risk)`,
217
+ });
218
+ }
219
+ }
220
+ }
221
+ // 4. Check historical change coupling for modified files
222
+ try {
223
+ const couplingResult = await (0, change_coupling_1.mineGitHistory)(graph.projectRoot);
224
+ if (couplingResult.totalCommitsAnalyzed > 0) {
225
+ const modifiedSet = new Set(specifiedFiles.map((f) => path.relative(graph.projectRoot, f).replace(/\\/g, "/")));
226
+ for (const f of specifiedFiles) {
227
+ if (!graph.files.has(f))
228
+ continue;
229
+ const gitRelPath = path
230
+ .relative(graph.projectRoot, f)
231
+ .replace(/\\/g, "/");
232
+ const couplings = (0, change_coupling_1.getCoupledFiles)(gitRelPath, couplingResult);
233
+ for (const coupling of couplings) {
234
+ const otherFile = coupling.file1 === gitRelPath ? coupling.file2 : coupling.file1;
235
+ if (modifiedSet.has(otherFile))
236
+ continue;
237
+ const otherAbsolute = path.normalize(path.join(graph.projectRoot, otherFile));
238
+ const forwardDeps = graph.forward.get(f) || [];
239
+ const reverseDeps = graph.reverse.get(f) || [];
240
+ const isInGraph = forwardDeps.includes(otherAbsolute) ||
241
+ reverseDeps.includes(otherAbsolute);
242
+ if (isInGraph)
243
+ continue;
244
+ if (coupling.confidence < 0.3)
245
+ continue;
246
+ const severity = coupling.confidence >= 0.5 ? "MEDIUM" : "LOW";
247
+ const pct = Math.round(coupling.confidence * 100);
248
+ const rel = path.relative(graph.sourceDir, f).replace(/\\/g, "/");
249
+ issues.push({
250
+ file: rel,
251
+ severity,
252
+ description: `Historical coupling: ${otherFile} changes with this file in ${pct}% of commits (${coupling.coChangeCount} times) -- consider reviewing`,
253
+ });
254
+ }
255
+ }
256
+ }
257
+ }
258
+ catch {
259
+ // Non-critical: coupling analysis failure should not block build gate
260
+ }
261
+ }
262
+ // ── Determine verdict ──
263
+ const hasCritical = issues.some((i) => i.severity === "CRITICAL");
264
+ const highIssues = issues.filter((i) => i.severity === "HIGH");
265
+ const hasHighWithBroken = highIssues.length > 0 &&
266
+ warnings.some((w) => w.riskLevel === "HIGH" && w.brokenImports.length > 0);
267
+ const hasCycles = cycles.length > 0;
268
+ let verdict;
269
+ let statusLine;
270
+ let recommendation;
271
+ let autoAcknowledged = 0;
272
+ if (hasCritical || hasHighWithBroken || hasCycles) {
273
+ verdict = "FAIL";
274
+ const reasons = [];
275
+ if (hasCritical)
276
+ reasons.push("CRITICAL warnings");
277
+ if (hasHighWithBroken)
278
+ reasons.push("HIGH warnings with broken imports");
279
+ if (hasCycles)
280
+ reasons.push(`${cycles.length} circular dependency(ies)`);
281
+ statusLine = `BUILD BLOCKED — ${reasons.join(", ")}`;
282
+ recommendation =
283
+ "Fix the issues above before building. Use `check_warnings` for details, then `analyze_impact` on affected files.";
284
+ }
285
+ else if (highIssues.length > 0 ||
286
+ issues.some((i) => i.severity === "MEDIUM")) {
287
+ verdict = "WARN";
288
+ statusLine = `PROCEED WITH CAUTION — ${issues.length} issue(s) detected`;
289
+ recommendation =
290
+ "Review the issues. If you've verified they're safe, proceed with the build. Use `check_warnings acknowledge=true` to clear warnings.";
291
+ }
292
+ else {
293
+ verdict = "PASS";
294
+ statusLine = "All clear — safe to build";
295
+ recommendation = "No issues detected. You may proceed with build/deploy.";
296
+ // Auto-acknowledge warnings on PASS
297
+ autoAcknowledged = (0, server_1.acknowledgeWarnings)();
298
+ }
299
+ return {
300
+ verdict,
301
+ statusLine,
302
+ issues,
303
+ recommendation,
304
+ stats,
305
+ autoAcknowledged,
306
+ };
307
+ }
308
+ // ── Formatting ──
309
+ function formatGateResult(result) {
310
+ const icon = result.verdict === "PASS"
311
+ ? "✅"
312
+ : result.verdict === "WARN"
313
+ ? "⚠️"
314
+ : "🚫";
315
+ const lines = [
316
+ `## SYKE Build Gate — ${icon} ${result.verdict}`,
317
+ "",
318
+ "### Status",
319
+ result.statusLine,
320
+ ];
321
+ if (result.issues.length > 0) {
322
+ lines.push("", "### Issues");
323
+ for (const issue of result.issues) {
324
+ const issueIcon = issue.severity === "CRITICAL"
325
+ ? "🚫"
326
+ : issue.severity === "HIGH"
327
+ ? "🔴"
328
+ : issue.severity === "MEDIUM"
329
+ ? "🟡"
330
+ : "🔵";
331
+ lines.push(`- ${issueIcon} **[${issue.severity}]** ${issue.file}: ${issue.description}`);
332
+ }
333
+ }
334
+ lines.push("", "### Recommendation", result.recommendation);
335
+ lines.push("", "### Stats", `- Files in graph: ${result.stats.filesInGraph}`, `- Unresolved warnings: ${result.stats.unresolvedWarnings}`);
336
+ if (result.stats.sccCount !== undefined) {
337
+ lines.push(`- Strongly Connected Components: ${result.stats.sccCount}`);
338
+ }
339
+ if (result.stats.cyclicSCCs !== undefined && result.stats.cyclicSCCs > 0) {
340
+ lines.push(`- Circular dependency clusters: ${result.stats.cyclicSCCs}`);
341
+ }
342
+ if (result.autoAcknowledged > 0) {
343
+ lines.push(`- Auto-acknowledged: ${result.autoAcknowledged} warning(s)`);
344
+ }
345
+ return lines.join("\n");
346
+ }
347
+ // ── Helpers ──
348
+ function mapRiskToSeverity(riskLevel) {
349
+ switch (riskLevel) {
350
+ case "CRITICAL":
351
+ return "CRITICAL";
352
+ case "HIGH":
353
+ return "HIGH";
354
+ case "MEDIUM":
355
+ return "MEDIUM";
356
+ case "LOW":
357
+ return "LOW";
358
+ default:
359
+ return null; // SAFE → no issue
360
+ }
361
+ }