yymaxapi 1.0.7 → 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 +28 -18
  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
  }
@@ -1507,8 +1517,8 @@ async function presetClaude(paths, args = {}) {
1507
1517
  name: 'selectedIndex',
1508
1518
  message: '选择节点:',
1509
1519
  choices: [
1510
- { name: `🚀 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1511
- new inquirer.Separator('--- 或手动选择 ---'),
1520
+ { name: `* 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1521
+ new inquirer.Separator(' ---- 或手动选择 ----'),
1512
1522
  ...sorted.map((e, i) => ({
1513
1523
  name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
1514
1524
  value: i
@@ -1701,8 +1711,8 @@ async function presetCodex(paths, args = {}) {
1701
1711
  name: 'selectedIndex',
1702
1712
  message: '选择节点:',
1703
1713
  choices: [
1704
- { name: `🚀 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1705
- new inquirer.Separator('--- 或手动选择 ---'),
1714
+ { name: `* 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1715
+ new inquirer.Separator(' ---- 或手动选择 ----'),
1706
1716
  ...sorted.map((e, i) => ({
1707
1717
  name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
1708
1718
  value: i
@@ -1917,17 +1927,17 @@ async function main() {
1917
1927
  pageSize: 10,
1918
1928
  loop: false,
1919
1929
  choices: [
1920
- new inquirer.Separator(chalk.gray('── 配置模型 ──')),
1921
- { name: '激活 Claude', value: 'activate_claude' },
1922
- { name: '激活 Codex (GPT)', value: 'activate_codex' },
1923
- new inquirer.Separator(chalk.gray('── 工具 ──')),
1924
- { name: '测试连接', value: 'test_connection' },
1925
- { name: '查看配置', value: 'view_config' },
1926
- { name: '恢复默认', value: 'restore' },
1927
- new inquirer.Separator(chalk.gray('── 安装 ──')),
1928
- { name: '安装/更新 OpenClaw', value: 'install_openclaw' },
1930
+ new inquirer.Separator(' -- 配置模型 --'),
1931
+ { name: ' 激活 Claude', value: 'activate_claude' },
1932
+ { name: ' 激活 Codex (GPT)', value: 'activate_codex' },
1933
+ new inquirer.Separator(' -- 工具 --'),
1934
+ { name: ' 测试连接', value: 'test_connection' },
1935
+ { name: ' 查看配置', value: 'view_config' },
1936
+ { name: ' 恢复默认', value: 'restore' },
1937
+ new inquirer.Separator(' -- 安装 --'),
1938
+ { name: ' 安装/更新 OpenClaw', value: 'install_openclaw' },
1929
1939
  new inquirer.Separator(''),
1930
- { name: chalk.gray('退出'), value: 'exit' }
1940
+ { name: ' 退出', value: 'exit' }
1931
1941
  ]
1932
1942
  }]);
1933
1943
 
@@ -2029,8 +2039,8 @@ async function selectNode(paths, type) {
2029
2039
  name: 'selectedIndex',
2030
2040
  message: '选择节点:',
2031
2041
  choices: [
2032
- { name: `🚀 使用推荐节点 (${sorted[0].name}, 评分:${sorted[0].score})`, value: -1 },
2033
- new inquirer.Separator('--- 或手动选择 ---'),
2042
+ { name: `* 使用推荐节点 (${sorted[0].name}, 评分:${sorted[0].score})`, value: -1 },
2043
+ new inquirer.Separator(' ---- 或手动选择 ----'),
2034
2044
  ...sorted.map((e, i) => ({
2035
2045
  name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
2036
2046
  value: i
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {