trimprompt 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/api-proxy.js +1 -1
- package/cache-manager.js +1 -1
- package/cache.js +1 -1
- package/ccr.js +1 -1
- package/cli.js +1 -1
- package/dashboard.js +1 -1
- package/executor.js +1 -1
- package/file-watcher.js +1 -1
- package/filters/devops.js +1 -1
- package/filters/generic.js +1 -1
- package/filters/git.js +1 -1
- package/filters/go.js +99 -1
- package/filters/index.js +185 -1
- package/filters/js.js +78 -1
- package/filters/python.js +130 -1
- package/filters/rust.js +115 -1
- package/filters/shell.js +395 -1
- package/hooks/claude-hook.js +79 -1
- package/mcp.js +132 -1
- package/package.json +1 -4
- package/proxy-conv.js +181 -1
- package/proxy-daemon.js +382 -1
- package/proxy-resp.js +1 -1
- package/redactor.js +1 -1
- package/seed.js +1 -1
- package/shims.js +1 -1
- package/simulate.js +1 -1
- package/sync.js +1 -1
- package/tracker.js +1 -1
- package/traffic-interceptor.js +1 -1
package/filters/shell.js
CHANGED
|
@@ -1 +1,395 @@
|
|
|
1
|
-
'use strict';const a0_0x4cd1fd=a0_0x5be4;(function(_0x3240fa,_0x401775){const _0x27c7ea=a0_0x5be4,_0x1cee05=_0x3240fa();while(!![]){try{const _0x1cdf6f=parseInt(_0x27c7ea(0x18a))/0x1+-parseInt(_0x27c7ea(0x1c6))/0x2*(parseInt(_0x27c7ea(0x181))/0x3)+-parseInt(_0x27c7ea(0x16f))/0x4*(-parseInt(_0x27c7ea(0x1da))/0x5)+parseInt(_0x27c7ea(0x1db))/0x6+-parseInt(_0x27c7ea(0x1ce))/0x7+parseInt(_0x27c7ea(0x17d))/0x8+parseInt(_0x27c7ea(0x1a3))/0x9*(parseInt(_0x27c7ea(0x1ad))/0xa);if(_0x1cdf6f===_0x401775)break;else _0x1cee05['push'](_0x1cee05['shift']());}catch(_0x548901){_0x1cee05['push'](_0x1cee05['shift']());}}}(a0_0x4ff3,0x40d91));function a0_0x5be4(_0x153dc8,_0x1d0602){_0x153dc8=_0x153dc8-0x147;const _0x4ff3ab=a0_0x4ff3();let _0x5be490=_0x4ff3ab[_0x153dc8];return _0x5be490;}var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x1f9124,_0x3c7da8,_0xf2c5d8,_0x90bc9e){const _0x18c669=a0_0x5be4;if(_0x90bc9e===undefined)_0x90bc9e=_0xf2c5d8;var _0x4c0f9a=Object[_0x18c669(0x184)](_0x3c7da8,_0xf2c5d8);(!_0x4c0f9a||(_0x18c669(0x179)in _0x4c0f9a?!_0x3c7da8['__esModule']:_0x4c0f9a[_0x18c669(0x149)]||_0x4c0f9a[_0x18c669(0x148)]))&&(_0x4c0f9a={'enumerable':!![],'get':function(){return _0x3c7da8[_0xf2c5d8];}}),Object[_0x18c669(0x17e)](_0x1f9124,_0x90bc9e,_0x4c0f9a);}:function(_0x4d8a63,_0x5d76e0,_0x468c65,_0x48c953){if(_0x48c953===undefined)_0x48c953=_0x468c65;_0x4d8a63[_0x48c953]=_0x5d76e0[_0x468c65];}),__setModuleDefault=this&&this[a0_0x4cd1fd(0x1a4)]||(Object['create']?function(_0x5e5c9e,_0x20a303){const _0x1f7df0=a0_0x4cd1fd;Object[_0x1f7df0(0x17e)](_0x5e5c9e,_0x1f7df0(0x1a0),{'enumerable':!![],'value':_0x20a303});}:function(_0x42db2b,_0xb4ba14){_0x42db2b['default']=_0xb4ba14;}),__importStar=this&&this['__importStar']||(function(){var _0x506f1f=function(_0x49a5fe){const _0x59b909=a0_0x5be4;return _0x506f1f=Object[_0x59b909(0x162)]||function(_0x166de3){const _0x656e09=_0x59b909;var _0x55503c=[];for(var _0x5c50d5 in _0x166de3)if(Object[_0x656e09(0x186)][_0x656e09(0x1bb)][_0x656e09(0x1d9)](_0x166de3,_0x5c50d5))_0x55503c[_0x55503c[_0x656e09(0x17a)]]=_0x5c50d5;return _0x55503c;},_0x506f1f(_0x49a5fe);};return function(_0xaa7ac4){const _0x28ab6f=a0_0x5be4;if(_0xaa7ac4&&_0xaa7ac4['__esModule'])return _0xaa7ac4;var _0x142a5b={};if(_0xaa7ac4!=null){for(var _0x54e202=_0x506f1f(_0xaa7ac4),_0x217019=0x0;_0x217019<_0x54e202[_0x28ab6f(0x17a)];_0x217019++)if(_0x54e202[_0x217019]!=='default')__createBinding(_0x142a5b,_0xaa7ac4,_0x54e202[_0x217019]);}return __setModuleDefault(_0x142a5b,_0xaa7ac4),_0x142a5b;};}());Object[a0_0x4cd1fd(0x17e)](exports,a0_0x4cd1fd(0x168),{'value':!![]}),exports['filterLs']=filterLs,exports['filterTree']=filterTree,exports[a0_0x4cd1fd(0x15f)]=filterCat,exports[a0_0x4cd1fd(0x1d4)]=filterGrep,exports[a0_0x4cd1fd(0x1c9)]=filterFind;const path=__importStar(require(a0_0x4cd1fd(0x16c))),generic_1=require('./generic'),tracker_1=require(a0_0x4cd1fd(0x163));function isFeatureEnabled(_0x2dd86b){const _0x41bae3=a0_0x4cd1fd;try{const _0x5ab439=tracker_1[_0x41bae3(0x175)][_0x41bae3(0x1ac)](),_0x2e3b7e=_0x5ab439[_0x41bae3(0x190)];if(!_0x2e3b7e||_0x2e3b7e[_0x2dd86b]===undefined)return!![];return _0x2e3b7e[_0x2dd86b]!==![];}catch{return!![];}}const LOCK_FILES=[a0_0x4cd1fd(0x177),a0_0x4cd1fd(0x1c3),a0_0x4cd1fd(0x1a8),'Cargo.lock',a0_0x4cd1fd(0x192),'poetry.lock',a0_0x4cd1fd(0x16b),a0_0x4cd1fd(0x1bf),a0_0x4cd1fd(0x166)],BINARY_EXTENSIONS=[a0_0x4cd1fd(0x1d5),a0_0x4cd1fd(0x1c0),a0_0x4cd1fd(0x155),'.wasm',a0_0x4cd1fd(0x197),a0_0x4cd1fd(0x195),'.jpeg','.gif',a0_0x4cd1fd(0x176),a0_0x4cd1fd(0x1a1),a0_0x4cd1fd(0x196),'.svg',a0_0x4cd1fd(0x14b),a0_0x4cd1fd(0x1aa),a0_0x4cd1fd(0x156),a0_0x4cd1fd(0x1d2),a0_0x4cd1fd(0x16a),a0_0x4cd1fd(0x1ca),a0_0x4cd1fd(0x1a7),'.rar','.exe',a0_0x4cd1fd(0x154),a0_0x4cd1fd(0x15e),a0_0x4cd1fd(0x1b3),'.bin','.dat',a0_0x4cd1fd(0x15b),a0_0x4cd1fd(0x19c),a0_0x4cd1fd(0x161),a0_0x4cd1fd(0x19b),a0_0x4cd1fd(0x159),'.ttf','.eot',a0_0x4cd1fd(0x1b1),a0_0x4cd1fd(0x18f),a0_0x4cd1fd(0x1c5),'.wav',a0_0x4cd1fd(0x15d),a0_0x4cd1fd(0x14a),a0_0x4cd1fd(0x1bd),a0_0x4cd1fd(0x191),a0_0x4cd1fd(0x1b0),a0_0x4cd1fd(0x188),'.o',a0_0x4cd1fd(0x1b8)];function extractFilename(_0x4059ef){const _0x2b1494=a0_0x4cd1fd,_0x3aeae1=_0x4059ef['trim']()['split'](/\s+/);for(let _0x5ac1e4=0x1;_0x5ac1e4<_0x3aeae1[_0x2b1494(0x17a)];_0x5ac1e4++){if(!_0x3aeae1[_0x5ac1e4][_0x2b1494(0x1a2)]('-'))return _0x3aeae1[_0x5ac1e4];}return null;}function filterLockFile(_0x676175,_0x3a4e40){const _0x3db4fc=a0_0x4cd1fd;try{const _0x9aa04e=path[_0x3db4fc(0x198)](_0x3a4e40)[_0x3db4fc(0x19d)]();if(!LOCK_FILES[_0x3db4fc(0x17b)](_0x58588a=>_0x9aa04e===_0x58588a[_0x3db4fc(0x19d)]()))return null;const _0x4f839e=_0x676175[_0x3db4fc(0x17a)];let _0x39f068=0x0;if(_0x9aa04e===_0x3db4fc(0x177))try{const _0x574744=JSON[_0x3db4fc(0x1c1)](_0x676175);_0x39f068=Object[_0x3db4fc(0x165)](_0x574744[_0x3db4fc(0x15a)]||_0x574744[_0x3db4fc(0x17f)]||{})[_0x3db4fc(0x17a)];}catch{_0x39f068=(_0x676175[_0x3db4fc(0x18e)](/"resolved":/g)||[])[_0x3db4fc(0x17a)];}else{if(_0x9aa04e===_0x3db4fc(0x1c3))_0x39f068=(_0x676175[_0x3db4fc(0x18e)](/^"?[^#\s][^:]*:$/gm)||[])[_0x3db4fc(0x17a)];else{if(_0x9aa04e===_0x3db4fc(0x182)||_0x9aa04e==='poetry.lock')_0x39f068=(_0x676175['match'](/\[\[package\]\]/g)||[])['length'];else{if(_0x9aa04e===_0x3db4fc(0x192))_0x39f068=Math[_0x3db4fc(0x1ab)](_0x676175['split']('\x0a')[_0x3db4fc(0x1ba)](_0x2bceba=>_0x2bceba[_0x3db4fc(0x199)]())[_0x3db4fc(0x17a)]/0x2);else{if(_0x9aa04e===_0x3db4fc(0x16b))try{_0x39f068=JSON[_0x3db4fc(0x1c1)](_0x676175)[_0x3db4fc(0x15a)]?.['length']||0x0;}catch{}else _0x9aa04e===_0x3db4fc(0x1a8)?_0x39f068=(_0x676175[_0x3db4fc(0x18e)](/^\s{2}['"@a-z]/gm)||[])[_0x3db4fc(0x17a)]:_0x39f068=_0x676175[_0x3db4fc(0x14e)]('\x0a')['filter'](_0x5ed265=>_0x5ed265['trim']())[_0x3db4fc(0x17a)];}}}}return _0x3db4fc(0x152)+path['basename'](_0x3a4e40)+':\x20'+_0x39f068+_0x3db4fc(0x14f)+_0x4f839e['toLocaleString']()+_0x3db4fc(0x1cb);}catch{return null;}}function filterBinaryOrMinified(_0x3d0ec5,_0x1003f8){const _0x4add87=a0_0x4cd1fd;try{if(_0x1003f8){const _0x52b99c=_0x1003f8['toLowerCase']();for(const _0x295fda of BINARY_EXTENSIONS){if(_0x52b99c[_0x4add87(0x1be)](_0x295fda))return'[binary/minified\x20file]\x20'+path['basename'](_0x1003f8)+',\x20'+_0x3d0ec5[_0x4add87(0x17a)][_0x4add87(0x172)]()+_0x4add87(0x1d7)+_0x295fda+_0x4add87(0x189);}}const _0x387ef5=_0x3d0ec5[_0x4add87(0x169)](0x0,0x3e8);let _0x28879c=0x0;for(let _0x4b761d=0x0;_0x4b761d<_0x387ef5[_0x4add87(0x17a)];_0x4b761d++){if(_0x387ef5[_0x4add87(0x1bc)](_0x4b761d)===0x0)_0x28879c++;}if(_0x28879c>0x0)return _0x4add87(0x1c2)+_0x3d0ec5[_0x4add87(0x17a)][_0x4add87(0x172)]()+_0x4add87(0x1a9);let _0x5689db=0x0;for(let _0x2accc6=0x0;_0x2accc6<_0x387ef5[_0x4add87(0x17a)];_0x2accc6++){const _0x25c1ef=_0x387ef5[_0x4add87(0x1bc)](_0x2accc6);if(_0x25c1ef<0x20&&_0x25c1ef!==0xa&&_0x25c1ef!==0xd&&_0x25c1ef!==0x9)_0x5689db++;}if(_0x387ef5[_0x4add87(0x17a)]>0x64&&_0x5689db>_0x387ef5[_0x4add87(0x17a)]*0.1)return _0x4add87(0x1c2)+_0x3d0ec5['length']['toLocaleString']()+_0x4add87(0x19e);const _0x2bb497=_0x3d0ec5[_0x4add87(0x14e)]('\x0a');if(_0x2bb497[_0x4add87(0x17a)]<=0x3&&_0x3d0ec5[_0x4add87(0x17a)]>0x1388)return'[minified\x20file]\x20'+_0x3d0ec5[_0x4add87(0x17a)][_0x4add87(0x172)]()+_0x4add87(0x1a6)+_0x2bb497['length']+'\x20line(s)\x20(content\x20omitted\x20—\x20not\x20human-readable)';return null;}catch{return null;}}function filterJsonMinify(_0x20e931){const _0x436cbf=a0_0x4cd1fd;try{const _0x48fc78=_0x20e931[_0x436cbf(0x199)]();if(!_0x48fc78[_0x436cbf(0x1a2)]('{')&&!_0x48fc78[_0x436cbf(0x1a2)]('['))return null;const _0x532fa6=_0x48fc78[_0x436cbf(0x14e)]('\x0a');if(_0x532fa6['length']<=0x14)return null;const _0x536ca9=JSON[_0x436cbf(0x1c1)](_0x48fc78),_0x2da8ea=JSON[_0x436cbf(0x174)](_0x536ca9);if(_0x2da8ea[_0x436cbf(0x17a)]<_0x48fc78[_0x436cbf(0x17a)])return _0x2da8ea;return null;}catch{return null;}}function filterLs(_0x5a7abc){const _0x1d57a6=a0_0x4cd1fd,_0x3e551b=_0x5a7abc[_0x1d57a6(0x14e)]('\x0a')[_0x1d57a6(0x1ba)](_0x2ca2db=>_0x2ca2db[_0x1d57a6(0x199)]()[_0x1d57a6(0x17a)]>0x0);if(_0x3e551b[_0x1d57a6(0x17a)]===0x0)return _0x1d57a6(0x178);if(_0x3e551b[_0x1d57a6(0x17a)]<=0x1e)return _0x5a7abc['trim']();const _0x2b8003=[],_0xf69e1e=[];for(const _0x20bf53 of _0x3e551b){const _0x1223fc=_0x20bf53[_0x1d57a6(0x199)]();if(_0x1223fc[_0x1d57a6(0x1a2)](_0x1d57a6(0x18c))||_0x1223fc[_0x1d57a6(0x1a2)]('d')&&_0x1223fc[_0x1d57a6(0x185)]('..'))continue;_0x1223fc[_0x1d57a6(0x1be)]('/')||_0x1223fc['startsWith']('d')&&_0x1223fc[_0x1d57a6(0x185)]('\x20')?_0x2b8003[_0x1d57a6(0x183)](_0x1223fc):_0xf69e1e['push'](_0x1223fc);}const _0x5d79b6=[];return _0x2b8003[_0x1d57a6(0x17a)]>0x0&&(_0x2b8003[_0x1d57a6(0x17a)]<=0xf?_0x5d79b6[_0x1d57a6(0x183)](..._0x2b8003):(_0x5d79b6['push'](..._0x2b8003[_0x1d57a6(0x164)](0x0,0xa)),_0x5d79b6[_0x1d57a6(0x183)](_0x1d57a6(0x1d6)+(_0x2b8003['length']-0xa)+_0x1d57a6(0x187)))),_0xf69e1e[_0x1d57a6(0x17a)]>0x0&&(_0xf69e1e['length']<=0x14?_0x5d79b6[_0x1d57a6(0x183)](..._0xf69e1e):(_0x5d79b6[_0x1d57a6(0x183)](..._0xf69e1e['slice'](0x0,0xf)),_0x5d79b6['push'](_0x1d57a6(0x1d6)+(_0xf69e1e[_0x1d57a6(0x17a)]-0xf)+_0x1d57a6(0x173)))),_0x5d79b6[_0x1d57a6(0x183)]('\x0a('+_0x2b8003[_0x1d57a6(0x17a)]+_0x1d57a6(0x158)+_0xf69e1e[_0x1d57a6(0x17a)]+_0x1d57a6(0x19f)),_0x5d79b6['join']('\x0a');}function filterTree(_0x155a3f){const _0x3da51b=a0_0x4cd1fd,_0x1653c9=_0x155a3f[_0x3da51b(0x14e)]('\x0a');if(_0x1653c9[_0x3da51b(0x17a)]<=0x32)return _0x155a3f['trim']();const _0x101c8a=[];let _0x2dbe81=0x0,_0x499596=0x0,_0x3252d0=0x0;for(const _0x16bda0 of _0x1653c9){const _0x505cd2=_0x16bda0['match'](/(\d+)\s+director/),_0x39334d=_0x16bda0[_0x3da51b(0x18e)](/(\d+)\s+file/);if(_0x505cd2)_0x3252d0=parseInt(_0x505cd2[0x1]);if(_0x39334d)_0x499596=parseInt(_0x39334d[0x1]);const _0x33c0f8=(_0x16bda0[_0x3da51b(0x18e)](/^[│├└\s─]+/)||[''])[0x0][_0x3da51b(0x17a)];_0x33c0f8<=0x4&&(_0x101c8a[_0x3da51b(0x183)](_0x16bda0),_0x2dbe81++);}return _0x1653c9[_0x3da51b(0x17a)]>_0x101c8a[_0x3da51b(0x17a)]&&_0x101c8a[_0x3da51b(0x183)](_0x3da51b(0x194)+_0x3252d0+_0x3da51b(0x158)+_0x499596+_0x3da51b(0x1c8)),_0x101c8a[_0x3da51b(0x1cf)]('\x0a');}function filterCat(_0x467830,_0x5e2e0b=''){const _0x425b34=a0_0x4cd1fd,_0x12c5dd=extractFilename(_0x5e2e0b);try{if(_0x12c5dd&&isFeatureEnabled(_0x425b34(0x1b2))){const _0x36c642=filterLockFile(_0x467830,_0x12c5dd);if(_0x36c642)return _0x36c642;}if(isFeatureEnabled(_0x425b34(0x16e))){const _0x4e1a84=filterBinaryOrMinified(_0x467830,_0x12c5dd);if(_0x4e1a84)return _0x4e1a84;}if(isFeatureEnabled('json_crusher')){const _0x180379=(0x0,generic_1['smartCrushJson'])(_0x467830);if(_0x180379)return _0x180379;}const _0xc8d2a8=filterJsonMinify(_0x467830);if(_0xc8d2a8)return _0xc8d2a8;if(_0x12c5dd&&isFeatureEnabled('skeleton')){const _0x3e3875=path[_0x425b34(0x150)](_0x12c5dd)['toLowerCase'](),_0x388dbc=[_0x425b34(0x193),_0x425b34(0x147),_0x425b34(0x170),_0x425b34(0x1d1),'.py',_0x425b34(0x1b9),_0x425b34(0x19a),_0x425b34(0x17c),'.c','.cpp',_0x425b34(0x1cd),_0x425b34(0x1b7),_0x425b34(0x1af),_0x425b34(0x15c)];if(_0x388dbc[_0x425b34(0x185)](_0x3e3875)){const _0x3af0ba=_0x467830['split']('\x0a');if(_0x3af0ba[_0x425b34(0x17a)]>0x64){const _0x4cb54a=[];_0x4cb54a['push'](_0x425b34(0x167)+path[_0x425b34(0x198)](_0x12c5dd)+'\x20('+_0x3af0ba['length']+'\x20lines)'),_0x4cb54a[_0x425b34(0x183)]('');for(const _0x411216 of _0x3af0ba){const _0x3a7069=_0x411216[_0x425b34(0x199)]();if(_0x3a7069[_0x425b34(0x1a2)]('import\x20')||_0x3a7069[_0x425b34(0x1a2)](_0x425b34(0x1c7))||_0x3a7069[_0x425b34(0x1a2)](_0x425b34(0x1cc))||_0x3a7069[_0x425b34(0x18e)](/=\s*require\(/)||_0x3a7069['startsWith'](_0x425b34(0x14c))||_0x3a7069[_0x425b34(0x1a2)](_0x425b34(0x151))||_0x3a7069[_0x425b34(0x1a2)](_0x425b34(0x180)))_0x4cb54a[_0x425b34(0x183)](_0x411216);else{if(_0x3a7069[_0x425b34(0x18e)](/^(export\s+)?(async\s+)?function\s+/)||_0x3a7069['match'](/^(export\s+)?(default\s+)?class\s+/)||_0x3a7069['match'](/^(export\s+)?(type|interface|enum)\s+/)||_0x3a7069['match'](/^(async\s+)?def\s+/)||_0x3a7069[_0x425b34(0x18e)](/^func\s+/)||_0x3a7069[_0x425b34(0x18e)](/^type\s+\w+\s+(struct|interface)/)||_0x3a7069[_0x425b34(0x18e)](/^(pub\s+)?(async\s+)?fn\s+/)||_0x3a7069[_0x425b34(0x18e)](/^(pub\s+)?(struct|enum|trait|impl)\s+/)||_0x3a7069[_0x425b34(0x18e)](/^(public|private|protected|static)\s+/))_0x4cb54a[_0x425b34(0x183)](_0x411216);else{if(_0x3a7069[_0x425b34(0x1a2)]('export\x20')&&!_0x3a7069[_0x425b34(0x185)]('=>')&&_0x3a7069['length']<0x78)_0x4cb54a[_0x425b34(0x183)](_0x411216);else _0x3a7069[_0x425b34(0x1a2)]('@')&&!_0x3a7069[_0x425b34(0x1a2)](_0x425b34(0x16d))&&!_0x3a7069['startsWith']('@return')&&_0x4cb54a[_0x425b34(0x183)](_0x411216);}}}_0x4cb54a[_0x425b34(0x183)](''),_0x4cb54a[_0x425b34(0x183)]('('+_0x3af0ba[_0x425b34(0x17a)]+_0x425b34(0x1b5)+(_0x4cb54a[_0x425b34(0x17a)]-0x2)+'\x20structural\x20lines\x20shown)');const _0x4e5d80=_0x4cb54a[_0x425b34(0x1cf)]('\x0a');if(_0x4e5d80[_0x425b34(0x17a)]<_0x467830['length'])return _0x4e5d80;}}}}catch{}let _0x516e47=(0x0,generic_1['collapseWhitespace'])(_0x467830);if(_0x12c5dd){const _0x117643=path[_0x425b34(0x150)](_0x12c5dd)[_0x425b34(0x19d)]();_0x516e47=(0x0,generic_1[_0x425b34(0x1a5)])(_0x516e47,_0x117643);}const _0x155551=_0x516e47['split']('\x0a');if(_0x155551[_0x425b34(0x17a)]<=0x64)return _0x516e47;const _0x15e502=[];return _0x15e502[_0x425b34(0x183)](..._0x155551[_0x425b34(0x164)](0x0,0x32)),_0x15e502['push']('\x0a...\x20['+(_0x155551[_0x425b34(0x17a)]-0x50)+_0x425b34(0x1d8)),_0x15e502[_0x425b34(0x183)](..._0x155551[_0x425b34(0x164)](-0x1e)),_0x15e502[_0x425b34(0x183)]('\x0a('+_0x155551[_0x425b34(0x17a)]+_0x425b34(0x160)),_0x15e502[_0x425b34(0x1cf)]('\x0a');}function filterGrep(_0x16c30d){const _0x2b9d79=a0_0x4cd1fd,_0x234b94=_0x16c30d['split']('\x0a')['filter'](_0x137e57=>_0x137e57[_0x2b9d79(0x199)]()[_0x2b9d79(0x17a)]>0x0);if(_0x234b94['length']===0x0)return _0x2b9d79(0x1b4);if(_0x234b94['length']<=0x32)return _0x16c30d[_0x2b9d79(0x199)]();const _0x41bbd5={},_0x1dd3ee=[];for(const _0xd806e0 of _0x234b94){const _0x28aa26=_0xd806e0[_0x2b9d79(0x157)](':');if(_0x28aa26>0x0&&_0x28aa26<0xc8){const _0x1d7ff2=_0xd806e0[_0x2b9d79(0x169)](0x0,_0x28aa26);if(_0x1d7ff2['includes']('/')||_0x1d7ff2['includes']('\x5c')||_0x1d7ff2[_0x2b9d79(0x185)]('.')){if(!_0x41bbd5[_0x1d7ff2])_0x41bbd5[_0x1d7ff2]=[];_0x41bbd5[_0x1d7ff2][_0x2b9d79(0x183)](_0xd806e0['substring'](_0x28aa26+0x1)[_0x2b9d79(0x199)]());continue;}}_0x1dd3ee['push'](_0xd806e0);}const _0x305475=[],_0x108f6d=Object[_0x2b9d79(0x165)](_0x41bbd5);if(_0x108f6d[_0x2b9d79(0x17a)]>0x0){const _0x18f8e3=0x14,_0x4b0b02=_0x108f6d[_0x2b9d79(0x164)](0x0,_0x18f8e3);for(const _0xb048bb of _0x4b0b02){const _0x9675e8=_0x41bbd5[_0xb048bb];if(_0x9675e8['length']<=0x3)for(const _0x4d42e1 of _0x9675e8){_0x305475['push'](_0xb048bb+':\x20'+_0x4d42e1);}else _0x305475[_0x2b9d79(0x183)](_0xb048bb+':\x20'+_0x9675e8[0x0]),_0x305475[_0x2b9d79(0x183)](_0xb048bb+':\x20...\x20('+_0x9675e8['length']+_0x2b9d79(0x171));}_0x108f6d['length']>_0x18f8e3&&_0x305475[_0x2b9d79(0x183)]('...\x20+'+(_0x108f6d[_0x2b9d79(0x17a)]-_0x18f8e3)+_0x2b9d79(0x18d));}if(_0x1dd3ee['length']>0x0){const _0x45dd4b=0x1e;_0x305475[_0x2b9d79(0x183)](..._0x1dd3ee[_0x2b9d79(0x164)](0x0,_0x45dd4b)),_0x1dd3ee[_0x2b9d79(0x17a)]>_0x45dd4b&&_0x305475['push'](_0x2b9d79(0x1d6)+(_0x1dd3ee[_0x2b9d79(0x17a)]-_0x45dd4b)+_0x2b9d79(0x1ae));}const _0x2abf4f=_0x234b94[_0x2b9d79(0x17a)];return _0x305475[_0x2b9d79(0x183)]('\x0a('+_0x2abf4f+_0x2b9d79(0x14d)+(_0x108f6d[_0x2b9d79(0x17a)]||'?')+_0x2b9d79(0x19f)),_0x305475[_0x2b9d79(0x1cf)]('\x0a');}function a0_0x4ff3(){const _0x1a93c6=['.db','toLowerCase','\x20chars\x20(high\x20non-printable\x20ratio\x20—\x20content\x20omitted)','\x20files)','default','.bmp','startsWith','387wWUbKc','__setModuleDefault','stripComments','\x20chars\x20across\x20','.7z','pnpm-lock.yaml','\x20chars\x20(contains\x20null\x20bytes\x20—\x20binary\x20content\x20omitted)','.zip','floor','getConfig','27970ztZHLY','\x20more\x20matches','.swift','.pyo','.otf','lock','.dylib','No\x20matches\x20found','\x20lines\x20total,\x20','entries','.rb','.obj','.go','filter','hasOwnProperty','charCodeAt','.webm','endsWith','Gemfile.lock','.min.css','parse','[binary\x20file]\x20','yarn.lock','/\x20(','.mp4','2VdKRqQ','from\x20','\x20files\x20total\x20—\x20deep\x20entries\x20truncated)','filterFind','.bz2','\x20chars\x20(content\x20omitted\x20—\x20lock\x20files\x20are\x20not\x20useful\x20for\x20LLM\x20context)','require(','.cs','3126277txsrFH','join','No\x20files\x20found','.jsx','.tgz','sort','filterGrep','.min.js','...\x20+','\x20chars,\x20type:\x20','\x20lines\x20truncated]\x20...\x0a','call','83890PAoFIe','774912AdpHnU','.js','configurable','writable','.mov','.pdf','#include\x20','\x20matches\x20across\x20','split','\x20dependencies,\x20','extname','use\x20','[lock\x20file]\x20','\x20\x20...\x20+','.dll','.map','.tar.gz','indexOf','\x20directories,\x20','.woff2','packages','.sqlite','.kt','.avi','.so','filterCat','\x20lines\x20total)','.sqlite3','getOwnPropertyNames','../tracker','slice','keys','bun.lockb','[code\x20skeleton]\x20','__esModule','substring','.gz','composer.lock','path','@param','binary','120NioCLD','.tsx','\x20matches\x20in\x20this\x20file)','toLocaleString','\x20more\x20files','stringify','tracker','.ico','package-lock.json','Empty\x20directory','get','length','some','.java','2517808YRuZHM','defineProperty','dependencies','package\x20','1437027qRuHWK','cargo.lock','push','getOwnPropertyDescriptor','includes','prototype','\x20more\x20directories','.class','\x20(content\x20omitted\x20—\x20not\x20useful\x20for\x20LLM\x20context)','123748iaDVEF','\x20directories','total\x20','\x20more\x20files\x20with\x20matches','match','.mp3','features_enabled','.pyc','go.sum','.ts','\x0a...\x20(','.jpg','.webp','.png','basename','trim','.rs','.woff'];a0_0x4ff3=function(){return _0x1a93c6;};return a0_0x4ff3();}function filterFind(_0x3ed5b1){const _0x1dca8e=a0_0x4cd1fd,_0x2e92f5=_0x3ed5b1[_0x1dca8e(0x14e)]('\x0a')[_0x1dca8e(0x1ba)](_0x272e10=>_0x272e10[_0x1dca8e(0x199)]()[_0x1dca8e(0x17a)]>0x0);if(_0x2e92f5[_0x1dca8e(0x17a)]===0x0)return _0x1dca8e(0x1d0);if(_0x2e92f5[_0x1dca8e(0x17a)]<=0x32)return _0x3ed5b1[_0x1dca8e(0x199)]();const _0x2bb11e={};for(const _0x13b1f8 of _0x2e92f5){const _0x13cefd=path['dirname'](_0x13b1f8[_0x1dca8e(0x199)]())||'.';_0x2bb11e[_0x13cefd]=(_0x2bb11e[_0x13cefd]||0x0)+0x1;}const _0x3b1649=Object[_0x1dca8e(0x1b6)](_0x2bb11e)[_0x1dca8e(0x1d3)]((_0x133945,_0x16fa56)=>_0x16fa56[0x1]-_0x133945[0x1]),_0x65912f=[_0x2e92f5[_0x1dca8e(0x17a)]+'\x20files\x20found\x20across\x20'+_0x3b1649['length']+_0x1dca8e(0x18b),''],_0x1b1923=0x1e;for(const [_0x296b8a,_0x966490]of _0x3b1649[_0x1dca8e(0x164)](0x0,_0x1b1923)){_0x65912f['push']('\x20\x20'+_0x296b8a+_0x1dca8e(0x1c4)+_0x966490+_0x1dca8e(0x19f));}return _0x3b1649[_0x1dca8e(0x17a)]>_0x1b1923&&_0x65912f[_0x1dca8e(0x183)](_0x1dca8e(0x153)+(_0x3b1649[_0x1dca8e(0x17a)]-_0x1b1923)+_0x1dca8e(0x187)),_0x65912f[_0x1dca8e(0x1cf)]('\x0a');}
|
|
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.filterLs = filterLs;
|
|
37
|
+
exports.filterTree = filterTree;
|
|
38
|
+
exports.filterCat = filterCat;
|
|
39
|
+
exports.filterGrep = filterGrep;
|
|
40
|
+
exports.filterFind = filterFind;
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const generic_1 = require("./generic");
|
|
43
|
+
const tracker_1 = require("../tracker");
|
|
44
|
+
function isFeatureEnabled(key) {
|
|
45
|
+
try {
|
|
46
|
+
const config = tracker_1.tracker.getConfig();
|
|
47
|
+
const fe = config.features_enabled;
|
|
48
|
+
if (!fe || fe[key] === undefined)
|
|
49
|
+
return true;
|
|
50
|
+
return fe[key] !== false;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const LOCK_FILES = [
|
|
57
|
+
'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'Cargo.lock',
|
|
58
|
+
'go.sum', 'poetry.lock', 'composer.lock', 'Gemfile.lock', 'bun.lockb'
|
|
59
|
+
];
|
|
60
|
+
const BINARY_EXTENSIONS = [
|
|
61
|
+
'.min.js', '.min.css', '.map', '.wasm',
|
|
62
|
+
'.png', '.jpg', '.jpeg', '.gif', '.ico', '.bmp', '.webp', '.svg',
|
|
63
|
+
'.pdf', '.zip', '.tar.gz', '.tgz', '.gz', '.bz2', '.7z', '.rar',
|
|
64
|
+
'.exe', '.dll', '.so', '.dylib', '.bin', '.dat',
|
|
65
|
+
'.sqlite', '.db', '.sqlite3',
|
|
66
|
+
'.woff', '.woff2', '.ttf', '.eot', '.otf',
|
|
67
|
+
'.mp3', '.mp4', '.wav', '.avi', '.mov', '.webm',
|
|
68
|
+
'.pyc', '.pyo', '.class', '.o', '.obj'
|
|
69
|
+
];
|
|
70
|
+
function extractFilename(command) {
|
|
71
|
+
const parts = command.trim().split(/\s+/);
|
|
72
|
+
for (let i = 1; i < parts.length; i++) {
|
|
73
|
+
if (!parts[i].startsWith('-'))
|
|
74
|
+
return parts[i];
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function filterLockFile(stdout, filename) {
|
|
79
|
+
try {
|
|
80
|
+
const base = path.basename(filename).toLowerCase();
|
|
81
|
+
if (!LOCK_FILES.some(lf => base === lf.toLowerCase()))
|
|
82
|
+
return null;
|
|
83
|
+
const size = stdout.length;
|
|
84
|
+
let depCount = 0;
|
|
85
|
+
if (base === 'package-lock.json') {
|
|
86
|
+
try {
|
|
87
|
+
const parsed = JSON.parse(stdout);
|
|
88
|
+
depCount = Object.keys(parsed.packages || parsed.dependencies || {}).length;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
depCount = (stdout.match(/"resolved":/g) || []).length;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (base === 'yarn.lock') {
|
|
95
|
+
depCount = (stdout.match(/^"?[^#\s][^:]*:$/gm) || []).length;
|
|
96
|
+
}
|
|
97
|
+
else if (base === 'cargo.lock' || base === 'poetry.lock') {
|
|
98
|
+
depCount = (stdout.match(/\[\[package\]\]/g) || []).length;
|
|
99
|
+
}
|
|
100
|
+
else if (base === 'go.sum') {
|
|
101
|
+
depCount = Math.floor(stdout.split('\n').filter(l => l.trim()).length / 2);
|
|
102
|
+
}
|
|
103
|
+
else if (base === 'composer.lock') {
|
|
104
|
+
try {
|
|
105
|
+
depCount = JSON.parse(stdout).packages?.length || 0;
|
|
106
|
+
}
|
|
107
|
+
catch { }
|
|
108
|
+
}
|
|
109
|
+
else if (base === 'pnpm-lock.yaml') {
|
|
110
|
+
depCount = (stdout.match(/^\s{2}['"@a-z]/gm) || []).length;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
depCount = stdout.split('\n').filter(l => l.trim()).length;
|
|
114
|
+
}
|
|
115
|
+
return `[lock file] ${path.basename(filename)}: ${depCount} dependencies, ${size.toLocaleString()} chars (content omitted — lock files are not useful for LLM context)`;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function filterBinaryOrMinified(stdout, filename) {
|
|
122
|
+
try {
|
|
123
|
+
if (filename) {
|
|
124
|
+
const lower = filename.toLowerCase();
|
|
125
|
+
for (const ext of BINARY_EXTENSIONS) {
|
|
126
|
+
if (lower.endsWith(ext)) {
|
|
127
|
+
return `[binary/minified file] ${path.basename(filename)}, ${stdout.length.toLocaleString()} chars, type: ${ext} (content omitted — not useful for LLM context)`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const sample = stdout.substring(0, 1000);
|
|
132
|
+
let nullCount = 0;
|
|
133
|
+
for (let i = 0; i < sample.length; i++) {
|
|
134
|
+
if (sample.charCodeAt(i) === 0)
|
|
135
|
+
nullCount++;
|
|
136
|
+
}
|
|
137
|
+
if (nullCount > 0) {
|
|
138
|
+
return `[binary file] ${stdout.length.toLocaleString()} chars (contains null bytes — binary content omitted)`;
|
|
139
|
+
}
|
|
140
|
+
let nonPrintable = 0;
|
|
141
|
+
for (let i = 0; i < sample.length; i++) {
|
|
142
|
+
const code = sample.charCodeAt(i);
|
|
143
|
+
if (code < 32 && code !== 10 && code !== 13 && code !== 9)
|
|
144
|
+
nonPrintable++;
|
|
145
|
+
}
|
|
146
|
+
if (sample.length > 100 && nonPrintable > sample.length * 0.1) {
|
|
147
|
+
return `[binary file] ${stdout.length.toLocaleString()} chars (high non-printable ratio — content omitted)`;
|
|
148
|
+
}
|
|
149
|
+
const lines = stdout.split('\n');
|
|
150
|
+
if (lines.length <= 3 && stdout.length > 5000) {
|
|
151
|
+
return `[minified file] ${stdout.length.toLocaleString()} chars across ${lines.length} line(s) (content omitted — not human-readable)`;
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function filterJsonMinify(stdout) {
|
|
160
|
+
try {
|
|
161
|
+
const trimmed = stdout.trim();
|
|
162
|
+
if (!trimmed.startsWith('{') && !trimmed.startsWith('['))
|
|
163
|
+
return null;
|
|
164
|
+
const lines = trimmed.split('\n');
|
|
165
|
+
if (lines.length <= 20)
|
|
166
|
+
return null;
|
|
167
|
+
const parsed = JSON.parse(trimmed);
|
|
168
|
+
const minified = JSON.stringify(parsed);
|
|
169
|
+
if (minified.length < trimmed.length)
|
|
170
|
+
return minified;
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function filterLs(stdout) {
|
|
178
|
+
const lines = stdout.split('\n').filter(l => l.trim().length > 0);
|
|
179
|
+
if (lines.length === 0)
|
|
180
|
+
return "Empty directory";
|
|
181
|
+
if (lines.length <= 30)
|
|
182
|
+
return stdout.trim();
|
|
183
|
+
const dirs = [];
|
|
184
|
+
const files = [];
|
|
185
|
+
for (const line of lines) {
|
|
186
|
+
const trimmed = line.trim();
|
|
187
|
+
if (trimmed.startsWith('total ') || trimmed.startsWith('d') && trimmed.includes('..'))
|
|
188
|
+
continue;
|
|
189
|
+
if (trimmed.endsWith('/') || (trimmed.startsWith('d') && trimmed.includes(' '))) {
|
|
190
|
+
dirs.push(trimmed);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
files.push(trimmed);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const result = [];
|
|
197
|
+
if (dirs.length > 0) {
|
|
198
|
+
if (dirs.length <= 15) {
|
|
199
|
+
result.push(...dirs);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
result.push(...dirs.slice(0, 10));
|
|
203
|
+
result.push(`... +${dirs.length - 10} more directories`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (files.length > 0) {
|
|
207
|
+
if (files.length <= 20) {
|
|
208
|
+
result.push(...files);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
result.push(...files.slice(0, 15));
|
|
212
|
+
result.push(`... +${files.length - 15} more files`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
result.push(`\n(${dirs.length} directories, ${files.length} files)`);
|
|
216
|
+
return result.join('\n');
|
|
217
|
+
}
|
|
218
|
+
function filterTree(stdout) {
|
|
219
|
+
const lines = stdout.split('\n');
|
|
220
|
+
if (lines.length <= 50)
|
|
221
|
+
return stdout.trim();
|
|
222
|
+
const result = [];
|
|
223
|
+
let depth0Count = 0;
|
|
224
|
+
let totalFiles = 0;
|
|
225
|
+
let totalDirs = 0;
|
|
226
|
+
for (const line of lines) {
|
|
227
|
+
const summaryMatch = line.match(/(\d+)\s+director/);
|
|
228
|
+
const fileMatch = line.match(/(\d+)\s+file/);
|
|
229
|
+
if (summaryMatch)
|
|
230
|
+
totalDirs = parseInt(summaryMatch[1]);
|
|
231
|
+
if (fileMatch)
|
|
232
|
+
totalFiles = parseInt(fileMatch[1]);
|
|
233
|
+
const depth = (line.match(/^[│├└\s─]+/) || [''])[0].length;
|
|
234
|
+
if (depth <= 4) {
|
|
235
|
+
result.push(line);
|
|
236
|
+
depth0Count++;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (lines.length > result.length) {
|
|
240
|
+
result.push(`\n... (${totalDirs} directories, ${totalFiles} files total — deep entries truncated)`);
|
|
241
|
+
}
|
|
242
|
+
return result.join('\n');
|
|
243
|
+
}
|
|
244
|
+
function filterCat(stdout, command = '') {
|
|
245
|
+
const filename = extractFilename(command);
|
|
246
|
+
try {
|
|
247
|
+
if (filename && isFeatureEnabled('lock')) {
|
|
248
|
+
const lockResult = filterLockFile(stdout, filename);
|
|
249
|
+
if (lockResult)
|
|
250
|
+
return lockResult;
|
|
251
|
+
}
|
|
252
|
+
if (isFeatureEnabled('binary')) {
|
|
253
|
+
const binaryResult = filterBinaryOrMinified(stdout, filename);
|
|
254
|
+
if (binaryResult)
|
|
255
|
+
return binaryResult;
|
|
256
|
+
}
|
|
257
|
+
if (isFeatureEnabled('json_crusher')) {
|
|
258
|
+
const crushed = (0, generic_1.smartCrushJson)(stdout);
|
|
259
|
+
if (crushed)
|
|
260
|
+
return crushed;
|
|
261
|
+
}
|
|
262
|
+
const jsonResult = filterJsonMinify(stdout);
|
|
263
|
+
if (jsonResult)
|
|
264
|
+
return jsonResult;
|
|
265
|
+
if (filename && isFeatureEnabled('skeleton')) {
|
|
266
|
+
const ext = path.extname(filename).toLowerCase();
|
|
267
|
+
const codeExts = ['.ts', '.js', '.tsx', '.jsx', '.py', '.go', '.rs', '.java', '.c', '.cpp', '.cs', '.rb', '.swift', '.kt'];
|
|
268
|
+
if (codeExts.includes(ext)) {
|
|
269
|
+
const lines = stdout.split('\n');
|
|
270
|
+
if (lines.length > 100) {
|
|
271
|
+
const skeleton = [];
|
|
272
|
+
skeleton.push(`[code skeleton] ${path.basename(filename)} (${lines.length} lines)`);
|
|
273
|
+
skeleton.push('');
|
|
274
|
+
for (const line of lines) {
|
|
275
|
+
const t = line.trim();
|
|
276
|
+
if (t.startsWith('import ') || t.startsWith('from ') || t.startsWith('require(') ||
|
|
277
|
+
t.match(/=\s*require\(/) || t.startsWith('#include ') || t.startsWith('use ') ||
|
|
278
|
+
t.startsWith('package ')) {
|
|
279
|
+
skeleton.push(line);
|
|
280
|
+
}
|
|
281
|
+
else if (t.match(/^(export\s+)?(async\s+)?function\s+/) || t.match(/^(export\s+)?(default\s+)?class\s+/) ||
|
|
282
|
+
t.match(/^(export\s+)?(type|interface|enum)\s+/) || t.match(/^(async\s+)?def\s+/) ||
|
|
283
|
+
t.match(/^func\s+/) || t.match(/^type\s+\w+\s+(struct|interface)/) ||
|
|
284
|
+
t.match(/^(pub\s+)?(async\s+)?fn\s+/) || t.match(/^(pub\s+)?(struct|enum|trait|impl)\s+/) ||
|
|
285
|
+
t.match(/^(public|private|protected|static)\s+/)) {
|
|
286
|
+
skeleton.push(line);
|
|
287
|
+
}
|
|
288
|
+
else if (t.startsWith('export ') && !t.includes('=>') && t.length < 120) {
|
|
289
|
+
skeleton.push(line);
|
|
290
|
+
}
|
|
291
|
+
else if (t.startsWith('@') && !t.startsWith('@param') && !t.startsWith('@return')) {
|
|
292
|
+
skeleton.push(line);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
skeleton.push('');
|
|
296
|
+
skeleton.push(`(${lines.length} lines total, ${skeleton.length - 2} structural lines shown)`);
|
|
297
|
+
const skeletonResult = skeleton.join('\n');
|
|
298
|
+
if (skeletonResult.length < stdout.length)
|
|
299
|
+
return skeletonResult;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
}
|
|
306
|
+
let processed = (0, generic_1.collapseWhitespace)(stdout);
|
|
307
|
+
if (filename) {
|
|
308
|
+
const ext = path.extname(filename).toLowerCase();
|
|
309
|
+
processed = (0, generic_1.stripComments)(processed, ext);
|
|
310
|
+
}
|
|
311
|
+
const lines = processed.split('\n');
|
|
312
|
+
if (lines.length <= 100)
|
|
313
|
+
return processed;
|
|
314
|
+
const result = [];
|
|
315
|
+
result.push(...lines.slice(0, 50));
|
|
316
|
+
result.push(`\n... [${lines.length - 80} lines truncated] ...\n`);
|
|
317
|
+
result.push(...lines.slice(-30));
|
|
318
|
+
result.push(`\n(${lines.length} lines total)`);
|
|
319
|
+
return result.join('\n');
|
|
320
|
+
}
|
|
321
|
+
function filterGrep(stdout) {
|
|
322
|
+
const lines = stdout.split('\n').filter(l => l.trim().length > 0);
|
|
323
|
+
if (lines.length === 0)
|
|
324
|
+
return "No matches found";
|
|
325
|
+
if (lines.length <= 50)
|
|
326
|
+
return stdout.trim();
|
|
327
|
+
const fileGroups = {};
|
|
328
|
+
const ungrouped = [];
|
|
329
|
+
for (const line of lines) {
|
|
330
|
+
const colonIdx = line.indexOf(':');
|
|
331
|
+
if (colonIdx > 0 && colonIdx < 200) {
|
|
332
|
+
const prefix = line.substring(0, colonIdx);
|
|
333
|
+
if (prefix.includes('/') || prefix.includes('\\') || prefix.includes('.')) {
|
|
334
|
+
if (!fileGroups[prefix])
|
|
335
|
+
fileGroups[prefix] = [];
|
|
336
|
+
fileGroups[prefix].push(line.substring(colonIdx + 1).trim());
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
ungrouped.push(line);
|
|
341
|
+
}
|
|
342
|
+
const result = [];
|
|
343
|
+
const fileKeys = Object.keys(fileGroups);
|
|
344
|
+
if (fileKeys.length > 0) {
|
|
345
|
+
const maxFiles = 20;
|
|
346
|
+
const shownFiles = fileKeys.slice(0, maxFiles);
|
|
347
|
+
for (const file of shownFiles) {
|
|
348
|
+
const matches = fileGroups[file];
|
|
349
|
+
if (matches.length <= 3) {
|
|
350
|
+
for (const m of matches) {
|
|
351
|
+
result.push(`${file}: ${m}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
result.push(`${file}: ${matches[0]}`);
|
|
356
|
+
result.push(`${file}: ... (${matches.length} matches in this file)`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (fileKeys.length > maxFiles) {
|
|
360
|
+
result.push(`... +${fileKeys.length - maxFiles} more files with matches`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (ungrouped.length > 0) {
|
|
364
|
+
const maxUngrouped = 30;
|
|
365
|
+
result.push(...ungrouped.slice(0, maxUngrouped));
|
|
366
|
+
if (ungrouped.length > maxUngrouped) {
|
|
367
|
+
result.push(`... +${ungrouped.length - maxUngrouped} more matches`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const totalMatches = lines.length;
|
|
371
|
+
result.push(`\n(${totalMatches} matches across ${fileKeys.length || '?'} files)`);
|
|
372
|
+
return result.join('\n');
|
|
373
|
+
}
|
|
374
|
+
function filterFind(stdout) {
|
|
375
|
+
const lines = stdout.split('\n').filter(l => l.trim().length > 0);
|
|
376
|
+
if (lines.length === 0)
|
|
377
|
+
return "No files found";
|
|
378
|
+
if (lines.length <= 50)
|
|
379
|
+
return stdout.trim();
|
|
380
|
+
const dirGroups = {};
|
|
381
|
+
for (const line of lines) {
|
|
382
|
+
const dir = path.dirname(line.trim()) || '.';
|
|
383
|
+
dirGroups[dir] = (dirGroups[dir] || 0) + 1;
|
|
384
|
+
}
|
|
385
|
+
const sorted = Object.entries(dirGroups).sort((a, b) => b[1] - a[1]);
|
|
386
|
+
const result = [`${lines.length} files found across ${sorted.length} directories`, ''];
|
|
387
|
+
const maxDirs = 30;
|
|
388
|
+
for (const [dir, count] of sorted.slice(0, maxDirs)) {
|
|
389
|
+
result.push(` ${dir}/ (${count} files)`);
|
|
390
|
+
}
|
|
391
|
+
if (sorted.length > maxDirs) {
|
|
392
|
+
result.push(` ... +${sorted.length - maxDirs} more directories`);
|
|
393
|
+
}
|
|
394
|
+
return result.join('\n');
|
|
395
|
+
}
|
package/hooks/claude-hook.js
CHANGED
|
@@ -1 +1,79 @@
|
|
|
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.installClaudeHooks = installClaudeHooks;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
function installClaudeHooks() {
|
|
41
|
+
try {
|
|
42
|
+
const claudeHooksDir = path.join(os.homedir(), '.claude', 'hooks');
|
|
43
|
+
if (!fs.existsSync(claudeHooksDir)) {
|
|
44
|
+
fs.mkdirSync(claudeHooksDir, { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
const hookScriptPath = path.join(claudeHooksDir, 'post_tool_use.js');
|
|
47
|
+
const hookCode = `// TrimPrompt Native PostToolUse Hook for Claude Code
|
|
48
|
+
const fs = require('fs');
|
|
49
|
+
const path = require('path');
|
|
50
|
+
const os = require('os');
|
|
51
|
+
|
|
52
|
+
module.exports = async function postToolUse(event) {
|
|
53
|
+
try {
|
|
54
|
+
if (!event || !event.result) return event;
|
|
55
|
+
let contentStr = typeof event.result === 'string' ? event.result : JSON.stringify(event.result);
|
|
56
|
+
if (contentStr.length > 500) {
|
|
57
|
+
const cacheDir = path.join(os.homedir(), '.trimprompt', 'cache');
|
|
58
|
+
if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, { recursive: true });
|
|
59
|
+
const chunkId = 'chunk_' + Math.random().toString(36).substring(2, 11);
|
|
60
|
+
fs.writeFileSync(path.join(cacheDir, chunkId + '.json'), JSON.stringify({ raw_payload: contentStr, timestamp: new Date().toISOString() }));
|
|
61
|
+
|
|
62
|
+
const snippet = contentStr.substring(0, 200).replace(/\\n/g, ' ');
|
|
63
|
+
const replacement = \`> [!NOTE]\\n> **[TrimPrompt Context Offloaded]** Raw tool output (\${contentStr.length.toLocaleString()} chars) side-cached locally.\\n> Preview: \${snippet}...\\n> Retrieve raw: \`trim retrieve \${chunkId}\`\`;
|
|
64
|
+
|
|
65
|
+
if (typeof event.result === 'string') {
|
|
66
|
+
event.result = replacement;
|
|
67
|
+
} else if (event.result && typeof event.result === 'object') {
|
|
68
|
+
event.result.content = replacement;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (e) {}
|
|
72
|
+
return event;
|
|
73
|
+
};
|
|
74
|
+
`;
|
|
75
|
+
fs.writeFileSync(hookScriptPath, hookCode, 'utf8');
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
}
|
|
79
|
+
}
|