yymaxapi 1.0.6 → 1.0.8

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 +84 -20
  2. package/package.json +1 -1
package/bin/yymaxapi.js CHANGED
@@ -1507,8 +1507,8 @@ async function presetClaude(paths, args = {}) {
1507
1507
  name: 'selectedIndex',
1508
1508
  message: '选择节点:',
1509
1509
  choices: [
1510
- { name: `🚀 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1511
- new inquirer.Separator('--- 或手动选择 ---'),
1510
+ { name: `* 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1511
+ new inquirer.Separator(' ---- 或手动选择 ----'),
1512
1512
  ...sorted.map((e, i) => ({
1513
1513
  name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
1514
1514
  value: i
@@ -1701,8 +1701,8 @@ async function presetCodex(paths, args = {}) {
1701
1701
  name: 'selectedIndex',
1702
1702
  message: '选择节点:',
1703
1703
  choices: [
1704
- { name: `🚀 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1705
- new inquirer.Separator('--- 或手动选择 ---'),
1704
+ { name: `* 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
1705
+ new inquirer.Separator(' ---- 或手动选择 ----'),
1706
1706
  ...sorted.map((e, i) => ({
1707
1707
  name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
1708
1708
  value: i
@@ -1917,17 +1917,17 @@ async function main() {
1917
1917
  pageSize: 10,
1918
1918
  loop: false,
1919
1919
  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' },
1920
+ new inquirer.Separator(' -- 配置模型 --'),
1921
+ { name: ' 激活 Claude', value: 'activate_claude' },
1922
+ { name: ' 激活 Codex (GPT)', value: 'activate_codex' },
1923
+ new inquirer.Separator(' -- 工具 --'),
1924
+ { name: ' 测试连接', value: 'test_connection' },
1925
+ { name: ' 查看配置', value: 'view_config' },
1926
+ { name: ' 恢复默认', value: 'restore' },
1927
+ new inquirer.Separator(' -- 安装 --'),
1928
+ { name: ' 安装/更新 OpenClaw', value: 'install_openclaw' },
1929
1929
  new inquirer.Separator(''),
1930
- { name: chalk.gray('退出'), value: 'exit' }
1930
+ { name: ' 退出', value: 'exit' }
1931
1931
  ]
1932
1932
  }]);
1933
1933
 
@@ -2029,8 +2029,8 @@ async function selectNode(paths, type) {
2029
2029
  name: 'selectedIndex',
2030
2030
  message: '选择节点:',
2031
2031
  choices: [
2032
- { name: `🚀 使用推荐节点 (${sorted[0].name}, 评分:${sorted[0].score})`, value: -1 },
2033
- new inquirer.Separator('--- 或手动选择 ---'),
2032
+ { name: `* 使用推荐节点 (${sorted[0].name}, 评分:${sorted[0].score})`, value: -1 },
2033
+ new inquirer.Separator(' ---- 或手动选择 ----'),
2034
2034
  ...sorted.map((e, i) => ({
2035
2035
  name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
2036
2036
  value: i
@@ -2798,6 +2798,57 @@ async function viewConfig(paths) {
2798
2798
  console.log(` ${fs.existsSync(backupPath) ? chalk.green('✓ 已备份') : chalk.gray('未备份')}`);
2799
2799
  }
2800
2800
 
2801
+ // ============ Windows 自动安装 Git ============
2802
+ async function autoInstallGitWindows() {
2803
+ // 方式1: 尝试 winget(Windows 10/11 自带)
2804
+ const wingetCheck = safeExec('winget --version');
2805
+ if (wingetCheck.ok) {
2806
+ const spinner = ora({ text: '正在通过 winget 安装 Git...', spinner: 'dots' }).start();
2807
+ try {
2808
+ execSync('winget install --id Git.Git -e --source winget --accept-package-agreements --accept-source-agreements', {
2809
+ stdio: 'pipe', timeout: 300000
2810
+ });
2811
+ spinner.succeed('Git 安装完成 (winget)');
2812
+ // 刷新 PATH
2813
+ const gitPath = safeExec('where.exe git');
2814
+ if (gitPath.ok) {
2815
+ console.log(chalk.green(` ${gitPath.output.split('\n')[0].trim()}`));
2816
+ return true;
2817
+ }
2818
+ // winget 安装后可能需要重启终端才能找到 git
2819
+ console.log(chalk.yellow(' Git 已安装,但需要重新打开终端使 PATH 生效'));
2820
+ console.log(chalk.gray(' 请关闭当前终端,重新打开后再运行此工具'));
2821
+ return false;
2822
+ } catch (e) {
2823
+ spinner.fail('winget 安装 Git 失败,尝试下载安装包...');
2824
+ }
2825
+ }
2826
+
2827
+ // 方式2: 下载 Git 安装包
2828
+ const spinner = ora({ text: '正在下载 Git 安装包...', spinner: 'dots' }).start();
2829
+ const installerPath = path.join(os.tmpdir(), 'git-installer.exe');
2830
+ const downloadUrl = 'https://github.com/git-for-windows/git/releases/latest/download/Git-2.47.1.2-64-bit.exe';
2831
+
2832
+ try {
2833
+ execSync(`powershell -Command "Invoke-WebRequest -Uri '${downloadUrl}' -OutFile '${installerPath}'"`, {
2834
+ stdio: 'pipe', timeout: 300000
2835
+ });
2836
+ spinner.succeed('Git 安装包下载完成');
2837
+
2838
+ const installSpinner = ora({ text: '正在静默安装 Git...', spinner: 'dots' }).start();
2839
+ execSync(`"${installerPath}" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\\reg\\shellhere,assoc,assoc_sh"`, {
2840
+ stdio: 'pipe', timeout: 300000
2841
+ });
2842
+ installSpinner.succeed('Git 安装完成');
2843
+ console.log(chalk.yellow(' 请关闭当前终端,重新打开后再运行此工具'));
2844
+ return false;
2845
+ } catch (e) {
2846
+ spinner.fail('Git 下载/安装失败');
2847
+ console.log(chalk.cyan(' 请手动安装: https://git-scm.com/download/win'));
2848
+ return false;
2849
+ }
2850
+ }
2851
+
2801
2852
  // ============ 安装/更新 OpenClaw ============
2802
2853
  async function installOrUpdateOpenClaw() {
2803
2854
  // 检测当前版本
@@ -2856,14 +2907,27 @@ async function installOrUpdateOpenClaw() {
2856
2907
  // 检测 git(openclaw 的依赖需要 git)
2857
2908
  const gitCheck = safeExec('git --version');
2858
2909
  if (!gitCheck.ok) {
2859
- console.log(chalk.red('\n 未检测到 Git,OpenClaw 安装需要 Git'));
2910
+ console.log(chalk.yellow('\n 未检测到 Git,OpenClaw 安装需要 Git'));
2911
+
2860
2912
  if (process.platform === 'win32') {
2861
- console.log(chalk.cyan(' 请先安装 Git: https://git-scm.com/download/win'));
2862
- console.log(chalk.gray(' 安装后重新打开终端再试'));
2913
+ const { autoInstallGit } = await inquirer.prompt([{
2914
+ type: 'confirm',
2915
+ name: 'autoInstallGit',
2916
+ message: '是否自动安装 Git?',
2917
+ default: true
2918
+ }]);
2919
+
2920
+ if (autoInstallGit) {
2921
+ const gitInstalled = await autoInstallGitWindows();
2922
+ if (!gitInstalled) return;
2923
+ } else {
2924
+ console.log(chalk.cyan(' 请手动安装 Git: https://git-scm.com/download/win'));
2925
+ return;
2926
+ }
2863
2927
  } else {
2864
2928
  console.log(chalk.gray(' 请先安装 Git: sudo apt install git / brew install git'));
2929
+ return;
2865
2930
  }
2866
- return;
2867
2931
  }
2868
2932
 
2869
2933
  const spinner = ora({ text: `正在${actionLabel} OpenClaw...`, spinner: 'dots' }).start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {