trimprompt 1.0.29 → 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/filters/shell.js CHANGED
@@ -1 +1,395 @@
1
- 'use strict';const a0_0x2e4863=a0_0x32be;function a0_0xb0c6(){const _0x6ef7b8=['.ico','\x20line(s)\x20(content\x20omitted\x20—\x20not\x20human-readable)','default','Cargo.lock','import\x20','filterFind','defineProperty','.class','hasOwnProperty','go.sum','.avi','\x20files)','poetry.lock','dirname','packages','configurable','.cpp','some','.woff','extname','.zip','1040639KlJLdg','require(','.svg','getOwnPropertyDescriptor','\x20\x20...\x20+','.bmp','pnpm-lock.yaml','.go','.woff2','skeleton','\x20chars\x20(content\x20omitted\x20—\x20lock\x20files\x20are\x20not\x20useful\x20for\x20LLM\x20context)','@param','split','yarn.lock','collapseWhitespace','composer.lock','.ts','.tar.gz','\x20structural\x20lines\x20shown)','7477677eJDhpE','258671CZthoQ','.jsx','.sqlite3','/\x20(','.db','startsWith','.bz2','\x0a...\x20[','.rs','.jpeg','25293920CLaBvT','.webp','.bin','[lock\x20file]\x20','../tracker','\x0a...\x20(','@return','\x20dependencies,\x20','sort','charCodeAt','./generic','bun.lockb','create','slice','[code\x20skeleton]\x20','234IxYzju','package-lock.json','.cs','\x20more\x20directories','trim','match','stripComments','includes','lock','.tsx','floor','from\x20','Gemfile.lock','endsWith','2BPwVdm','.py','.pyc','\x20chars\x20(contains\x20null\x20bytes\x20—\x20binary\x20content\x20omitted)','tracker','\x20files\x20found\x20across\x20','substring','.pdf','getConfig','parse','keys','cargo.lock','\x20chars\x20(high\x20non-printable\x20ratio\x20—\x20content\x20omitted)','smartCrushJson','call','[binary\x20file]\x20','total\x20','use\x20','indexOf','basename','package\x20','.gif','toLocaleString','.7z','\x20lines)','...\x20+','524092LDcfOX','\x20directories','.jpg','4128699ferfUt','.dylib','[binary/minified\x20file]\x20','filter','binary','.map','toLowerCase','join','45ekMfue','#include\x20','push','prototype','.pyo','.wav','.min.css','Empty\x20directory','\x20directories,\x20','3674752IrUwnH','length','.min.js','\x20lines\x20total,\x20','.webm','features_enabled','\x20chars,\x20type:\x20','.kt','\x20matches\x20across\x20'];a0_0xb0c6=function(){return _0x6ef7b8;};return a0_0xb0c6();}(function(_0x20c5f8,_0x24314e){const _0x19822a=a0_0x32be,_0x2ea3e3=_0x20c5f8();while(!![]){try{const _0x5b7891=-parseInt(_0x19822a(0x210))/0x1*(parseInt(_0x19822a(0x24b))/0x2)+-parseInt(_0x19822a(0x1e1))/0x3+parseInt(_0x19822a(0x1de))/0x4*(-parseInt(_0x19822a(0x1e9))/0x5)+-parseInt(_0x19822a(0x23d))/0x6*(-parseInt(_0x19822a(0x224))/0x7)+-parseInt(_0x19822a(0x1f2))/0x8+parseInt(_0x19822a(0x223))/0x9+parseInt(_0x19822a(0x22e))/0xa;if(_0x5b7891===_0x24314e)break;else _0x2ea3e3['push'](_0x2ea3e3['shift']());}catch(_0x5b6e07){_0x2ea3e3['push'](_0x2ea3e3['shift']());}}}(a0_0xb0c6,0xb6205));var __createBinding=this&&this['__createBinding']||(Object[a0_0x2e4863(0x23a)]?function(_0x2617c5,_0x517a25,_0xdf40ff,_0x5becb7){const _0x207070=a0_0x2e4863;if(_0x5becb7===undefined)_0x5becb7=_0xdf40ff;var _0x40de00=Object[_0x207070(0x213)](_0x517a25,_0xdf40ff);(!_0x40de00||('get'in _0x40de00?!_0x517a25['__esModule']:_0x40de00['writable']||_0x40de00[_0x207070(0x20a)]))&&(_0x40de00={'enumerable':!![],'get':function(){return _0x517a25[_0xdf40ff];}}),Object[_0x207070(0x201)](_0x2617c5,_0x5becb7,_0x40de00);}:function(_0x108cc5,_0x535357,_0x1095be,_0x53855c){if(_0x53855c===undefined)_0x53855c=_0x1095be;_0x108cc5[_0x53855c]=_0x535357[_0x1095be];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object[a0_0x2e4863(0x23a)]?function(_0x3e5a4d,_0xadb767){Object['defineProperty'](_0x3e5a4d,'default',{'enumerable':!![],'value':_0xadb767});}:function(_0x5a669e,_0xebe28a){const _0x24fc7d=a0_0x2e4863;_0x5a669e[_0x24fc7d(0x1fd)]=_0xebe28a;}),__importStar=this&&this['__importStar']||(function(){var _0x515f39=function(_0x3af293){return _0x515f39=Object['getOwnPropertyNames']||function(_0x5de0ff){const _0x2f27e4=a0_0x32be;var _0xca39f4=[];for(var _0x37ae05 in _0x5de0ff)if(Object[_0x2f27e4(0x1ec)][_0x2f27e4(0x203)][_0x2f27e4(0x1d2)](_0x5de0ff,_0x37ae05))_0xca39f4[_0xca39f4['length']]=_0x37ae05;return _0xca39f4;},_0x515f39(_0x3af293);};return function(_0x70e3b1){const _0x405f38=a0_0x32be;if(_0x70e3b1&&_0x70e3b1['__esModule'])return _0x70e3b1;var _0x15bff2={};if(_0x70e3b1!=null){for(var _0x30e37e=_0x515f39(_0x70e3b1),_0x4c8060=0x0;_0x4c8060<_0x30e37e[_0x405f38(0x1f3)];_0x4c8060++)if(_0x30e37e[_0x4c8060]!==_0x405f38(0x1fd))__createBinding(_0x15bff2,_0x70e3b1,_0x30e37e[_0x4c8060]);}return __setModuleDefault(_0x15bff2,_0x70e3b1),_0x15bff2;};}());Object[a0_0x2e4863(0x201)](exports,'__esModule',{'value':!![]}),exports['filterLs']=filterLs,exports['filterTree']=filterTree,exports['filterCat']=filterCat,exports['filterGrep']=filterGrep,exports[a0_0x2e4863(0x200)]=filterFind;const path=__importStar(require('path')),generic_1=require(a0_0x2e4863(0x238)),tracker_1=require(a0_0x2e4863(0x232));function isFeatureEnabled(_0x345015){const _0xaa1046=a0_0x2e4863;try{const _0x34fcf6=tracker_1[_0xaa1046(0x1c8)][_0xaa1046(0x1cc)](),_0x99ef3b=_0x34fcf6[_0xaa1046(0x1f7)];if(!_0x99ef3b||_0x99ef3b[_0x345015]===undefined)return!![];return _0x99ef3b[_0x345015]!==![];}catch{return!![];}}const LOCK_FILES=[a0_0x2e4863(0x23e),'yarn.lock',a0_0x2e4863(0x216),a0_0x2e4863(0x1fe),a0_0x2e4863(0x204),a0_0x2e4863(0x207),a0_0x2e4863(0x21f),a0_0x2e4863(0x249),a0_0x2e4863(0x239)],BINARY_EXTENSIONS=[a0_0x2e4863(0x1f4),a0_0x2e4863(0x1ef),a0_0x2e4863(0x1e6),'.wasm','.png',a0_0x2e4863(0x1e0),a0_0x2e4863(0x22d),a0_0x2e4863(0x1d9),a0_0x2e4863(0x1fb),a0_0x2e4863(0x215),a0_0x2e4863(0x22f),a0_0x2e4863(0x212),a0_0x2e4863(0x1cb),a0_0x2e4863(0x20f),a0_0x2e4863(0x221),'.tgz','.gz',a0_0x2e4863(0x22a),a0_0x2e4863(0x1db),'.rar','.exe','.dll','.so',a0_0x2e4863(0x1e2),a0_0x2e4863(0x230),'.dat','.sqlite',a0_0x2e4863(0x228),a0_0x2e4863(0x226),a0_0x2e4863(0x20d),a0_0x2e4863(0x218),'.ttf','.eot','.otf','.mp3','.mp4',a0_0x2e4863(0x1ee),a0_0x2e4863(0x205),'.mov',a0_0x2e4863(0x1f6),a0_0x2e4863(0x24d),a0_0x2e4863(0x1ed),a0_0x2e4863(0x202),'.o','.obj'];function extractFilename(_0x34cb4d){const _0x2e1d4b=a0_0x2e4863,_0x4fa28d=_0x34cb4d[_0x2e1d4b(0x241)]()[_0x2e1d4b(0x21c)](/\s+/);for(let _0x2e57cf=0x1;_0x2e57cf<_0x4fa28d['length'];_0x2e57cf++){if(!_0x4fa28d[_0x2e57cf][_0x2e1d4b(0x229)]('-'))return _0x4fa28d[_0x2e57cf];}return null;}function a0_0x32be(_0x132c39,_0x37ab29){_0x132c39=_0x132c39-0x1c7;const _0xb0c6d4=a0_0xb0c6();let _0x32be7d=_0xb0c6d4[_0x132c39];return _0x32be7d;}function filterLockFile(_0x4de4d8,_0x208602){const _0x532b2b=a0_0x2e4863;try{const _0x11eec2=path['basename'](_0x208602)['toLowerCase']();if(!LOCK_FILES[_0x532b2b(0x20c)](_0x3be1e9=>_0x11eec2===_0x3be1e9['toLowerCase']()))return null;const _0x2f36d4=_0x4de4d8['length'];let _0x3fef42=0x0;if(_0x11eec2==='package-lock.json')try{const _0x58e98b=JSON[_0x532b2b(0x1cd)](_0x4de4d8);_0x3fef42=Object[_0x532b2b(0x1ce)](_0x58e98b[_0x532b2b(0x209)]||_0x58e98b['dependencies']||{})['length'];}catch{_0x3fef42=(_0x4de4d8[_0x532b2b(0x242)](/"resolved":/g)||[])[_0x532b2b(0x1f3)];}else{if(_0x11eec2===_0x532b2b(0x21d))_0x3fef42=(_0x4de4d8[_0x532b2b(0x242)](/^"?[^#\s][^:]*:$/gm)||[])[_0x532b2b(0x1f3)];else{if(_0x11eec2===_0x532b2b(0x1cf)||_0x11eec2===_0x532b2b(0x207))_0x3fef42=(_0x4de4d8[_0x532b2b(0x242)](/\[\[package\]\]/g)||[])[_0x532b2b(0x1f3)];else{if(_0x11eec2===_0x532b2b(0x204))_0x3fef42=Math[_0x532b2b(0x247)](_0x4de4d8[_0x532b2b(0x21c)]('\x0a')['filter'](_0x54583f=>_0x54583f[_0x532b2b(0x241)]())['length']/0x2);else{if(_0x11eec2===_0x532b2b(0x21f))try{_0x3fef42=JSON['parse'](_0x4de4d8)[_0x532b2b(0x209)]?.['length']||0x0;}catch{}else _0x11eec2===_0x532b2b(0x216)?_0x3fef42=(_0x4de4d8[_0x532b2b(0x242)](/^\s{2}['"@a-z]/gm)||[])[_0x532b2b(0x1f3)]:_0x3fef42=_0x4de4d8[_0x532b2b(0x21c)]('\x0a')[_0x532b2b(0x1e4)](_0x208cec=>_0x208cec[_0x532b2b(0x241)]())[_0x532b2b(0x1f3)];}}}}return _0x532b2b(0x231)+path['basename'](_0x208602)+':\x20'+_0x3fef42+_0x532b2b(0x235)+_0x2f36d4[_0x532b2b(0x1da)]()+_0x532b2b(0x21a);}catch{return null;}}function filterBinaryOrMinified(_0x4caa33,_0x24bac4){const _0x305f30=a0_0x2e4863;try{if(_0x24bac4){const _0x358448=_0x24bac4['toLowerCase']();for(const _0x3eef3e of BINARY_EXTENSIONS){if(_0x358448['endsWith'](_0x3eef3e))return _0x305f30(0x1e3)+path[_0x305f30(0x1d7)](_0x24bac4)+',\x20'+_0x4caa33['length'][_0x305f30(0x1da)]()+_0x305f30(0x1f8)+_0x3eef3e+'\x20(content\x20omitted\x20—\x20not\x20useful\x20for\x20LLM\x20context)';}}const _0x4d420c=_0x4caa33['substring'](0x0,0x3e8);let _0x2f7eae=0x0;for(let _0x13ce0e=0x0;_0x13ce0e<_0x4d420c['length'];_0x13ce0e++){if(_0x4d420c[_0x305f30(0x237)](_0x13ce0e)===0x0)_0x2f7eae++;}if(_0x2f7eae>0x0)return _0x305f30(0x1d3)+_0x4caa33[_0x305f30(0x1f3)][_0x305f30(0x1da)]()+_0x305f30(0x1c7);let _0x56fad1=0x0;for(let _0xe11a6=0x0;_0xe11a6<_0x4d420c['length'];_0xe11a6++){const _0x328c4b=_0x4d420c[_0x305f30(0x237)](_0xe11a6);if(_0x328c4b<0x20&&_0x328c4b!==0xa&&_0x328c4b!==0xd&&_0x328c4b!==0x9)_0x56fad1++;}if(_0x4d420c[_0x305f30(0x1f3)]>0x64&&_0x56fad1>_0x4d420c[_0x305f30(0x1f3)]*0.1)return _0x305f30(0x1d3)+_0x4caa33[_0x305f30(0x1f3)][_0x305f30(0x1da)]()+_0x305f30(0x1d0);const _0x25959b=_0x4caa33[_0x305f30(0x21c)]('\x0a');if(_0x25959b['length']<=0x3&&_0x4caa33[_0x305f30(0x1f3)]>0x1388)return'[minified\x20file]\x20'+_0x4caa33[_0x305f30(0x1f3)][_0x305f30(0x1da)]()+'\x20chars\x20across\x20'+_0x25959b[_0x305f30(0x1f3)]+_0x305f30(0x1fc);return null;}catch{return null;}}function filterJsonMinify(_0x377aeb){const _0x99eeeb=a0_0x2e4863;try{const _0x54b5cc=_0x377aeb[_0x99eeeb(0x241)]();if(!_0x54b5cc[_0x99eeeb(0x229)]('{')&&!_0x54b5cc[_0x99eeeb(0x229)]('['))return null;const _0x170341=_0x54b5cc[_0x99eeeb(0x21c)]('\x0a');if(_0x170341[_0x99eeeb(0x1f3)]<=0x14)return null;const _0x12b6c7=JSON[_0x99eeeb(0x1cd)](_0x54b5cc),_0x355252=JSON['stringify'](_0x12b6c7);if(_0x355252[_0x99eeeb(0x1f3)]<_0x54b5cc['length'])return _0x355252;return null;}catch{return null;}}function filterLs(_0x226e77){const _0x4efc7b=a0_0x2e4863,_0x1ca8dc=_0x226e77[_0x4efc7b(0x21c)]('\x0a')[_0x4efc7b(0x1e4)](_0x2b7c4e=>_0x2b7c4e[_0x4efc7b(0x241)]()[_0x4efc7b(0x1f3)]>0x0);if(_0x1ca8dc['length']===0x0)return _0x4efc7b(0x1f0);if(_0x1ca8dc[_0x4efc7b(0x1f3)]<=0x1e)return _0x226e77[_0x4efc7b(0x241)]();const _0x26976b=[],_0x4a8ff3=[];for(const _0x12cf76 of _0x1ca8dc){const _0x35620a=_0x12cf76['trim']();if(_0x35620a[_0x4efc7b(0x229)](_0x4efc7b(0x1d4))||_0x35620a[_0x4efc7b(0x229)]('d')&&_0x35620a['includes']('..'))continue;_0x35620a[_0x4efc7b(0x24a)]('/')||_0x35620a[_0x4efc7b(0x229)]('d')&&_0x35620a[_0x4efc7b(0x244)]('\x20')?_0x26976b[_0x4efc7b(0x1eb)](_0x35620a):_0x4a8ff3[_0x4efc7b(0x1eb)](_0x35620a);}const _0x24bc11=[];return _0x26976b[_0x4efc7b(0x1f3)]>0x0&&(_0x26976b[_0x4efc7b(0x1f3)]<=0xf?_0x24bc11[_0x4efc7b(0x1eb)](..._0x26976b):(_0x24bc11[_0x4efc7b(0x1eb)](..._0x26976b[_0x4efc7b(0x23b)](0x0,0xa)),_0x24bc11[_0x4efc7b(0x1eb)]('...\x20+'+(_0x26976b['length']-0xa)+_0x4efc7b(0x240)))),_0x4a8ff3[_0x4efc7b(0x1f3)]>0x0&&(_0x4a8ff3[_0x4efc7b(0x1f3)]<=0x14?_0x24bc11[_0x4efc7b(0x1eb)](..._0x4a8ff3):(_0x24bc11['push'](..._0x4a8ff3[_0x4efc7b(0x23b)](0x0,0xf)),_0x24bc11[_0x4efc7b(0x1eb)](_0x4efc7b(0x1dd)+(_0x4a8ff3[_0x4efc7b(0x1f3)]-0xf)+'\x20more\x20files'))),_0x24bc11[_0x4efc7b(0x1eb)]('\x0a('+_0x26976b[_0x4efc7b(0x1f3)]+_0x4efc7b(0x1f1)+_0x4a8ff3[_0x4efc7b(0x1f3)]+_0x4efc7b(0x206)),_0x24bc11[_0x4efc7b(0x1e8)]('\x0a');}function filterTree(_0x278dfe){const _0x55085f=a0_0x2e4863,_0x25d0c7=_0x278dfe[_0x55085f(0x21c)]('\x0a');if(_0x25d0c7[_0x55085f(0x1f3)]<=0x32)return _0x278dfe['trim']();const _0xbc4e67=[];let _0x5a0f2e=0x0,_0x5f4f25=0x0,_0x3ab084=0x0;for(const _0x3771e9 of _0x25d0c7){const _0x14fa64=_0x3771e9[_0x55085f(0x242)](/(\d+)\s+director/),_0x14eb58=_0x3771e9[_0x55085f(0x242)](/(\d+)\s+file/);if(_0x14fa64)_0x3ab084=parseInt(_0x14fa64[0x1]);if(_0x14eb58)_0x5f4f25=parseInt(_0x14eb58[0x1]);const _0x3bcf2f=(_0x3771e9['match'](/^[│├└\s─]+/)||[''])[0x0]['length'];_0x3bcf2f<=0x4&&(_0xbc4e67[_0x55085f(0x1eb)](_0x3771e9),_0x5a0f2e++);}return _0x25d0c7['length']>_0xbc4e67[_0x55085f(0x1f3)]&&_0xbc4e67[_0x55085f(0x1eb)](_0x55085f(0x233)+_0x3ab084+_0x55085f(0x1f1)+_0x5f4f25+'\x20files\x20total\x20—\x20deep\x20entries\x20truncated)'),_0xbc4e67[_0x55085f(0x1e8)]('\x0a');}function filterCat(_0x5c61cf,_0x21f28c=''){const _0x348aae=a0_0x2e4863,_0x417ec7=extractFilename(_0x21f28c);try{if(_0x417ec7&&isFeatureEnabled(_0x348aae(0x245))){const _0x37518a=filterLockFile(_0x5c61cf,_0x417ec7);if(_0x37518a)return _0x37518a;}if(isFeatureEnabled(_0x348aae(0x1e5))){const _0x11476d=filterBinaryOrMinified(_0x5c61cf,_0x417ec7);if(_0x11476d)return _0x11476d;}if(isFeatureEnabled('json_crusher')){const _0x230bf2=(0x0,generic_1[_0x348aae(0x1d1)])(_0x5c61cf);if(_0x230bf2)return _0x230bf2;}const _0x1e05fa=filterJsonMinify(_0x5c61cf);if(_0x1e05fa)return _0x1e05fa;if(_0x417ec7&&isFeatureEnabled(_0x348aae(0x219))){const _0x482662=path[_0x348aae(0x20e)](_0x417ec7)[_0x348aae(0x1e7)](),_0x4de064=[_0x348aae(0x220),'.js',_0x348aae(0x246),_0x348aae(0x225),_0x348aae(0x24c),_0x348aae(0x217),_0x348aae(0x22c),'.java','.c',_0x348aae(0x20b),_0x348aae(0x23f),'.rb','.swift',_0x348aae(0x1f9)];if(_0x4de064[_0x348aae(0x244)](_0x482662)){const _0x3c561b=_0x5c61cf[_0x348aae(0x21c)]('\x0a');if(_0x3c561b['length']>0x64){const _0x4fe800=[];_0x4fe800['push'](_0x348aae(0x23c)+path[_0x348aae(0x1d7)](_0x417ec7)+'\x20('+_0x3c561b['length']+_0x348aae(0x1dc)),_0x4fe800[_0x348aae(0x1eb)]('');for(const _0x5ea8eb of _0x3c561b){const _0x2f2998=_0x5ea8eb[_0x348aae(0x241)]();if(_0x2f2998[_0x348aae(0x229)](_0x348aae(0x1ff))||_0x2f2998[_0x348aae(0x229)](_0x348aae(0x248))||_0x2f2998['startsWith'](_0x348aae(0x211))||_0x2f2998[_0x348aae(0x242)](/=\s*require\(/)||_0x2f2998[_0x348aae(0x229)](_0x348aae(0x1ea))||_0x2f2998[_0x348aae(0x229)](_0x348aae(0x1d5))||_0x2f2998[_0x348aae(0x229)](_0x348aae(0x1d8)))_0x4fe800[_0x348aae(0x1eb)](_0x5ea8eb);else{if(_0x2f2998['match'](/^(export\s+)?(async\s+)?function\s+/)||_0x2f2998[_0x348aae(0x242)](/^(export\s+)?(default\s+)?class\s+/)||_0x2f2998[_0x348aae(0x242)](/^(export\s+)?(type|interface|enum)\s+/)||_0x2f2998['match'](/^(async\s+)?def\s+/)||_0x2f2998[_0x348aae(0x242)](/^func\s+/)||_0x2f2998[_0x348aae(0x242)](/^type\s+\w+\s+(struct|interface)/)||_0x2f2998['match'](/^(pub\s+)?(async\s+)?fn\s+/)||_0x2f2998[_0x348aae(0x242)](/^(pub\s+)?(struct|enum|trait|impl)\s+/)||_0x2f2998[_0x348aae(0x242)](/^(public|private|protected|static)\s+/))_0x4fe800[_0x348aae(0x1eb)](_0x5ea8eb);else{if(_0x2f2998['startsWith']('export\x20')&&!_0x2f2998[_0x348aae(0x244)]('=>')&&_0x2f2998[_0x348aae(0x1f3)]<0x78)_0x4fe800[_0x348aae(0x1eb)](_0x5ea8eb);else _0x2f2998[_0x348aae(0x229)]('@')&&!_0x2f2998[_0x348aae(0x229)](_0x348aae(0x21b))&&!_0x2f2998['startsWith'](_0x348aae(0x234))&&_0x4fe800[_0x348aae(0x1eb)](_0x5ea8eb);}}}_0x4fe800['push'](''),_0x4fe800['push']('('+_0x3c561b[_0x348aae(0x1f3)]+_0x348aae(0x1f5)+(_0x4fe800['length']-0x2)+_0x348aae(0x222));const _0x5c7360=_0x4fe800[_0x348aae(0x1e8)]('\x0a');if(_0x5c7360['length']<_0x5c61cf[_0x348aae(0x1f3)])return _0x5c7360;}}}}catch{}let _0x70a1e9=(0x0,generic_1[_0x348aae(0x21e)])(_0x5c61cf);if(_0x417ec7){const _0x1ebbd9=path[_0x348aae(0x20e)](_0x417ec7)['toLowerCase']();_0x70a1e9=(0x0,generic_1[_0x348aae(0x243)])(_0x70a1e9,_0x1ebbd9);}const _0x1fe967=_0x70a1e9[_0x348aae(0x21c)]('\x0a');if(_0x1fe967[_0x348aae(0x1f3)]<=0x64)return _0x70a1e9;const _0x4ba194=[];return _0x4ba194[_0x348aae(0x1eb)](..._0x1fe967[_0x348aae(0x23b)](0x0,0x32)),_0x4ba194[_0x348aae(0x1eb)](_0x348aae(0x22b)+(_0x1fe967[_0x348aae(0x1f3)]-0x50)+'\x20lines\x20truncated]\x20...\x0a'),_0x4ba194[_0x348aae(0x1eb)](..._0x1fe967[_0x348aae(0x23b)](-0x1e)),_0x4ba194[_0x348aae(0x1eb)]('\x0a('+_0x1fe967[_0x348aae(0x1f3)]+'\x20lines\x20total)'),_0x4ba194['join']('\x0a');}function filterGrep(_0x24ef0e){const _0x10e068=a0_0x2e4863,_0x4d2575=_0x24ef0e[_0x10e068(0x21c)]('\x0a')[_0x10e068(0x1e4)](_0x12f3be=>_0x12f3be['trim']()[_0x10e068(0x1f3)]>0x0);if(_0x4d2575[_0x10e068(0x1f3)]===0x0)return'No\x20matches\x20found';if(_0x4d2575[_0x10e068(0x1f3)]<=0x32)return _0x24ef0e[_0x10e068(0x241)]();const _0x4dc00b={},_0x502294=[];for(const _0x46310e of _0x4d2575){const _0x595b5c=_0x46310e[_0x10e068(0x1d6)](':');if(_0x595b5c>0x0&&_0x595b5c<0xc8){const _0x26583a=_0x46310e[_0x10e068(0x1ca)](0x0,_0x595b5c);if(_0x26583a[_0x10e068(0x244)]('/')||_0x26583a[_0x10e068(0x244)]('\x5c')||_0x26583a['includes']('.')){if(!_0x4dc00b[_0x26583a])_0x4dc00b[_0x26583a]=[];_0x4dc00b[_0x26583a][_0x10e068(0x1eb)](_0x46310e[_0x10e068(0x1ca)](_0x595b5c+0x1)['trim']());continue;}}_0x502294[_0x10e068(0x1eb)](_0x46310e);}const _0x248dd1=[],_0x101d6c=Object[_0x10e068(0x1ce)](_0x4dc00b);if(_0x101d6c[_0x10e068(0x1f3)]>0x0){const _0x5b7e69=0x14,_0x15bf00=_0x101d6c[_0x10e068(0x23b)](0x0,_0x5b7e69);for(const _0x377b98 of _0x15bf00){const _0x279d1a=_0x4dc00b[_0x377b98];if(_0x279d1a[_0x10e068(0x1f3)]<=0x3)for(const _0x204b85 of _0x279d1a){_0x248dd1['push'](_0x377b98+':\x20'+_0x204b85);}else _0x248dd1[_0x10e068(0x1eb)](_0x377b98+':\x20'+_0x279d1a[0x0]),_0x248dd1[_0x10e068(0x1eb)](_0x377b98+':\x20...\x20('+_0x279d1a[_0x10e068(0x1f3)]+'\x20matches\x20in\x20this\x20file)');}_0x101d6c[_0x10e068(0x1f3)]>_0x5b7e69&&_0x248dd1[_0x10e068(0x1eb)]('...\x20+'+(_0x101d6c['length']-_0x5b7e69)+'\x20more\x20files\x20with\x20matches');}if(_0x502294[_0x10e068(0x1f3)]>0x0){const _0x282060=0x1e;_0x248dd1['push'](..._0x502294[_0x10e068(0x23b)](0x0,_0x282060)),_0x502294[_0x10e068(0x1f3)]>_0x282060&&_0x248dd1[_0x10e068(0x1eb)](_0x10e068(0x1dd)+(_0x502294[_0x10e068(0x1f3)]-_0x282060)+'\x20more\x20matches');}const _0x13a8e7=_0x4d2575[_0x10e068(0x1f3)];return _0x248dd1[_0x10e068(0x1eb)]('\x0a('+_0x13a8e7+_0x10e068(0x1fa)+(_0x101d6c[_0x10e068(0x1f3)]||'?')+_0x10e068(0x206)),_0x248dd1[_0x10e068(0x1e8)]('\x0a');}function filterFind(_0x559065){const _0x259105=a0_0x2e4863,_0x50765c=_0x559065[_0x259105(0x21c)]('\x0a')[_0x259105(0x1e4)](_0x4b5926=>_0x4b5926[_0x259105(0x241)]()[_0x259105(0x1f3)]>0x0);if(_0x50765c[_0x259105(0x1f3)]===0x0)return'No\x20files\x20found';if(_0x50765c['length']<=0x32)return _0x559065['trim']();const _0xe80ba0={};for(const _0x4d583d of _0x50765c){const _0xd94f00=path[_0x259105(0x208)](_0x4d583d[_0x259105(0x241)]())||'.';_0xe80ba0[_0xd94f00]=(_0xe80ba0[_0xd94f00]||0x0)+0x1;}const _0x1c18f3=Object['entries'](_0xe80ba0)[_0x259105(0x236)]((_0x195c62,_0x535ce3)=>_0x535ce3[0x1]-_0x195c62[0x1]),_0x494e70=[_0x50765c['length']+_0x259105(0x1c9)+_0x1c18f3[_0x259105(0x1f3)]+_0x259105(0x1df),''],_0x2c19a6=0x1e;for(const [_0x22fea5,_0x15ea79]of _0x1c18f3[_0x259105(0x23b)](0x0,_0x2c19a6)){_0x494e70[_0x259105(0x1eb)]('\x20\x20'+_0x22fea5+_0x259105(0x227)+_0x15ea79+_0x259105(0x206));}return _0x1c18f3[_0x259105(0x1f3)]>_0x2c19a6&&_0x494e70[_0x259105(0x1eb)](_0x259105(0x214)+(_0x1c18f3[_0x259105(0x1f3)]-_0x2c19a6)+_0x259105(0x240)),_0x494e70[_0x259105(0x1e8)]('\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
+ }
@@ -0,0 +1,79 @@
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
+ }