auto_error_fixer 0.1.4 → 0.1.6

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 CHANGED
@@ -1,9 +1,24 @@
1
1
  # 更新日志
2
2
 
3
+ ## [0.1.6] - 2026-01-22
4
+ ### 功能变更
5
+ - 修改面板访问端口从3001到7210
6
+ - 修改面板访问路径从/panel/AEF更改为/AEF/panel
7
+ - 保持原有文件路径结构不变
8
+
9
+ ## [0.1.5] - 2026-01-20
10
+ ### 跨平台增强
11
+ - 添加跨平台路径标准化功能,自动处理Windows与Unix/Linux/Mac路径分隔符差异
12
+ - 实现跨平台命令执行适配,根据不同操作系统执行相应命令
13
+ - 增强错误检测机制,专门处理跨平台移植过程中的常见问题
14
+ - 优化文件路径处理,使用Node.js内置path模块确保跨平台兼容性
15
+ - 改进权限处理逻辑,适配不同操作系统的权限管理机制
16
+ - 更新目录创建逻辑,使用跨平台路径构建方法
17
+
3
18
  ## [0.1.4] - 2026-01-19
4
19
  ### 史史級增強
5
- - 添加AI驱动的错误预测与预防机制
6
- - 实现自适应学习算法,根据历史错误模式优化修复策略
20
+ - 添加AI驱动的错误预测与预防机制(基于统计学算法,非真实AI模型)
21
+ - 实现自适应学习算法,根据历史错误模式优化修复策略(轻量级统计算法)
7
22
  - 增强性能监控,实时分析系统资源使用情况
8
23
  - 添加分布式错误处理支持,适用于微服务架构
9
24
  - 实现高级安全防护,自动识别和阻止恶意攻击
@@ -12,6 +27,7 @@
12
27
  - 实现智能负载均衡,自动分配系统资源
13
28
  - 增强日志分析,支持自然语言查询和智能报告生成
14
29
  - 添加自动化测试集成,确保修复后系统稳定性
30
+ - 优化性能,确保新增功能对系统影响最小
15
31
 
16
32
  ## [0.1.3] - 2026-01-19
17
33
  ### 已完成
@@ -51,6 +67,8 @@
51
67
  - 创建管理控制面板界面
52
68
  - 实现基本的错误处理逻辑
53
69
 
70
+ [0.1.6]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.6
71
+ [0.1.5]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.5
54
72
  [0.1.4]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.4
55
73
  [0.1.3]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.3
56
74
  [0.1.2]: https://github.com/DLZstudio/AEF/releases/tag/v0.1.2
@@ -1,5 +1,2 @@
1
- qwen --resume 076143e9-f5d8-461d-a15a-c63e02ff9f9c
1
+ qwen --resume 8ce8fb1a-6330-49a0-9718-689b6b84c99c
2
2
 
3
- qwen --resume 82d0a245-483e-49ab-b7b0-8e1046790edd
4
-
5
- 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
@@ -441,7 +441,7 @@
441
441
  const password = passwordInput.value;
442
442
 
