cheatengine 5.8.13 → 5.8.14
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/bin/cheatengine +38 -4
- package/package.json +1 -1
package/bin/cheatengine
CHANGED
|
@@ -4,10 +4,18 @@
|
|
|
4
4
|
* 调用Python运行ce_mcp_server.py
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const { spawn } = require('child_process');
|
|
7
|
+
const { spawn, execSync } = require('child_process');
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
|
|
11
|
+
// 调试模式
|
|
12
|
+
const DEBUG = process.env.DEBUG === '1';
|
|
13
|
+
function log(...args) {
|
|
14
|
+
if (DEBUG) console.error('[cheatengine]', ...args);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
log('Starting cheatengine wrapper...');
|
|
18
|
+
|
|
11
19
|
// 找到包根目录(兼容 npx/npm install 各种情况)
|
|
12
20
|
function findPackageRoot() {
|
|
13
21
|
// 方法1: 通过 package.json 定位
|
|
@@ -21,7 +29,10 @@ function findPackageRoot() {
|
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
const packageRoot = findPackageRoot();
|
|
32
|
+
log('Package root:', packageRoot);
|
|
33
|
+
|
|
24
34
|
const pythonScript = path.join(packageRoot, 'ce_mcp_server.py');
|
|
35
|
+
log('Python script path:', pythonScript);
|
|
25
36
|
|
|
26
37
|
// 验证Python脚本存在
|
|
27
38
|
if (!fs.existsSync(pythonScript)) {
|
|
@@ -31,20 +42,38 @@ if (!fs.existsSync(pythonScript)) {
|
|
|
31
42
|
process.exit(1);
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
// 检测Python命令
|
|
35
|
-
|
|
45
|
+
// 检测Python命令 - Windows上尝试多个选项
|
|
46
|
+
let pythonCmd = 'python';
|
|
47
|
+
if (process.platform === 'win32') {
|
|
48
|
+
// Windows: 尝试 python, python3, py
|
|
49
|
+
for (const cmd of ['python', 'python3', 'py']) {
|
|
50
|
+
try {
|
|
51
|
+
execSync(`${cmd} --version`, { stdio: 'ignore' });
|
|
52
|
+
pythonCmd = cmd;
|
|
53
|
+
log('Found Python:', cmd);
|
|
54
|
+
break;
|
|
55
|
+
} catch (e) {
|
|
56
|
+
// 尝试下一个
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
log('Using Python command:', pythonCmd);
|
|
36
62
|
|
|
37
63
|
const proc = spawn(pythonCmd, [pythonScript], {
|
|
38
64
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
39
65
|
windowsHide: true
|
|
40
66
|
});
|
|
41
67
|
|
|
68
|
+
log('Python process spawned, PID:', proc.pid);
|
|
69
|
+
|
|
42
70
|
// 透传stdin/stdout/stderr
|
|
43
71
|
process.stdin.pipe(proc.stdin);
|
|
44
72
|
proc.stdout.pipe(process.stdout);
|
|
45
73
|
proc.stderr.pipe(process.stderr);
|
|
46
74
|
|
|
47
|
-
proc.on('exit', (code) => {
|
|
75
|
+
proc.on('exit', (code, signal) => {
|
|
76
|
+
log('Python process exited, code:', code, 'signal:', signal);
|
|
48
77
|
process.exit(code ?? 0);
|
|
49
78
|
});
|
|
50
79
|
|
|
@@ -53,3 +82,8 @@ proc.on('error', (err) => {
|
|
|
53
82
|
console.error('请确保已安装Python和pywin32: pip install pywin32');
|
|
54
83
|
process.exit(1);
|
|
55
84
|
});
|
|
85
|
+
|
|
86
|
+
// 如果3秒内没有退出,说明启动成功
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
log('Python process still running after 3s');
|
|
89
|
+
}, 3000);
|