@bangdao-ai/acw-tools 1.13.68 → 1.13.69

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/postinstall.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- function _0x3f8a(_0x35d0c7,_0x257093){_0x35d0c7=_0x35d0c7-0xd6;const _0x2710fb=_0x2710();let _0x3f8a1a=_0x2710fb[_0x35d0c7];return _0x3f8a1a;}const _0x2d62c7=_0x3f8a;(function(_0x3554fc,_0x36c677){const _0x1dc983=_0x3f8a,_0x27cf52=_0x3554fc();while(!![]){try{const _0x3f29e5=-parseInt(_0x1dc983(0xdd))/0x1+parseInt(_0x1dc983(0x130))/0x2+parseInt(_0x1dc983(0xff))/0x3*(-parseInt(_0x1dc983(0x11b))/0x4)+-parseInt(_0x1dc983(0x115))/0x5*(-parseInt(_0x1dc983(0x12f))/0x6)+-parseInt(_0x1dc983(0x110))/0x7*(parseInt(_0x1dc983(0x121))/0x8)+-parseInt(_0x1dc983(0x125))/0x9*(-parseInt(_0x1dc983(0xd9))/0xa)+-parseInt(_0x1dc983(0x12d))/0xb*(-parseInt(_0x1dc983(0xf6))/0xc);if(_0x3f29e5===_0x36c677)break;else _0x27cf52['push'](_0x27cf52['shift']());}catch(_0x5bbfa){_0x27cf52['push'](_0x27cf52['shift']());}}}(_0x2710,0x4cb82));import _0x49cd3e from'fs';import _0x531f45 from'path';import{fileURLToPath as _0xd6fe4d}from'url';import{execSync as _0x2acfd4}from'child_process';import _0xe30a47 from'https';import _0x6bc901 from'http';import _0x19ce02 from'zlib';var C='12.4.1',L=_0x2d62c7(0x147),F={0x12:'108',0x13:_0x2d62c7(0x119),0x14:_0x2d62c7(0x103),0x15:'120',0x16:'127',0x17:'131',0x18:_0x2d62c7(0x146),0x19:'137'},$=[_0x2d62c7(0x103),_0x2d62c7(0x149),'131',_0x2d62c7(0x146)],I=parseInt(process['version'][_0x2d62c7(0x134)](0x1)['split']('.')[0x0],0xa),T=((()=>{const _0x535ef9=_0x2d62c7;let _0x59a803=process[_0x535ef9(0xe9)][_0x535ef9(0x134)](0x1)[_0x535ef9(0x116)]('.');return parseInt(_0x59a803[0x1]||'0',0xa);})());function x(){return I>0x16||I===0x16&&T>=0x5;}function P(){const _0x2e4a2e=_0x2d62c7;console[_0x2e4a2e(0x145)](''),console[_0x2e4a2e(0x145)](_0x2e4a2e(0xf5)),console[_0x2e4a2e(0x145)]('[提示]\x20【本包为什么要动\x20SQLite】需要读取\x20Cursor\x20本地的\x20state.vscdb(对话与\x20composer\x20数据)。'),console['log']('[提示]\x20【推荐环境】请使用\x20Node.js\x2022.5\x20及以上(LTS\x2022\x20的最新小版本即可)。'),console['log']('[提示]\x20\x20\x20该版本起\x20Node\x20内置「node:sqlite」,安装时无需\x20better-sqlite3,Windows\x20上可避免出现「模块编译失败」。'),console[_0x2e4a2e(0x145)](_0x2e4a2e(0xf9)+process['version']+_0x2e4a2e(0x143)),console[_0x2e4a2e(0x145)](_0x2e4a2e(0xdc)),console['log']('[提示]\x20\x20\x20·\x20Windows:未安装\x20Visual\x20Studio\x20Build\x20Tools(缺\x20cl.exe),node-gyp\x20无法编译;'),console['log'](_0x2e4a2e(0xfe)),console[_0x2e4a2e(0x145)]('[提示]\x20\x20\x20·\x20公司网络拦截导致预编译包下载失败,被迫本地编译但本机无工具链。'),console['log']('[提示]\x20【解决办法优先级】①\x20将运行\x20npx\x20的\x20Node\x20升级到\x2022.5+(最省事);②\x20安装对应系统的\x20C++\x20编译环境后再装本包;③\x20确保\x20Cursor\x20/\x20终端使用同一份\x20Node,避免\x20ABI\x20混用。'),console['log'](_0x2e4a2e(0xf5)),console[_0x2e4a2e(0x145)]('');}function y(){const _0x1f49c5=_0x2d62c7;console['error'](''),console[_0x1f49c5(0xe4)](_0x1f49c5(0x151)),console[_0x1f49c5(0xe4)]('本步骤失败,几乎总是「可选依赖\x20better-sqlite3」的原生模块无法在您当前环境加载或编译。'),console[_0x1f49c5(0xe4)](_0x1f49c5(0x13b)),console['error']('建议:将运行「npx\x20@bangdao-ai/acw-tools」的\x20Node\x20升级到\x2022.5\x20及以上,本包将改用内置\x20SQLite,一般不再需要编译。'),console[_0x1f49c5(0xe4)](_0x1f49c5(0x128)),console['error']('────────────────────────────────────────────');}function b(){const _0x17ecff=_0x2d62c7;let _0x5d9b71=parseInt(process['version'][_0x17ecff(0x134)](0x1)['split']('.')[0x0],0xa);return F[_0x5d9b71]||process[_0x17ecff(0x101)][_0x17ecff(0xf3)];}function E(){const _0x58d252=_0x2d62c7;let _0x4b6767=C,_0x34cb39=b(),_0x1c0987=process['platform'],_0x41215a=process['arch'];return _0x58d252(0x135)+_0x4b6767+_0x58d252(0x100)+_0x34cb39+'-'+_0x1c0987+'-'+_0x41215a+_0x58d252(0xf2);}function v(_0x454817){return new Promise((_0x415ddf,_0x22a970)=>{const _0x896cbb=_0x3f8a;let _0xdda455=(_0x454817[_0x896cbb(0xed)]('https')?_0xe30a47:_0x6bc901)['get'](_0x454817,{'timeout':0x7530},_0x4c586f=>{const _0x3ca583=_0x896cbb;if(_0x4c586f[_0x3ca583(0x102)]===0x12d||_0x4c586f['statusCode']===0x12e){v(_0x4c586f['headers']['location'])[_0x3ca583(0x118)](_0x415ddf)[_0x3ca583(0xf4)](_0x22a970);return;}if(_0x4c586f[_0x3ca583(0x102)]!==0xc8){_0x22a970(new Error(_0x3ca583(0x14c)+_0x4c586f['statusCode']));return;}let _0x4aa6d4=[];_0x4c586f['on']('data',_0x58f71d=>_0x4aa6d4['push'](_0x58f71d)),_0x4c586f['on'](_0x3ca583(0x10b),()=>_0x415ddf(Buffer['concat'](_0x4aa6d4))),_0x4c586f['on'](_0x3ca583(0xe4),_0x22a970);});_0xdda455['on'](_0x896cbb(0xe4),_0x22a970),_0xdda455['on'](_0x896cbb(0xe7),()=>{const _0x34412c=_0x896cbb;_0xdda455['destroy'](),_0x22a970(new Error(_0x34412c(0x12a)));});});}function _0x2710(){const _0x1378c7=['1284906aLwEkh','1244936wzhXOe','[INFO]\x20━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━',',平台=','exit','slice','better-sqlite3-v','[OK]\x20已检测到\x20Node\x20内置\x20node:sqlite,安装检查通过。','mkdirSync','existsSync','━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━','basename','根因:它需要与本机\x20Node\x20版本匹配的\x20C++\x20二进制;Windows\x20上缺\x20VS\x20Build\x20Tools\x20时极易报错。','\x20KB)','fromCharCode','package.json','toFixed','[OK]\x20安装完成','[步骤]\x20npm\x20rebuild:\x20失败(见上方日志,多为缺少\x20cl.exe\x20/\x20Xcode\x20Command\x20Line\x20Tools\x20/\x20build-essential)','[提示]\x20',',未检测到可用的内置\x20node:sqlite(或运行时被禁用),因此走可选依赖\x20better-sqlite3。','darwin','log','137','https://bd-acw.oss-cn-beijing.aliyuncs.com/prebuilds/better-sqlite3','utf8','127','close','[ERROR]\x20better-sqlite3\x20模块加载失败,安装中止','HTTP\x20','[步骤]\x20未找到\x20better-sqlite3\x20目录,无法执行\x20npm\x20rebuild','[WARN]\x20无法确定\x20npm\x20包根目录,跳过\x20npm\x20rebuild','[OK]\x20better-sqlite3\x20修复成功(OSS\x20预编译)','join','──────────\x20给用户的说明(安装失败)──────────','说明:\x20已尝试\x20OSS\x20预编译与\x20npm\x20rebuild。仍失败时:务必把运行\x20npx\x20的\x20Node\x20升到\x2022.5+(内置\x20SQLite,从根上避免本问题)。其余检查:','cwd','prebuilds','2320nrXFaa','includes','acwInstallNote','[提示]\x20【为什么会编译失败】better-sqlite3\x20含\x20C++\x20扩展(.node\x20文件)。常见原因:','379846QwNQgd','[WARN]\x20预编译包安装后测试失败:\x20','pipe','dirname','[步骤]\x20执行自动\x20npm\x20rebuild\x20better-sqlite3(本机源码编译)','message','──────────\x20诊断摘要(请整段复制给支持人员或\x20Cursor)──────────','error','test',',npm\x20包根=','timeout','。优先请把运行\x20npx\x20的\x20Node\x20升级到\x2022.5\x20以上以使用内置\x20SQLite、避免编译。若暂不能升级:已装\x20VS\x20仍失败则执行\x20npm\x20cache\x20clean\x20--force\x20后\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools\x20重装。','version','unknown','object','[环境]\x20better-sqlite3\x20路径=','startsWith','[步骤]\x20OSS\x20预编译后子进程校验仍失败:\x20','node:sqlite','...','arch','.tar.gz','modules','catch','[提示]\x20━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━','8068248YyEOUz','\x20(ABI\x20','\x20\x201)\x20终端执行\x20node\x20-v\x20与\x20Cursor\x20调起\x20MCP\x20用的是否为同一\x20Node;','[提示]\x20【你当前的情况】当前为\x20','」执行\x20npm\x20rebuild\x20better-sqlite3','未找到','[OK]\x20npm\x20rebuild\x20成功,better-sqlite3\x20已可加载','复制以下提示词发送给\x20Cursor,让\x20AI\x20帮你修复:','[提示]\x20\x20\x20·\x20任意系统:执行\x20npx\x20的\x20Node\x20版本与当初编译该模块的\x20Node\x20ABI\x20不一致(报\x20NODE_MODULE_VERSION\x20/\x20was\x20compiled\x20against);','1488255ZxBomo','-node-v','versions','statusCode','115','push','gunzipSync','\x20不在\x20OSS\x20预编译列表\x20[',')\x20|\x20','[INFO]\x20预编译包已安装,重新测试...','trim','warn','end','[提示]\x20当前通过\x20better-sqlite3\x20完成检查。若希望免去原生依赖,可将\x20Node\x20升级到\x2022.5\x20及以上。','────────────────────────────────────────────────────────────','我的\x20ACW\x20MCP\x20安装失败(better-sqlite3\x20/\x20原生模块),错误:','[原因]\x20当前\x20ABI\x20','6104pXgqug','[步骤]\x20OSS\x20下载或解压失败:\x20','(ABI\x20v','better_sqlite3','[原因]\x20首次加载失败(动态\x20import):\x20','5uLQnPt','split','无法找到\x20better-sqlite3\x20模块路径','then','111','default','4lmKrNd','\x20\x202)\x20若必须留在旧\x20Node:安装\x20C++\x20工具链后在包根目录执行\x20npm\x20rebuild\x20better-sqlite3\x20--foreground-scripts;','platform','writeFileSync','env','dlopen','4304qgzekU','[INFO]\x20检测到原生模块加载异常,尝试从\x20OSS\x20拉取匹配当前\x20ABI\x20的预编译包...','[INFO]\x20尝试从\x20OSS\x20下载预编译包:\x20','未解析','5832MuTCHs','\x20\x203)\x20再执行\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools。','better-sqlite3','package.json\x20中\x20engines\x20为\x20node>=20;要免编译、少踩坑,请以\x2022.5+\x20为准。','ceil','Request\x20timeout','。优先请把运行\x20npx\x20的\x20Node\x20升级到\x2022.5\x20以上(免装\x20VS\x20Build\x20Tools)。否则请安装\x20Visual\x20Studio\x20Build\x20Tools\x20后再\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools。',':memory:','11kilHpY','stdout'];_0x2710=function(){return _0x1378c7;};return _0x2710();}async function D(_0x215f1c,_0x3b36bd){const _0x4ee598=_0x2d62c7;let _0x38d914=_0x19ce02[_0x4ee598(0x105)](_0x215f1c),_0xc61a48=0x200,_0x19c563=0x0;for(;_0x19c563<_0x38d914['length']-_0xc61a48;){let _0x1f12d3=_0x38d914[_0x4ee598(0x134)](_0x19c563,_0x19c563+_0xc61a48);if(_0x1f12d3[0x0]===0x0)break;let _0x5b636f=_0x1f12d3['slice'](0x0,0x64)['toString'](_0x4ee598(0x148))['replace'](/\0/g,'')['trim'](),_0x19b6ba=_0x1f12d3['slice'](0x7c,0x88)['toString']('utf8')['replace'](/\0/g,'')[_0x4ee598(0x109)](),_0x36d6d1=parseInt(_0x19b6ba,0x8)||0x0,_0x489981=String[_0x4ee598(0x13d)](_0x1f12d3[0x9c]);if(_0x19c563+=_0xc61a48,_0x5b636f&&_0x489981==='0'||_0x489981==='\x00'){let _0x522d1b=_0x38d914[_0x4ee598(0x134)](_0x19c563,_0x19c563+_0x36d6d1),_0x79e84c=_0x531f45['join'](_0x3b36bd,_0x531f45[_0x4ee598(0x13a)](_0x5b636f));_0x49cd3e[_0x4ee598(0x137)](_0x531f45[_0x4ee598(0xe0)](_0x79e84c),{'recursive':!0x0}),_0x49cd3e[_0x4ee598(0x11e)](_0x79e84c,_0x522d1b);}_0x19c563+=Math[_0x4ee598(0x129)](_0x36d6d1/_0xc61a48)*_0xc61a48;}}function h(){const _0x1a8718=_0x2d62c7;let _0x254c53=[_0x531f45[_0x1a8718(0x150)](process[_0x1a8718(0xd7)](),'node_modules','better-sqlite3'),_0x531f45['join'](_0xd6fe4d(import.meta.url),'..','node_modules',_0x1a8718(0x127))];try{let _0x5675da=import.meta.resolve('better-sqlite3');if(_0x5675da){let _0x1655f6=_0xd6fe4d(_0x5675da);_0x254c53['unshift'](_0x531f45['dirname'](_0x531f45[_0x1a8718(0xe0)](_0x1655f6)));}}catch{}for(let _0xb74d55 of _0x254c53)if(_0x49cd3e[_0x1a8718(0x138)](_0x531f45['join'](_0xb74d55,_0x1a8718(0x13e))))return _0xb74d55;return null;}function N(_0xb5dc82){const _0x1a7135=_0x2d62c7;if(!_0xb5dc82)return null;let _0x4672c2=_0x531f45[_0x1a7135(0xe0)](_0xb5dc82);return _0x531f45['basename'](_0x4672c2)==='node_modules'?_0x531f45['dirname'](_0x4672c2):null;}function B(_0x21edc2){const _0x56f19a=_0x2d62c7;_0x2acfd4('node\x20-e\x20\x22require(\x27better-sqlite3\x27)(\x27:memory:\x27).close()\x22',{'cwd':_0x21edc2||process['cwd'](),'stdio':'pipe','env':{...process[_0x56f19a(0x11f)]}});}function k(_0x9120f5){const _0x37816f=_0x2d62c7;let _0x3c9886=N(_0x9120f5);if(!_0x3c9886||!_0x49cd3e['existsSync'](_0x531f45['join'](_0x3c9886,'package.json')))return console[_0x37816f(0x10a)](_0x37816f(0x14e)),!0x1;console[_0x37816f(0x145)](''),console['log'](_0x37816f(0x131)),console['log']('[INFO]\x20自动尝试本地编译:\x20在「'+_0x3c9886+_0x37816f(0xfa)),console[_0x37816f(0x145)]('[INFO]\x20(需本机已有\x20C++\x20构建环境;Windows\x20为\x20VS\x20Build\x20Tools,macOS\x20为\x20Xcode\x20CLT,Linux\x20为\x20build-essential)'),console[_0x37816f(0x145)]('[INFO]\x20━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');try{return _0x2acfd4('npm\x20rebuild\x20better-sqlite3\x20--foreground-scripts',{'cwd':_0x3c9886,'stdio':'inherit','env':{...process[_0x37816f(0x11f)]}}),B(_0x3c9886),console[_0x37816f(0x145)](_0x37816f(0xfc)),!0x0;}catch(_0x5ad0a5){let _0x4dfcd1=_0x5ad0a5&&typeof _0x5ad0a5==_0x37816f(0xeb)?_0x5ad0a5:{},_0x120bd2=_0x4dfcd1['stderr']?String(_0x4dfcd1['stderr']):'',_0x38a6a2=_0x4dfcd1['stdout']?String(_0x4dfcd1[_0x37816f(0x12e)]):'',_0x4a7e65=_0x120bd2||_0x38a6a2||(_0x5ad0a5&&_0x5ad0a5[_0x37816f(0xe2)]?String(_0x5ad0a5['message']):String(_0x5ad0a5));return console[_0x37816f(0x10a)]('[WARN]\x20npm\x20rebuild\x20未成功:\x20'+_0x4a7e65['slice'](0x0,0x4b0)+(_0x4a7e65['length']>0x4b0?'...':'')),!0x1;}}async function M(){const _0x57984b=_0x2d62c7;let _0xc9469a=E(),_0x5e4d92=L+'/v'+C+'/'+_0xc9469a;console[_0x57984b(0x145)](_0x57984b(0x123)+_0xc9469a);let _0x14cdc4=await v(_0x5e4d92);console['log']('[INFO]\x20下载成功\x20('+(_0x14cdc4['length']/0x400)[_0x57984b(0x13f)](0x1)+_0x57984b(0x13c));let _0x40227d=h();if(!_0x40227d)throw new Error(_0x57984b(0x117));let _0x7c2293=_0x531f45[_0x57984b(0x150)](_0x40227d,_0x57984b(0xd8),process[_0x57984b(0x11d)]+'-'+process[_0x57984b(0xf1)]);return _0x49cd3e['mkdirSync'](_0x7c2293,{'recursive':!0x0}),await D(_0x14cdc4,_0x7c2293),console[_0x57984b(0x145)]('[INFO]\x20预编译包已安装到:\x20'+_0x7c2293),!0x0;}async function W(){const _0x501fdb=_0x2d62c7;let _0x4cfead=(await import(_0x501fdb(0x127)))[_0x501fdb(0x11a)];return new _0x4cfead(':memory:')[_0x501fdb(0x14a)](),!0x0;}async function V(){const _0x1546bd=_0x2d62c7;try{let {DatabaseSync:_0x2c70eb}=await import(_0x1546bd(0xef));return new _0x2c70eb(_0x1546bd(0x12c))['close'](),!0x0;}catch{return!0x1;}}((async()=>{const _0x91d2af=_0x2d62c7;try{let _0x1782bc=_0xd6fe4d(import.meta.url),_0x279bc0=_0x531f45['dirname'](_0x1782bc),_0x5d645e='unknown',_0x30ad6e='';try{let _0x29a13e=_0x531f45['join'](_0x279bc0,'package.json');if(_0x49cd3e['existsSync'](_0x29a13e)){let _0x4e8a5e=JSON['parse'](_0x49cd3e['readFileSync'](_0x29a13e,'utf8'));_0x5d645e=_0x4e8a5e[_0x91d2af(0xe9)]||_0x91d2af(0xea),_0x30ad6e=typeof _0x4e8a5e[_0x91d2af(0xdb)]=='string'?_0x4e8a5e['acwInstallNote']:'';}}catch{}console[_0x91d2af(0x145)]('ACW\x20Tools\x20MCP\x20安装后检查...'),console[_0x91d2af(0x145)]('v'+_0x5d645e+'\x20|\x20Node\x20'+process[_0x91d2af(0xe9)]+_0x91d2af(0xf7)+b()+_0x91d2af(0x107)+process['platform']+'/'+process[_0x91d2af(0xf1)]),_0x30ad6e&&console[_0x91d2af(0x145)](_0x91d2af(0x142)+_0x30ad6e),await V()&&(console['log'](_0x91d2af(0x136)),console[_0x91d2af(0x145)]('[提示]\x20当前\x20'+process[_0x91d2af(0xe9)]+'\x20满足「内置\x20SQLite」路径:对话抓取不依赖\x20better-sqlite3,Windows\x20上无需\x20VS\x20Build\x20Tools\x20即可避免「模块编译失败」。'),x()||console['log']('[提示]\x20说明:检测通过但主版本号低于文档推荐的\x2022.5+,若日后升级\x20Node,请以实际是否仍含\x20node:sqlite\x20为准。'),console[_0x91d2af(0x145)]('[OK]\x20安装完成'),process[_0x91d2af(0x133)](0x0)),P();let _0x4b7c12=!0x1,_0x28b12a=null,_0x9a9286=[];try{await W(),console['log']('[OK]\x20better-sqlite3\x20加载成功'),_0x4b7c12=!0x0;}catch(_0x27da81){_0x28b12a=_0x27da81;let _0x3bdbb5=_0x27da81&&_0x27da81['message']?String(_0x27da81[_0x91d2af(0xe2)]):'',_0x7d7ba0=_0x3bdbb5['toLowerCase']();console['log']('[INFO]\x20better-sqlite3\x20原生加载失败:\x20'+_0x3bdbb5),_0x9a9286['push'](_0x91d2af(0x114)+_0x3bdbb5['slice'](0x0,0x1f4)+(_0x3bdbb5['length']>0x1f4?_0x91d2af(0xf0):'')),(_0x3bdbb5[_0x91d2af(0xda)]('Cannot\x20find\x20package')||_0x3bdbb5[_0x91d2af(0xda)]('ERR_MODULE_NOT_FOUND')||_0x3bdbb5[_0x91d2af(0xda)]('MODULE_NOT_FOUND'))&&_0x9a9286['push']('[原因]\x20better-sqlite3\x20未安装到位(多为\x20optional\x20依赖下载或编译失败);在\x20Node\x20低于\x2022.5\x20且无内置\x20SQLite\x20时会导致本步失败。');let _0x2d8d57=_0x3bdbb5[_0x91d2af(0xda)]('NODE_MODULE_VERSION')||_0x3bdbb5['includes']('was\x20compiled\x20against')||/\.node\b/[_0x91d2af(0xe5)](_0x3bdbb5)||_0x7d7ba0[_0x91d2af(0xda)](_0x91d2af(0x113))||_0x7d7ba0['includes'](_0x91d2af(0x127))||_0x7d7ba0[_0x91d2af(0xda)](_0x91d2af(0x120))||_0x7d7ba0[_0x91d2af(0xda)]('invalid\x20ELF')||_0x7d7ba0[_0x91d2af(0xda)]('not\x20a\x20valid\x20win32'),_0x4a4547=h(),_0x5e2db8=N(_0x4a4547);if(_0x9a9286[_0x91d2af(0x104)]('[环境]\x20Node='+process[_0x91d2af(0xe9)]+',process.versions.modules='+process['versions']['modules']+',映射\x20ABI='+b()+_0x91d2af(0x132)+process['platform']+'/'+process[_0x91d2af(0xf1)]),_0x9a9286['push'](_0x91d2af(0xec)+(_0x4a4547||_0x91d2af(0xfb))+_0x91d2af(0xe6)+(_0x5e2db8||_0x91d2af(0x124))),!_0x2d8d57)_0x9a9286['push']('[结论]\x20报错形态不像典型原生模块加载问题,未自动执行\x20OSS\x20/\x20rebuild,请根据完整堆栈排查。');else{let _0x1e111e=b();if(!$['includes'](_0x1e111e))_0x9a9286['push'](_0x91d2af(0x10f)+_0x1e111e+_0x91d2af(0x106)+$[_0x91d2af(0x150)](',\x20')+'],不会下载预编译包(避免错配二进制)。将尝试本机\x20npm\x20rebuild。'),console[_0x91d2af(0x145)]('[INFO]\x20当前\x20Node\x20'+process['version']+_0x91d2af(0x112)+_0x1e111e+')无对应\x20OSS\x20预编译包,跳过\x20OSS,将尝试本机编译');else{_0x9a9286['push']('[步骤]\x20ABI\x20'+_0x1e111e+'\x20在预编译列表内,尝试\x20OSS:\x20'+E()),console[_0x91d2af(0x145)](_0x91d2af(0x122));try{await M(),console[_0x91d2af(0x145)](_0x91d2af(0x108));try{let _0x4c5766=N(h())||_0x5e2db8||process[_0x91d2af(0xd7)]();B(_0x4c5766),console[_0x91d2af(0x145)](_0x91d2af(0x14f)),_0x4b7c12=!0x0,_0x9a9286['push']('[步骤]\x20OSS\x20预编译\x20+\x20子进程校验:\x20成功');}catch(_0x1b7411){_0x9a9286['push'](_0x91d2af(0xee)+(_0x1b7411['message']||_0x1b7411)),console[_0x91d2af(0x10a)](_0x91d2af(0xde)+_0x1b7411['message']);}}catch(_0x53cd02){_0x9a9286['push'](_0x91d2af(0x111)+(_0x53cd02['message']||_0x53cd02)),console[_0x91d2af(0x10a)]('[WARN]\x20OSS\x20预编译包下载或解压失败:\x20'+_0x53cd02[_0x91d2af(0xe2)]);}}!_0x4b7c12&&_0x4a4547?(_0x9a9286[_0x91d2af(0x104)](_0x91d2af(0xe1)),k(_0x4a4547)?(_0x4b7c12=!0x0,_0x9a9286[_0x91d2af(0x104)]('[步骤]\x20npm\x20rebuild:\x20成功')):_0x9a9286[_0x91d2af(0x104)](_0x91d2af(0x141))):!_0x4b7c12&&!_0x4a4547&&_0x9a9286[_0x91d2af(0x104)](_0x91d2af(0x14d));}}if(!_0x4b7c12){let _0x484053=_0x28b12a?.[_0x91d2af(0xe2)]||'未知错误';if(y(),console[_0x91d2af(0xe4)](''),console['error'](_0x91d2af(0x139)),console[_0x91d2af(0xe4)](_0x91d2af(0x14b)),console[_0x91d2af(0xe4)](_0x91d2af(0x139)),console['error'](''),console['error'](_0x91d2af(0xe3)),_0x9a9286['forEach'](_0x838ad8=>console[_0x91d2af(0xe4)](_0x838ad8)),console['error'](_0x91d2af(0x10d)),console['error'](''),console['error']('首错原文:\x20'+_0x484053),console[_0x91d2af(0xe4)](''),console[_0x91d2af(0xe4)](_0x91d2af(0xd6)),console['error'](_0x91d2af(0xf8)),console[_0x91d2af(0xe4)](_0x91d2af(0x11c)),console['error'](_0x91d2af(0x126)),console[_0x91d2af(0xe4)](''),console['error'](_0x91d2af(0xfd)),console[_0x91d2af(0xe4)](''),process[_0x91d2af(0x11d)]==='win32'){let _0x401e45=!0x1;try{_0x2acfd4('where\x20cl.exe',{'stdio':_0x91d2af(0xdf)}),_0x401e45=!0x0;}catch{}console[_0x91d2af(0xe4)](_0x401e45?_0x91d2af(0x10e)+_0x484053+_0x91d2af(0xe8):'我的\x20ACW\x20MCP\x20安装失败(better-sqlite3\x20/\x20原生模块),错误:'+_0x484053+_0x91d2af(0x12b));}else process['platform']===_0x91d2af(0x144)?console['error'](_0x91d2af(0x10e)+_0x484053+'。优先将\x20Node\x20升到\x2022.5+。否则\x20xcode-select\x20--install\x20后\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools\x20重装。'):console[_0x91d2af(0xe4)]('我的\x20ACW\x20MCP\x20安装失败(better-sqlite3\x20/\x20原生模块),错误:'+_0x484053+'。优先将\x20Node\x20升到\x2022.5+。否则\x20sudo\x20apt-get\x20install\x20build-essential\x20后\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools\x20重装。');console[_0x91d2af(0xe4)](''),console['error']('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'),process['exit'](0x1);}console[_0x91d2af(0x145)](_0x91d2af(0x10c)),console['log'](_0x91d2af(0x140));}catch(_0x4133b3){y(),console[_0x91d2af(0xe4)]('[ERROR]\x20postinstall\x20脚本执行出错:',_0x4133b3[_0x91d2af(0xe2)]),process['exit'](0x1);}})());
2
+ const _0xc9840b=_0x51a7;(function(_0x5466e2,_0x35edad){const _0xde2cd6=_0x51a7,_0x1fd1bb=_0x5466e2();while(!![]){try{const _0x470560=parseInt(_0xde2cd6(0x83))/0x1*(-parseInt(_0xde2cd6(0xcb))/0x2)+-parseInt(_0xde2cd6(0x7d))/0x3+parseInt(_0xde2cd6(0xb0))/0x4*(parseInt(_0xde2cd6(0xad))/0x5)+parseInt(_0xde2cd6(0xdb))/0x6*(-parseInt(_0xde2cd6(0x73))/0x7)+-parseInt(_0xde2cd6(0xab))/0x8+-parseInt(_0xde2cd6(0xb9))/0x9+parseInt(_0xde2cd6(0xba))/0xa;if(_0x470560===_0x35edad)break;else _0x1fd1bb['push'](_0x1fd1bb['shift']());}catch(_0x3b1199){_0x1fd1bb['push'](_0x1fd1bb['shift']());}}}(_0x1ffd,0xa0ac4));import _0xe9bce2 from'fs';import _0x5d0f27 from'path';import{fileURLToPath as _0x2619e8}from'url';import{execSync as _0x40d0ec}from'child_process';import _0x4ac43d from'https';import _0x4bf335 from'http';import _0x160985 from'zlib';var C='12.4.1',L='https://bd-acw.oss-cn-beijing.aliyuncs.com/prebuilds/better-sqlite3',F={0x12:'108',0x13:'111',0x14:'115',0x15:_0xc9840b(0xa7),0x16:_0xc9840b(0x95),0x17:'131',0x18:_0xc9840b(0xbe),0x19:'137'},$=['115',_0xc9840b(0x95),_0xc9840b(0xa4),_0xc9840b(0xbe)],I=parseInt(process['version'][_0xc9840b(0xa9)](0x1)[_0xc9840b(0x9b)]('.')[0x0],0xa),T=((()=>{const _0x5e47c9=_0xc9840b;let _0x2f0117=process[_0x5e47c9(0xd8)][_0x5e47c9(0xa9)](0x1)[_0x5e47c9(0x9b)]('.');return parseInt(_0x2f0117[0x1]||'0',0xa);})());function x(){return I>0x16||I===0x16&&T>=0x5;}function P(){const _0x3d59ae=_0xc9840b;console[_0x3d59ae(0x7a)](''),console['log'](_0x3d59ae(0x89)),console['log'](_0x3d59ae(0xc9)),console['log'](_0x3d59ae(0xc4)),console['log'](_0x3d59ae(0x70)),console[_0x3d59ae(0x7a)]('[提示]\x20【你当前的情况】当前为\x20'+process[_0x3d59ae(0xd8)]+_0x3d59ae(0x88)),console[_0x3d59ae(0x7a)](_0x3d59ae(0xbf)),console[_0x3d59ae(0x7a)](_0x3d59ae(0x94)),console[_0x3d59ae(0x7a)](_0x3d59ae(0xd7)),console[_0x3d59ae(0x7a)](_0x3d59ae(0xdc)),console[_0x3d59ae(0x7a)]('[提示]\x20【解决办法优先级】①\x20将运行\x20npx\x20的\x20Node\x20升级到\x2022.5+(最省事);②\x20安装对应系统的\x20C++\x20编译环境后再装本包;③\x20确保\x20Cursor\x20/\x20终端使用同一份\x20Node,避免\x20ABI\x20混用。'),console['log']('[提示]\x20━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'),console[_0x3d59ae(0x7a)]('');}function y(){const _0x229781=_0xc9840b;console[_0x229781(0xc7)](''),console['error'](_0x229781(0xdf)),console[_0x229781(0xc7)]('本步骤失败,几乎总是「可选依赖\x20better-sqlite3」的原生模块无法在您当前环境加载或编译。'),console['error'](_0x229781(0x6f)),console['error'](_0x229781(0x8c)),console['error']('package.json\x20中\x20engines\x20为\x20node>=20;要免编译、少踩坑,请以\x2022.5+\x20为准。'),console[_0x229781(0xc7)]('────────────────────────────────────────────');}function b(){const _0x321492=_0xc9840b;let _0x5cff5e=parseInt(process[_0x321492(0xd8)][_0x321492(0xa9)](0x1)[_0x321492(0x9b)]('.')[0x0],0xa);return F[_0x5cff5e]||process[_0x321492(0xd0)][_0x321492(0xe3)];}function E(){const _0xfb0ba7=_0xc9840b;let _0x174f5c=C,_0x152ba4=b(),_0x195c67=process[_0xfb0ba7(0x7b)],_0x1d7dc8=process['arch'];return'better-sqlite3-v'+_0x174f5c+'-node-v'+_0x152ba4+'-'+_0x195c67+'-'+_0x1d7dc8+_0xfb0ba7(0xbd);}function _0x1ffd(){const _0x4ed1bb=['[INFO]\x20当前\x20Node\x20','我的\x20ACW\x20MCP\x20安装失败(better-sqlite3\x20/\x20原生模块),错误:','split','\x20\x203)\x20再执行\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools。','catch','join','[WARN]\x20npm\x20rebuild\x20未成功:\x20',',process.versions.modules=','basename','[OK]\x20better-sqlite3\x20加载成功','──────────\x20诊断摘要(请整段复制给支持人员或\x20Cursor)──────────','131','未找到','node:sqlite','120','close','slice','[步骤]\x20OSS\x20预编译后子进程校验仍失败:\x20','6170008CqRUPN','无法找到\x20better-sqlite3\x20模块路径','8975tmJjaW','dirname','package.json','2108lydTqr','[结论]\x20报错形态不像典型原生模块加载问题,未自动执行\x20OSS\x20/\x20rebuild,请根据完整堆栈排查。','[OK]\x20安装完成',',npm\x20包根=','statusCode','[提示]\x20当前\x20','━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━','mkdirSync','existsSync','175059csbull','33951300ZPndSx','[步骤]\x20执行自动\x20npm\x20rebuild\x20better-sqlite3(本机源码编译)','说明:\x20已尝试\x20OSS\x20预编译与\x20npm\x20rebuild。仍失败时:务必把运行\x20npx\x20的\x20Node\x20升到\x2022.5+(内置\x20SQLite,从根上避免本问题)。其余检查:','.tar.gz','137','[提示]\x20【为什么会编译失败】better-sqlite3\x20含\x20C++\x20扩展(.node\x20文件)。常见原因:','better-sqlite3','readFileSync','invalid\x20ELF','length','[提示]\x20【推荐环境】请使用\x20Node.js\x2022.5\x20及以上(LTS\x2022\x20的最新小版本即可)。','\x20|\x20Node\x20','not\x20a\x20valid\x20win32','error','node\x20-e\x20\x22require(\x27better-sqlite3\x27)(\x27:memory:\x27).close()\x22','[提示]\x20【本包为什么要动\x20SQLite】需要读取\x20Cursor\x20本地的\x20state.vscdb(对话与\x20composer\x20数据)。',':memory:','2JEjEMx','首错原文:\x20','darwin','acwInstallNote','cwd','versions','[原因]\x20当前\x20ABI\x20',')无对应\x20OSS\x20预编译包,跳过\x20OSS,将尝试本机编译','pipe','」执行\x20npm\x20rebuild\x20better-sqlite3','\x20(ABI\x20','[OK]\x20better-sqlite3\x20修复成功(OSS\x20预编译)','[提示]\x20\x20\x20·\x20任意系统:执行\x20npx\x20的\x20Node\x20版本与当初编译该模块的\x20Node\x20ABI\x20不一致(报\x20NODE_MODULE_VERSION\x20/\x20was\x20compiled\x20against);','version','[步骤]\x20OSS\x20预编译\x20+\x20子进程校验:\x20成功','message','192162scmxOf','[提示]\x20\x20\x20·\x20公司网络拦截导致预编译包下载失败,被迫本地编译但本机无工具链。','warn','env','──────────\x20给用户的说明(安装失败)──────────','better_sqlite3','未解析','────────────────────────────────────────────────────────────','modules','[WARN]\x20无法确定\x20npm\x20包根目录,跳过\x20npm\x20rebuild','toString','[INFO]\x20预编译包已安装,重新测试...','[提示]\x20当前通过\x20better-sqlite3\x20完成检查。若希望免去原生依赖,可将\x20Node\x20升级到\x2022.5\x20及以上。','utf8','根因:它需要与本机\x20Node\x20版本匹配的\x20C++\x20二进制;Windows\x20上缺\x20VS\x20Build\x20Tools\x20时极易报错。','[提示]\x20\x20\x20该版本起\x20Node\x20内置「node:sqlite」,安装时无需\x20better-sqlite3,Windows\x20上可避免出现「模块编译失败」。','push','dlopen','168rHHjci','gunzipSync','writeFileSync','includes','[原因]\x20better-sqlite3\x20未安装到位(多为\x20optional\x20依赖下载或编译失败);在\x20Node\x20低于\x2022.5\x20且无内置\x20SQLite\x20时会导致本步失败。','replace','ERR_MODULE_NOT_FOUND','log','platform','[INFO]\x20检测到原生模块加载异常,尝试从\x20OSS\x20拉取匹配当前\x20ABI\x20的预编译包...','2972124LeVMaQ','object','string','arch','exit','node_modules','1132921kSIQNZ',',映射\x20ABI=','未知错误','\x20\x202)\x20若必须留在旧\x20Node:安装\x20C++\x20工具链后在包根目录执行\x20npm\x20rebuild\x20better-sqlite3\x20--foreground-scripts;','test',',未检测到可用的内置\x20node:sqlite(或运行时被禁用),因此走可选依赖\x20better-sqlite3。','[提示]\x20━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━','[INFO]\x20━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━','where\x20cl.exe','建议:将运行「npx\x20@bangdao-ai/acw-tools」的\x20Node\x20升级到\x2022.5\x20及以上,本包将改用内置\x20SQLite,一般不再需要编译。','parse','\x20在预编译列表内,尝试\x20OSS:\x20','[提示]\x20','stdout','unknown','\x20\x201)\x20终端执行\x20node\x20-v\x20与\x20Cursor\x20调起\x20MCP\x20用的是否为同一\x20Node;','fromCharCode','[提示]\x20\x20\x20·\x20Windows:未安装\x20Visual\x20Studio\x20Build\x20Tools(缺\x20cl.exe),node-gyp\x20无法编译;','127','destroy','...','was\x20compiled\x20against'];_0x1ffd=function(){return _0x4ed1bb;};return _0x1ffd();}function v(_0x3d2a31){return new Promise((_0x887f02,_0x59c51b)=>{const _0x5ed54b=_0x51a7;let _0x273efa=(_0x3d2a31['startsWith']('https')?_0x4ac43d:_0x4bf335)['get'](_0x3d2a31,{'timeout':0x7530},_0x4ba95a=>{const _0x4c5263=_0x51a7;if(_0x4ba95a['statusCode']===0x12d||_0x4ba95a[_0x4c5263(0xb4)]===0x12e){v(_0x4ba95a['headers']['location'])['then'](_0x887f02)[_0x4c5263(0x9d)](_0x59c51b);return;}if(_0x4ba95a[_0x4c5263(0xb4)]!==0xc8){_0x59c51b(new Error('HTTP\x20'+_0x4ba95a[_0x4c5263(0xb4)]));return;}let _0x12392=[];_0x4ba95a['on']('data',_0x4c2979=>_0x12392['push'](_0x4c2979)),_0x4ba95a['on']('end',()=>_0x887f02(Buffer['concat'](_0x12392))),_0x4ba95a['on'](_0x4c5263(0xc7),_0x59c51b);});_0x273efa['on'](_0x5ed54b(0xc7),_0x59c51b),_0x273efa['on']('timeout',()=>{const _0xf7ca25=_0x5ed54b;_0x273efa[_0xf7ca25(0x96)](),_0x59c51b(new Error('Request\x20timeout'));});});}async function D(_0x3ac1d2,_0x17c91d){const _0x41c036=_0xc9840b;let _0x493784=_0x160985[_0x41c036(0x74)](_0x3ac1d2),_0x5e93b7=0x200,_0x3cb12b=0x0;for(;_0x3cb12b<_0x493784['length']-_0x5e93b7;){let _0x3ffd22=_0x493784[_0x41c036(0xa9)](_0x3cb12b,_0x3cb12b+_0x5e93b7);if(_0x3ffd22[0x0]===0x0)break;let _0x502284=_0x3ffd22['slice'](0x0,0x64)[_0x41c036(0x6b)](_0x41c036(0x6e))['replace'](/\0/g,'')['trim'](),_0x5d4090=_0x3ffd22['slice'](0x7c,0x88)['toString']('utf8')[_0x41c036(0x78)](/\0/g,'')['trim'](),_0x55b7fe=parseInt(_0x5d4090,0x8)||0x0,_0x15477a=String[_0x41c036(0x93)](_0x3ffd22[0x9c]);if(_0x3cb12b+=_0x5e93b7,_0x502284&&_0x15477a==='0'||_0x15477a==='\x00'){let _0x2647ca=_0x493784['slice'](_0x3cb12b,_0x3cb12b+_0x55b7fe),_0x3b89e8=_0x5d0f27['join'](_0x17c91d,_0x5d0f27[_0x41c036(0xa1)](_0x502284));_0xe9bce2[_0x41c036(0xb7)](_0x5d0f27[_0x41c036(0xae)](_0x3b89e8),{'recursive':!0x0}),_0xe9bce2[_0x41c036(0x75)](_0x3b89e8,_0x2647ca);}_0x3cb12b+=Math['ceil'](_0x55b7fe/_0x5e93b7)*_0x5e93b7;}}function h(){const _0x3215e1=_0xc9840b;let _0x33e79a=[_0x5d0f27['join'](process['cwd'](),'node_modules',_0x3215e1(0xc0)),_0x5d0f27[_0x3215e1(0x9e)](_0x2619e8(import.meta.url),'..','node_modules',_0x3215e1(0xc0))];try{let _0x1ff793=import.meta.resolve('better-sqlite3');if(_0x1ff793){let _0x36301b=_0x2619e8(_0x1ff793);_0x33e79a['unshift'](_0x5d0f27[_0x3215e1(0xae)](_0x5d0f27[_0x3215e1(0xae)](_0x36301b)));}}catch{}for(let _0x1111be of _0x33e79a)if(_0xe9bce2[_0x3215e1(0xb8)](_0x5d0f27['join'](_0x1111be,_0x3215e1(0xaf))))return _0x1111be;return null;}function N(_0x18c13f){const _0xe36bb9=_0xc9840b;if(!_0x18c13f)return null;let _0x43a56b=_0x5d0f27['dirname'](_0x18c13f);return _0x5d0f27[_0xe36bb9(0xa1)](_0x43a56b)===_0xe36bb9(0x82)?_0x5d0f27['dirname'](_0x43a56b):null;}function B(_0x27f1f9){const _0x32f621=_0xc9840b;_0x40d0ec(_0x32f621(0xc8),{'cwd':_0x27f1f9||process[_0x32f621(0xcf)](),'stdio':'pipe','env':{...process[_0x32f621(0xde)]}});}function k(_0x3b1668){const _0x51c1cf=_0xc9840b;let _0x3fafb=N(_0x3b1668);if(!_0x3fafb||!_0xe9bce2[_0x51c1cf(0xb8)](_0x5d0f27['join'](_0x3fafb,_0x51c1cf(0xaf))))return console[_0x51c1cf(0xdd)](_0x51c1cf(0x6a)),!0x1;console[_0x51c1cf(0x7a)](''),console[_0x51c1cf(0x7a)](_0x51c1cf(0x8a)),console['log']('[INFO]\x20自动尝试本地编译:\x20在「'+_0x3fafb+_0x51c1cf(0xd4)),console['log']('[INFO]\x20(需本机已有\x20C++\x20构建环境;Windows\x20为\x20VS\x20Build\x20Tools,macOS\x20为\x20Xcode\x20CLT,Linux\x20为\x20build-essential)'),console['log'](_0x51c1cf(0x8a));try{return _0x40d0ec('npm\x20rebuild\x20better-sqlite3\x20--foreground-scripts',{'cwd':_0x3fafb,'stdio':'inherit','env':{...process[_0x51c1cf(0xde)]}}),B(_0x3fafb),console['log']('[OK]\x20npm\x20rebuild\x20成功,better-sqlite3\x20已可加载'),!0x0;}catch(_0x159c99){let _0x18d8a4=_0x159c99&&typeof _0x159c99==_0x51c1cf(0x7e)?_0x159c99:{},_0x2370d8=_0x18d8a4['stderr']?String(_0x18d8a4['stderr']):'',_0x3b1715=_0x18d8a4['stdout']?String(_0x18d8a4[_0x51c1cf(0x90)]):'',_0x10c873=_0x2370d8||_0x3b1715||(_0x159c99&&_0x159c99[_0x51c1cf(0xda)]?String(_0x159c99['message']):String(_0x159c99));return console[_0x51c1cf(0xdd)](_0x51c1cf(0x9f)+_0x10c873[_0x51c1cf(0xa9)](0x0,0x4b0)+(_0x10c873['length']>0x4b0?_0x51c1cf(0x97):'')),!0x1;}}async function M(){const _0x441418=_0xc9840b;let _0x3fb4b1=E(),_0x5ea4b5=L+'/v'+C+'/'+_0x3fb4b1;console[_0x441418(0x7a)]('[INFO]\x20尝试从\x20OSS\x20下载预编译包:\x20'+_0x3fb4b1);let _0x156a2f=await v(_0x5ea4b5);console['log']('[INFO]\x20下载成功\x20('+(_0x156a2f['length']/0x400)['toFixed'](0x1)+'\x20KB)');let _0x467f90=h();if(!_0x467f90)throw new Error(_0x441418(0xac));let _0x5ea1f9=_0x5d0f27[_0x441418(0x9e)](_0x467f90,'prebuilds',process[_0x441418(0x7b)]+'-'+process['arch']);return _0xe9bce2[_0x441418(0xb7)](_0x5ea1f9,{'recursive':!0x0}),await D(_0x156a2f,_0x5ea1f9),console[_0x441418(0x7a)]('[INFO]\x20预编译包已安装到:\x20'+_0x5ea1f9),!0x0;}async function W(){const _0x18adf9=_0xc9840b;let _0x3643d6=(await import(_0x18adf9(0xc0)))['default'];return new _0x3643d6(':memory:')[_0x18adf9(0xa8)](),!0x0;}function _0x51a7(_0x7b45fc,_0x380e2b){_0x7b45fc=_0x7b45fc-0x6a;const _0x1ffdfd=_0x1ffd();let _0x51a7ba=_0x1ffdfd[_0x7b45fc];return _0x51a7ba;}async function V(){const _0x1fd35e=_0xc9840b;try{let {DatabaseSync:_0x45df4b}=await import(_0x1fd35e(0xa6));return new _0x45df4b(_0x1fd35e(0xca))['close'](),!0x0;}catch{return!0x1;}}((async()=>{const _0x3b9f98=_0xc9840b;try{let _0x3c576d=_0x2619e8(import.meta.url),_0x5714c1=_0x5d0f27['dirname'](_0x3c576d),_0xa5f556='unknown',_0x4d3cfd='';try{let _0xd850d2=_0x5d0f27[_0x3b9f98(0x9e)](_0x5714c1,'package.json');if(_0xe9bce2[_0x3b9f98(0xb8)](_0xd850d2)){let _0x4e4cc8=JSON[_0x3b9f98(0x8d)](_0xe9bce2[_0x3b9f98(0xc1)](_0xd850d2,_0x3b9f98(0x6e)));_0xa5f556=_0x4e4cc8['version']||_0x3b9f98(0x91),_0x4d3cfd=typeof _0x4e4cc8[_0x3b9f98(0xce)]==_0x3b9f98(0x7f)?_0x4e4cc8[_0x3b9f98(0xce)]:'';}}catch{}console['log']('ACW\x20Tools\x20MCP\x20安装后检查...'),console[_0x3b9f98(0x7a)]('v'+_0xa5f556+_0x3b9f98(0xc5)+process[_0x3b9f98(0xd8)]+_0x3b9f98(0xd5)+b()+')\x20|\x20'+process['platform']+'/'+process[_0x3b9f98(0x80)]),_0x4d3cfd&&console['log'](_0x3b9f98(0x8f)+_0x4d3cfd),await V()&&(console['log']('[OK]\x20已检测到\x20Node\x20内置\x20node:sqlite,安装检查通过。'),console['log'](_0x3b9f98(0xb5)+process['version']+'\x20满足「内置\x20SQLite」路径:对话抓取不依赖\x20better-sqlite3,Windows\x20上无需\x20VS\x20Build\x20Tools\x20即可避免「模块编译失败」。'),x()||console[_0x3b9f98(0x7a)]('[提示]\x20说明:检测通过但主版本号低于文档推荐的\x2022.5+,若日后升级\x20Node,请以实际是否仍含\x20node:sqlite\x20为准。'),console[_0x3b9f98(0x7a)](_0x3b9f98(0xb2)),process['exit'](0x0)),P();let _0x121a41=!0x1,_0x297d42=null,_0x2dd2fc=[];try{await W(),console['log'](_0x3b9f98(0xa2)),_0x121a41=!0x0;}catch(_0x2b4d5c){_0x297d42=_0x2b4d5c;let _0x116c46=_0x2b4d5c&&_0x2b4d5c[_0x3b9f98(0xda)]?String(_0x2b4d5c['message']):'',_0x30b114=_0x116c46['toLowerCase']();console['log']('[INFO]\x20better-sqlite3\x20原生加载失败:\x20'+_0x116c46),_0x2dd2fc[_0x3b9f98(0x71)]('[原因]\x20首次加载失败(动态\x20import):\x20'+_0x116c46[_0x3b9f98(0xa9)](0x0,0x1f4)+(_0x116c46[_0x3b9f98(0xc3)]>0x1f4?_0x3b9f98(0x97):'')),(_0x116c46[_0x3b9f98(0x76)]('Cannot\x20find\x20package')||_0x116c46['includes'](_0x3b9f98(0x79))||_0x116c46[_0x3b9f98(0x76)]('MODULE_NOT_FOUND'))&&_0x2dd2fc['push'](_0x3b9f98(0x77));let _0x397439=_0x116c46[_0x3b9f98(0x76)]('NODE_MODULE_VERSION')||_0x116c46['includes'](_0x3b9f98(0x98))||/\.node\b/[_0x3b9f98(0x87)](_0x116c46)||_0x30b114['includes'](_0x3b9f98(0xe0))||_0x30b114['includes']('better-sqlite3')||_0x30b114[_0x3b9f98(0x76)](_0x3b9f98(0x72))||_0x30b114['includes'](_0x3b9f98(0xc2))||_0x30b114['includes'](_0x3b9f98(0xc6)),_0x744c7d=h(),_0x51a023=N(_0x744c7d);if(_0x2dd2fc['push']('[环境]\x20Node='+process[_0x3b9f98(0xd8)]+_0x3b9f98(0xa0)+process[_0x3b9f98(0xd0)]['modules']+_0x3b9f98(0x84)+b()+',平台='+process[_0x3b9f98(0x7b)]+'/'+process[_0x3b9f98(0x80)]),_0x2dd2fc['push']('[环境]\x20better-sqlite3\x20路径='+(_0x744c7d||_0x3b9f98(0xa5))+_0x3b9f98(0xb3)+(_0x51a023||_0x3b9f98(0xe1))),!_0x397439)_0x2dd2fc[_0x3b9f98(0x71)](_0x3b9f98(0xb1));else{let _0x2a9558=b();if(!$[_0x3b9f98(0x76)](_0x2a9558))_0x2dd2fc['push'](_0x3b9f98(0xd1)+_0x2a9558+'\x20不在\x20OSS\x20预编译列表\x20['+$[_0x3b9f98(0x9e)](',\x20')+'],不会下载预编译包(避免错配二进制)。将尝试本机\x20npm\x20rebuild。'),console[_0x3b9f98(0x7a)](_0x3b9f98(0x99)+process['version']+'(ABI\x20v'+_0x2a9558+_0x3b9f98(0xd2));else{_0x2dd2fc['push']('[步骤]\x20ABI\x20'+_0x2a9558+_0x3b9f98(0x8e)+E()),console['log'](_0x3b9f98(0x7c));try{await M(),console[_0x3b9f98(0x7a)](_0x3b9f98(0x6c));try{let _0x27df15=N(h())||_0x51a023||process[_0x3b9f98(0xcf)]();B(_0x27df15),console[_0x3b9f98(0x7a)](_0x3b9f98(0xd6)),_0x121a41=!0x0,_0x2dd2fc['push'](_0x3b9f98(0xd9));}catch(_0x51c85e){_0x2dd2fc[_0x3b9f98(0x71)](_0x3b9f98(0xaa)+(_0x51c85e[_0x3b9f98(0xda)]||_0x51c85e)),console[_0x3b9f98(0xdd)]('[WARN]\x20预编译包安装后测试失败:\x20'+_0x51c85e[_0x3b9f98(0xda)]);}}catch(_0xd4732e){_0x2dd2fc['push']('[步骤]\x20OSS\x20下载或解压失败:\x20'+(_0xd4732e['message']||_0xd4732e)),console['warn']('[WARN]\x20OSS\x20预编译包下载或解压失败:\x20'+_0xd4732e['message']);}}!_0x121a41&&_0x744c7d?(_0x2dd2fc['push'](_0x3b9f98(0xbb)),k(_0x744c7d)?(_0x121a41=!0x0,_0x2dd2fc[_0x3b9f98(0x71)]('[步骤]\x20npm\x20rebuild:\x20成功')):_0x2dd2fc[_0x3b9f98(0x71)]('[步骤]\x20npm\x20rebuild:\x20失败(见上方日志,多为缺少\x20cl.exe\x20/\x20Xcode\x20Command\x20Line\x20Tools\x20/\x20build-essential)')):!_0x121a41&&!_0x744c7d&&_0x2dd2fc['push']('[步骤]\x20未找到\x20better-sqlite3\x20目录,无法执行\x20npm\x20rebuild');}}if(!_0x121a41){let _0x54e63b=_0x297d42?.['message']||_0x3b9f98(0x85);if(y(),console['error'](''),console[_0x3b9f98(0xc7)]('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'),console['error']('[ERROR]\x20better-sqlite3\x20模块加载失败,安装中止'),console['error'](_0x3b9f98(0xb6)),console['error'](''),console[_0x3b9f98(0xc7)](_0x3b9f98(0xa3)),_0x2dd2fc['forEach'](_0x36adec=>console['error'](_0x36adec)),console[_0x3b9f98(0xc7)](_0x3b9f98(0xe2)),console['error'](''),console[_0x3b9f98(0xc7)](_0x3b9f98(0xcc)+_0x54e63b),console['error'](''),console[_0x3b9f98(0xc7)](_0x3b9f98(0xbc)),console[_0x3b9f98(0xc7)](_0x3b9f98(0x92)),console['error'](_0x3b9f98(0x86)),console[_0x3b9f98(0xc7)](_0x3b9f98(0x9c)),console['error'](''),console[_0x3b9f98(0xc7)]('复制以下提示词发送给\x20Cursor,让\x20AI\x20帮你修复:'),console['error'](''),process[_0x3b9f98(0x7b)]==='win32'){let _0x57adbc=!0x1;try{_0x40d0ec(_0x3b9f98(0x8b),{'stdio':_0x3b9f98(0xd3)}),_0x57adbc=!0x0;}catch{}console[_0x3b9f98(0xc7)](_0x57adbc?_0x3b9f98(0x9a)+_0x54e63b+'。优先请把运行\x20npx\x20的\x20Node\x20升级到\x2022.5\x20以上以使用内置\x20SQLite、避免编译。若暂不能升级:已装\x20VS\x20仍失败则执行\x20npm\x20cache\x20clean\x20--force\x20后\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools\x20重装。':_0x3b9f98(0x9a)+_0x54e63b+'。优先请把运行\x20npx\x20的\x20Node\x20升级到\x2022.5\x20以上(免装\x20VS\x20Build\x20Tools)。否则请安装\x20Visual\x20Studio\x20Build\x20Tools\x20后再\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools。');}else process[_0x3b9f98(0x7b)]===_0x3b9f98(0xcd)?console['error']('我的\x20ACW\x20MCP\x20安装失败(better-sqlite3\x20/\x20原生模块),错误:'+_0x54e63b+'。优先将\x20Node\x20升到\x2022.5+。否则\x20xcode-select\x20--install\x20后\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools\x20重装。'):console['error'](_0x3b9f98(0x9a)+_0x54e63b+'。优先将\x20Node\x20升到\x2022.5+。否则\x20sudo\x20apt-get\x20install\x20build-essential\x20后\x20npm\x20install\x20-g\x20@bangdao-ai/acw-tools\x20重装。');console['error'](''),console['error'](_0x3b9f98(0xb6)),process[_0x3b9f98(0x81)](0x1);}console[_0x3b9f98(0x7a)](_0x3b9f98(0x6d)),console['log']('[OK]\x20安装完成');}catch(_0x121715){y(),console['error']('[ERROR]\x20postinstall\x20脚本执行出错:',_0x121715[_0x3b9f98(0xda)]),process['exit'](0x1);}})());