443
443
  try {
444
- const response = await fetch('/panel/AEF/login', {
444
+ const response = await fetch('/AEF/panel/login', {
445
445
  method: 'POST',
446
446
  headers: {
447
447
  'Content-Type': 'application/json'
@@ -477,7 +477,7 @@
477
477
  // 加载状态数据
478
478
  async function loadStatusData() {
479
479
  try {
480
- const response = await fetch('/panel/AEF/status');
480
+ const response = await fetch('/AEF/panel/status');
481
481
  const data = await response.json();
482
482
 
483
483
  // 更新状态指示器
@@ -515,7 +515,7 @@
515
515
  // 加载配置数据
516
516
  async function loadConfigData() {
517
517
  try {
518
- const response = await fetch('/panel/AEF/config');
518
+ const response = await fetch('/AEF/panel/config');
519
519
  const data = await response.json();
520
520
 
521
521
  if (data.content) {
@@ -531,7 +531,7 @@
531
531
  try {
532
532
  const content = configEditor.value;
533
533
 
534
- const response = await fetch('/panel/AEF/config', {
534
+ const response = await fetch('/AEF/panel/config', {
535
535
  method: 'POST',
536
536
  headers: {
537
537
  'Content-Type': 'application/json'
@@ -564,7 +564,7 @@
564
564
  // 切换AEF状态
565
565
  toggleAefBtn.addEventListener('click', async () => {
566
566
  try {
567
- const response = await fetch('/panel/AEF/toggle', {
567
+ const response = await fetch('/AEF/panel/toggle', {
568
568
  method: 'POST',
569
569
  headers: {
570
570
  'Content-Type': 'application/json'
@@ -606,7 +606,7 @@
606
606
  if (!isLoggedIn) return;
607
607
 
608
608
  try {
609
- const response = await fetch('/panel/AEF/log');
609
+ const response = await fetch('/AEF/panel/log');
610
610
  const data = await response.json();
611
611
 
612
612
  if (data.log !== currentLogContent) {
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
 
@@ -111,10 +112,19 @@ http://your-server:3001/panel/AEF
111
112
  - 手动启用/禁用AEF
112
113
  - 手动重启服务器
113
114
 
115
+ ## 访问控制面板
116
+
117
+ AEF提供了一个Web管理界面,可通过以下URL访问:
118
+ ```
119
+ http://your-server:7210/AEF/panel
120
+ ```
121
+
122
+ 默认密码是 `123456`(可在配置文件中修改)。
123
+
114
124
  ## 高级功能
115
125
 
116
126
  ### AI驱动的错误预测
117
- AEF使用机器学习算法分析历史错误模式,预测潜在问题并提前采取措施。
127
+ AEF使用统计学算法分析历史错误模式,预测潜在问题并提前采取措施。请注意,这里的"AI"是指基于规则的预测算法,而非真正的机器学习模型或大语言模型,因此对性能影响极小。
118
128
 
119
129
  ### 性能监控
120
130
  实时监控CPU、内存、响应时间等关键指标,确保系统最佳性能。
@@ -125,6 +135,18 @@ AEF使用机器学习算法分析历史错误模式,预测潜在问题并提
125
135
  ### 分布式支持
126
136
  适用于微服务架构,支持跨服务的错误处理和协调。
127
137
 
138
+ ### 关于"AI"功能的说明
139
+ AEF中的"AI"功能实际上是一套轻量级的统计算法,用于分析错误模式和预测潜在问题。这些算法基于简单的概率计算和模式匹配,而非真正的机器学习模型或大语言模型。因此,这些功能对系统性能的影响极小,几乎可以忽略不计。
140
+
141
+ ## 跨平台支持
142
+
143
+ AEF v0.1.5 引入了强大的跨平台支持功能:
144
+
145
+ 1. **路径标准化**:自动检测并修复不同操作系统间的路径分隔符问题(如Windows的反斜杠\与Unix/Linux/Mac的正斜杠/)
146
+ 2. **命令适配**:在不同操作系统上执行相应的系统命令(如Windows的taskkill与Linux/Mac的kill)
147
+ 3. **权限处理**:根据操作系统特性处理文件权限问题
148
+ 4. **错误检测**:专门检测和处理跨平台移植过程中常见的错误类型
149
+
128
150
  ## 如何帮助有问题的应用
129
151
 
130
152
  AEF特别适用于修复有问题的应用程序:
@@ -135,6 +157,7 @@ AEF特别适用于修复有问题的应用程序:
135
157
  4. **网络问题**:当网络请求超时时,AEF会实施重试机制
136
158
  5. **性能问题**:AEF会监控并优化系统性能
137
159
  6. **安全问题**:AEF会检测并阻止恶意活动
160
+ 7. **跨平台问题**:当应用程序从一个操作系统迁移到另一个时,AEF会自动处理路径和命令差异
138
161
 
139
162
  通过这些功能,AEF可以帮助原本因各种问题而无法运行的应用程序恢复正常运行。
140
163
 
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.logFilePath = './DLZstudio/AEF/log/log.txt';
18
- this.configPath = './DLZstudio/AEF/config/setting.cfg';
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
- './DLZstudio',
181
- './DLZstudio/AEF',
182
- './DLZstudio/AEF/config',
183
- './DLZstudio/AEF/log',
184
- './DLZstudio/AEF/views',
185
- './DLZstudio/AEF/public'
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 (process.platform === 'win32') {
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 (process.platform !== 'win32') {
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,16 +639,16 @@ class AEF {
631
639
  return;
632
640
  }
633
641
 
634
- this.app.use(express.static('./DLZstudio/AEF/public'));
642
+ this.app.use(express.static(path.join(this.baseDir, 'public')));
635
643
  this.app.use(express.json());
636
644
 
637
645
  // 控制面板路由
638
- this.app.get('/panel/AEF', (req, res) => {
639
- res.sendFile(path.join(__dirname, 'views', 'panel.html'));
646
+ this.app.get('/AEF/panel', (req, res) => {
647
+ res.sendFile(path.join(__dirname, 'DLZstudio', 'AEF', 'views', 'panel.html'));
640
648
  });
641
649
 
642
650
  // 验证密码接口
643
- this.app.post('/panel/AEF/login', (req, res) => {
651
+ this.app.post('/AEF/panel/login', (req, res) => {
644
652
  const { password } = req.body;
645
653
  if (password === this.config.password) {
646
654
  res.json({ success: true });
@@ -650,7 +658,7 @@ class AEF {
650
658
  });
651
659
 
652
660
  // 获取状态接口
653
- this.app.get('/panel/AEF/status', (req, res) => {
661
+ this.app.get('/AEF/panel/status', (req, res) => {
654
662
  res.json({
655
663
  isEnabled: this.isEnabled,
656
664
  config: this.config,
@@ -672,18 +680,18 @@ class AEF {
672
680
  });
673
681
 
674
682
  // 切换AEF状态接口
675
- this.app.post('/panel/AEF/toggle', (req, res) => {
683
+ this.app.post('/AEF/panel/toggle', (req, res) => {
676
684
  this.isEnabled = !this.isEnabled;
677
685
  res.json({ success: true, isEnabled: this.isEnabled });
678
686
  });
679
687
 
680
688
  // 获取日志接口
681
- this.app.get('/panel/AEF/log', (req, res) => {
689
+ this.app.get('/AEF/panel/log', (req, res) => {
682
690
  res.json({ log: this.getLog() });
683
691
  });
684
692
 
685
693
  // 获取配置文件内容
686
- this.app.get('/panel/AEF/config', (req, res) => {
694
+ this.app.get('/AEF/panel/config', (req, res) => {
687
695
  try {
688
696
  const configContent = fs.readFileSync(this.configPath, 'utf8');
689
697
  res.json({ content: configContent });
@@ -693,7 +701,7 @@ class AEF {
693
701
  });
694
702
 
695
703
  // 更新配置文件内容
696
- this.app.post('/panel/AEF/config', (req, res) => {
704
+ this.app.post('/AEF/panel/config', (req, res) => {
697
705
  try {
698
706
  const { content } = req.body;
699
707
  fs.writeFileSync(this.configPath, content);
@@ -722,7 +730,7 @@ class AEF {
722
730
  });
723
731
  });
724
732
 
725
- const port = process.env.AEF_PANEL_PORT || 3001;
733
+ const port = process.env.AEF_PANEL_PORT || 7210;
726
734
  this.server.listen(port, () => {
727
735
  this.log(`AEF控制面板已在端口 ${port} 上启动`, 'info');
728
736
  });
@@ -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
- await this.handleError(reason instanceof Error ? reason : new Error(reason));
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",
4
- "description": "AEF (Auto Error Fixer) - 自动故障修复系统,能够自动检测、修复服务器错误并在必要时重启服务器",
3
+ "version": "0.1.6",
4
+ "description": "AEF (Auto Error Fixer) - 自动故障修复系统,能够自动检测、修复服务器错误并在必要时重启服务器,支持跨平台错误处理",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "jest"