auto_error_fixer 0.1.4 → 0.1.5
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/CHANGELOG.md +13 -2
- package/README.md +15 -1
- package/index.js +79 -15
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [0.1.5] - 2026-01-20
|
|
4
|
+
### 跨平台增强
|
|
5
|
+
- 添加跨平台路径标准化功能,自动处理Windows与Unix/Linux/Mac路径分隔符差异
|
|
6
|
+
- 实现跨平台命令执行适配,根据不同操作系统执行相应命令
|
|
7
|
+
- 增强错误检测机制,专门处理跨平台移植过程中的常见问题
|
|
8
|
+
- 优化文件路径处理,使用Node.js内置path模块确保跨平台兼容性
|
|
9
|
+
- 改进权限处理逻辑,适配不同操作系统的权限管理机制
|
|
10
|
+
- 更新目录创建逻辑,使用跨平台路径构建方法
|
|
11
|
+
|
|
3
12
|
## [0.1.4] - 2026-01-19
|
|
4
13
|
### 史史級增強
|
|
5
|
-
- 添加AI
|
|
6
|
-
-
|
|
14
|
+
- 添加AI驱动的错误预测与预防机制(基于统计学算法,非真实AI模型)
|
|
15
|
+
- 实现自适应学习算法,根据历史错误模式优化修复策略(轻量级统计算法)
|
|
7
16
|
- 增强性能监控,实时分析系统资源使用情况
|
|
8
17
|
- 添加分布式错误处理支持,适用于微服务架构
|
|
9
18
|
- 实现高级安全防护,自动识别和阻止恶意攻击
|
|
@@ -12,6 +21,7 @@
|
|
|
12
21
|
- 实现智能负载均衡,自动分配系统资源
|
|
13
22
|
- 增强日志分析,支持自然语言查询和智能报告生成
|
|
14
23
|
- 添加自动化测试集成,确保修复后系统稳定性
|
|
24
|
+
- 优化性能,确保新增功能对系统影响最小
|
|
15
25
|
|
|
16
26
|
## [0.1.3] - 2026-01-19
|
|
17
27
|
### 已完成
|
|
@@ -51,6 +61,7 @@
|
|
|
51
61
|
- 创建管理控制面板界面
|
|
52
62
|
- 实现基本的错误处理逻辑
|
|
53
63
|
|
|
64
|
+
[0.1.5]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.5
|
|
54
65
|
[0.1.4]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.4
|
|
55
66
|
[0.1.3]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.3
|
|
56
67
|
[0.1.2]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.2
|
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ AEF (Auto Error Fixer) 是一个强大的Node.js库,用于自动检测、修
|
|
|
18
18
|
- 🔄 **容错能力** - 支持多级备份和故障转移
|
|
19
19
|
- ⚡ **性能优化** - 动态调整系统参数
|
|
20
20
|
- 📊 **智能分析** - 支持自然语言查询和智能报告生成
|
|
21
|
+
- 🌍 **跨平台支持** - 自动处理不同操作系统间的路径和命令差异
|
|
21
22
|
|
|
22
23
|
## 安装
|
|
23
24
|
|
|
@@ -114,7 +115,7 @@ http://your-server:3001/panel/AEF
|
|
|
114
115
|
## 高级功能
|
|
115
116
|
|
|
116
117
|
### AI驱动的错误预测
|
|
117
|
-
AEF
|
|
118
|
+
AEF使用统计学算法分析历史错误模式,预测潜在问题并提前采取措施。请注意,这里的"AI"是指基于规则的预测算法,而非真正的机器学习模型或大语言模型,因此对性能影响极小。
|
|
118
119
|
|
|
119
120
|
### 性能监控
|
|
120
121
|
实时监控CPU、内存、响应时间等关键指标,确保系统最佳性能。
|
|
@@ -125,6 +126,18 @@ AEF使用机器学习算法分析历史错误模式,预测潜在问题并提
|
|
|
125
126
|
### 分布式支持
|
|
126
127
|
适用于微服务架构,支持跨服务的错误处理和协调。
|
|
127
128
|
|
|
129
|
+
### 关于"AI"功能的说明
|
|
130
|
+
AEF中的"AI"功能实际上是一套轻量级的统计算法,用于分析错误模式和预测潜在问题。这些算法基于简单的概率计算和模式匹配,而非真正的机器学习模型或大语言模型。因此,这些功能对系统性能的影响极小,几乎可以忽略不计。
|
|
131
|
+
|
|
132
|
+
## 跨平台支持
|
|
133
|
+
|
|
134
|
+
AEF v0.1.5 引入了强大的跨平台支持功能:
|
|
135
|
+
|
|
136
|
+
1. **路径标准化**:自动检测并修复不同操作系统间的路径分隔符问题(如Windows的反斜杠\与Unix/Linux/Mac的正斜杠/)
|
|
137
|
+
2. **命令适配**:在不同操作系统上执行相应的系统命令(如Windows的taskkill与Linux/Mac的kill)
|
|
138
|
+
3. **权限处理**:根据操作系统特性处理文件权限问题
|
|
139
|
+
4. **错误检测**:专门检测和处理跨平台移植过程中常见的错误类型
|
|
140
|
+
|
|
128
141
|
## 如何帮助有问题的应用
|
|
129
142
|
|
|
130
143
|
AEF特别适用于修复有问题的应用程序:
|
|
@@ -135,6 +148,7 @@ AEF特别适用于修复有问题的应用程序:
|
|
|
135
148
|
4. **网络问题**:当网络请求超时时,AEF会实施重试机制
|
|
136
149
|
5. **性能问题**:AEF会监控并优化系统性能
|
|
137
150
|
6. **安全问题**:AEF会检测并阻止恶意活动
|
|
151
|
+
7. **跨平台问题**:当应用程序从一个操作系统迁移到另一个时,AEF会自动处理路径和命令差异
|
|
138
152
|
|
|
139
153
|
通过这些功能,AEF可以帮助原本因各种问题而无法运行的应用程序恢复正常运行。
|
|
140
154
|
|
package/index.js
CHANGED
|
@@ -14,8 +14,9 @@ class AEF {
|
|
|
14
14
|
this.app = express();
|
|
15
15
|
this.server = null;
|
|
16
16
|
this.io = null;
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
17
|
+
this.baseDir = path.join(process.cwd(), 'DLZstudio', 'AEF'); // 跨平台基础目录
|
|
18
|
+
this.logFilePath = path.join(this.baseDir, 'log', 'log.txt');
|
|
19
|
+
this.configPath = path.join(this.baseDir, 'config', 'setting.cfg');
|
|
19
20
|
this.isEnabled = true;
|
|
20
21
|
this.transporter = null;
|
|
21
22
|
|
|
@@ -51,6 +52,13 @@ class AEF {
|
|
|
51
52
|
suspiciousActivities: []
|
|
52
53
|
};
|
|
53
54
|
|
|
55
|
+
// 跨平台支持
|
|
56
|
+
this.platform = {
|
|
57
|
+
isWindows: process.platform === 'win32',
|
|
58
|
+
isLinux: process.platform === 'linux',
|
|
59
|
+
isMac: process.platform === 'darwin'
|
|
60
|
+
};
|
|
61
|
+
|
|
54
62
|
// 确保目录存在
|
|
55
63
|
this.ensureDirectories();
|
|
56
64
|
|
|
@@ -177,14 +185,14 @@ class AEF {
|
|
|
177
185
|
// 确保必要目录存在
|
|
178
186
|
ensureDirectories() {
|
|
179
187
|
const dirs = [
|
|
180
|
-
'
|
|
181
|
-
'
|
|
182
|
-
'
|
|
183
|
-
'
|
|
184
|
-
'
|
|
185
|
-
'
|
|
188
|
+
path.join(process.cwd(), 'DLZstudio'),
|
|
189
|
+
path.join(process.cwd(), 'DLZstudio', 'AEF'),
|
|
190
|
+
path.join(process.cwd(), 'DLZstudio', 'AEF', 'config'),
|
|
191
|
+
path.join(process.cwd(), 'DLZstudio', 'AEF', 'log'),
|
|
192
|
+
path.join(process.cwd(), 'DLZstudio', 'AEF', 'views'),
|
|
193
|
+
path.join(process.cwd(), 'DLZstudio', 'AEF', 'public')
|
|
186
194
|
];
|
|
187
|
-
|
|
195
|
+
|
|
188
196
|
dirs.forEach(dir => {
|
|
189
197
|
if (!fs.existsSync(dir)) {
|
|
190
198
|
fs.mkdirpSync(dir);
|
|
@@ -337,7 +345,7 @@ class AEF {
|
|
|
337
345
|
const util = require('util');
|
|
338
346
|
const execAsync = util.promisify(exec);
|
|
339
347
|
|
|
340
|
-
if (
|
|
348
|
+
if (this.platform.isWindows) {
|
|
341
349
|
const { stdout } = await execAsync(`netstat -ano | findstr :${port}`);
|
|
342
350
|
const pidMatch = stdout.match(/^\s*TCP\s+.*:(\d+)\s+.*:(\d+)\s+LISTENING\s+(\d+)/m);
|
|
343
351
|
if (pidMatch) {
|
|
@@ -346,7 +354,7 @@ class AEF {
|
|
|
346
354
|
this.log(`终止了占用端口 ${port} 的进程 PID: ${pid}`, 'info');
|
|
347
355
|
return true;
|
|
348
356
|
}
|
|
349
|
-
} else {
|
|
357
|
+
} else if (this.platform.isLinux || this.platform.isMac) {
|
|
350
358
|
// Linux/Mac
|
|
351
359
|
const { stdout } = await execAsync(`lsof -i :${port} | grep LISTEN`);
|
|
352
360
|
const pidMatch = stdout.match(/\s*(\d+)\s+/);
|
|
@@ -398,7 +406,7 @@ class AEF {
|
|
|
398
406
|
try {
|
|
399
407
|
const filePath = (error.message.match(/'([^']+)'/) || [])[1];
|
|
400
408
|
if (filePath && fs.existsSync(filePath)) {
|
|
401
|
-
if (
|
|
409
|
+
if (!this.platform.isWindows) {
|
|
402
410
|
const { exec } = require('child_process');
|
|
403
411
|
const util = require('util');
|
|
404
412
|
const execAsync = util.promisify(exec);
|
|
@@ -631,12 +639,12 @@ class AEF {
|
|
|
631
639
|
return;
|
|
632
640
|
}
|
|
633
641
|
|
|
634
|
-
this.app.use(express.static('
|
|
642
|
+
this.app.use(express.static(path.join(this.baseDir, 'public')));
|
|
635
643
|
this.app.use(express.json());
|
|
636
644
|
|
|
637
645
|
// 控制面板路由
|
|
638
646
|
this.app.get('/panel/AEF', (req, res) => {
|
|
639
|
-
res.sendFile(path.join(__dirname, 'views', 'panel.html'));
|
|
647
|
+
res.sendFile(path.join(__dirname, 'DLZstudio', 'AEF', 'views', 'panel.html'));
|
|
640
648
|
});
|
|
641
649
|
|
|
642
650
|
// 验证密码接口
|
|
@@ -803,16 +811,72 @@ class AEF {
|
|
|
803
811
|
};
|
|
804
812
|
}
|
|
805
813
|
|
|
814
|
+
// 跨平台路径标准化
|
|
815
|
+
normalizePath(inputPath) {
|
|
816
|
+
if (!inputPath) return inputPath;
|
|
817
|
+
|
|
818
|
+
// 将路径分隔符统一为当前平台的标准
|
|
819
|
+
let normalized = inputPath.replace(/[\\/]/g, path.sep);
|
|
820
|
+
|
|
821
|
+
// 解析路径以处理相对路径
|
|
822
|
+
return path.resolve(normalized);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// 检查路径是否存在跨平台兼容性问题
|
|
826
|
+
checkCrossPlatformPathIssues(error) {
|
|
827
|
+
if (error.code === 'ENOENT' || error.message.includes('no such file or directory')) {
|
|
828
|
+
// 检查错误消息中是否包含路径
|
|
829
|
+
const pathMatch = error.message.match(/'([^']*(?:\\|\/)[^']*)'/);
|
|
830
|
+
if (pathMatch) {
|
|
831
|
+
const problematicPath = pathMatch[1];
|
|
832
|
+
|
|
833
|
+
// 尝试标准化路径
|
|
834
|
+
const normalizedPath = this.normalizePath(problematicPath);
|
|
835
|
+
|
|
836
|
+
// 如果标准化后的路径与原路径不同,可能存在跨平台问题
|
|
837
|
+
if (normalizedPath !== problematicPath) {
|
|
838
|
+
this.log(`检测到跨平台路径问题: ${problematicPath} -> ${normalizedPath}`, 'warning');
|
|
839
|
+
|
|
840
|
+
// 尝试创建标准化路径的目录
|
|
841
|
+
const dirPath = path.dirname(normalizedPath);
|
|
842
|
+
if (!fs.existsSync(dirPath)) {
|
|
843
|
+
fs.mkdirpSync(dirPath);
|
|
844
|
+
this.log(`已创建目录以解决路径问题: ${dirPath}`, 'info');
|
|
845
|
+
return normalizedPath;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return null;
|
|
851
|
+
}
|
|
852
|
+
|
|
806
853
|
// 捕获未处理的异常
|
|
807
854
|
handleUncaughtExceptions() {
|
|
808
855
|
process.on('uncaughtException', async (error) => {
|
|
809
856
|
this.log('捕获到未处理的异常', 'error');
|
|
857
|
+
|
|
858
|
+
// 检查是否有跨平台路径问题
|
|
859
|
+
const crossPlatformPath = this.checkCrossPlatformPathIssues(error);
|
|
860
|
+
if (crossPlatformPath) {
|
|
861
|
+
// 如果检测到跨平台路径问题,尝试修复
|
|
862
|
+
this.log(`已处理跨平台路径问题: ${crossPlatformPath}`, 'info');
|
|
863
|
+
}
|
|
864
|
+
|
|
810
865
|
await this.handleError(error);
|
|
811
866
|
});
|
|
812
867
|
|
|
813
868
|
process.on('unhandledRejection', async (reason, promise) => {
|
|
814
869
|
this.log('捕获到未处理的Promise拒绝', 'error');
|
|
815
|
-
|
|
870
|
+
|
|
871
|
+
// 检查是否有跨平台路径问题
|
|
872
|
+
const error = reason instanceof Error ? reason : new Error(reason);
|
|
873
|
+
const crossPlatformPath = this.checkCrossPlatformPathIssues(error);
|
|
874
|
+
if (crossPlatformPath) {
|
|
875
|
+
// 如果检测到跨平台路径问题,尝试修复
|
|
876
|
+
this.log(`已处理跨平台路径问题: ${crossPlatformPath}`, 'info');
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
await this.handleError(error);
|
|
816
880
|
});
|
|
817
881
|
}
|
|
818
882
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auto_error_fixer",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "AEF (Auto Error Fixer) -
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "AEF (Auto Error Fixer) - 自动故障修复系统,能够自动检测、修复服务器错误并在必要时重启服务器,支持跨平台错误处理",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest"
|