yymaxapi 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/bin/yymaxapi.js +12 -2
  2. package/package.json +1 -1
package/bin/yymaxapi.js CHANGED
@@ -513,8 +513,18 @@ function getConfigPath() {
513
513
  // ============ 配置读写 ============
514
514
  function readConfig(configPath) {
515
515
  if (fs.existsSync(configPath)) {
516
- const raw = fs.readFileSync(configPath, 'utf8');
517
- return JSON5.parse(raw);
516
+ try {
517
+ const raw = fs.readFileSync(configPath, 'utf8').trim();
518
+ if (!raw || (!raw.startsWith('{') && !raw.startsWith('['))) {
519
+ console.log(chalk.yellow(`\n⚠ 配置文件格式异常,将重新创建: ${configPath}`));
520
+ return null;
521
+ }
522
+ return JSON5.parse(raw);
523
+ } catch (e) {
524
+ console.log(chalk.yellow(`\n⚠ 配置文件解析失败: ${e.message}`));
525
+ console.log(chalk.gray(` 文件: ${configPath}`));
526
+ return null;
527
+ }
518
528
  }
519
529
  return null;
520
530
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {