yingclaw 2.0.8 → 2.1.0

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/bin/cli.js CHANGED
@@ -16,6 +16,7 @@ const {
16
16
  buildClaudeEnv,
17
17
  classifyValidationStatus,
18
18
  PROVIDERS,
19
+ CLAUDE_ENV_KEYS,
19
20
  } = require('../lib/config');
20
21
  const { execSync, spawn, spawnSync } = require('child_process');
21
22
  const pkg = require('../package.json');
@@ -29,7 +30,7 @@ async function getBanner() {
29
30
  const chalk = (await import('chalk')).default;
30
31
  const figlet = require('figlet');
31
32
  const boxen = (await import('boxen')).default;
32
- const title = figlet.textSync('claw', { font: 'Standard', horizontalLayout: 'fitted' });
33
+ const title = figlet.textSync('yingclaw', { font: 'Small', horizontalLayout: 'fitted' });
33
34
  const subtitle = chalk.dim('Claude Code × 国产大模型 一键接入') + ' ' + chalk.cyan(`v${pkg.version}`);
34
35
  return boxen(
35
36
  chalk.cyan.bold(title) + '\n' + subtitle,
@@ -544,13 +545,16 @@ program
544
545
  spinner.warn(chalk.yellow('没有找到 Claude Code 终端环境变量,无需恢复'));
545
546
  } else {
546
547
  spinner.succeed(chalk.green('Claude Code 终端已恢复默认'));
547
- const resetNote = cleared.includes('Windows 用户环境变量')
548
+ const isWin = cleared.includes('Windows 用户环境变量');
549
+ const resetNote = isWin
548
550
  ? '注:当前终端的环境变量还在内存中,重新打开 PowerShell / CMD 后才彻底清除'
549
- : '注:当前终端的环境变量还在内存中,重开终端或 unset 才彻底清除';
551
+ : '注:当前终端的环境变量还在内存中,重开终端后生效,或在当前终端执行:';
552
+ const unsetCmd = isWin ? null : `unset ${CLAUDE_ENV_KEYS.join(' ')}`;
550
553
  console.log(boxen(
551
554
  chalk.bold('已清除以下位置中的 Claude Code 终端环境变量:\n\n') +
552
555
  cleared.map(f => chalk.cyan(' • ' + f)).join('\n') +
553
- '\n\n' + chalk.dim(resetNote),
556
+ '\n\n' + chalk.dim(resetNote) +
557
+ (unsetCmd ? '\n' + chalk.cyan(unsetCmd) : ''),
554
558
  { padding: { top: 0, bottom: 0, left: 2, right: 2 }, borderStyle: 'round', borderColor: 'green', margin: { top: 1, bottom: 1 } }
555
559
  ));
556
560
  }
@@ -754,10 +758,25 @@ program
754
758
  ].filter(Boolean);
755
759
  console.log(boxen(
756
760
  chalk.bold('已清除 Claude 桌面应用第三方推理配置:\n\n') +
757
- cleared.map(f => chalk.cyan(' • ' + f)).join('\n') +
758
- '\n\n' + chalk.dim('如 Claude Desktop 已打开,请完全退出后重新打开。'),
761
+ cleared.map(f => chalk.cyan(' • ' + f)).join('\n'),
759
762
  { padding: { top: 0, bottom: 0, left: 2, right: 2 }, borderStyle: 'round', borderColor: 'green', margin: { top: 1, bottom: 1 } }
760
763
  ));
764
+
765
+ if (process.platform === 'darwin') {
766
+ const shouldReopen = await confirm({ message: '是否现在重启 Claude 桌面应用使默认配置生效?', default: true });
767
+ if (shouldReopen) {
768
+ const openSpinner = ora('正在重启 Claude 桌面应用...').start();
769
+ try {
770
+ await openClaudeDesktop();
771
+ openSpinner.succeed(chalk.green('Claude 桌面应用已重启(已恢复 1P 模式)'));
772
+ } catch (e) {
773
+ openSpinner.fail(chalk.red(`打开失败: ${e.message}`));
774
+ console.log(chalk.dim('请手动完全退出 Claude 后重新打开。'));
775
+ }
776
+ }
777
+ } else {
778
+ console.log(chalk.dim('请手动完全退出 Claude 后重新打开。'));
779
+ }
761
780
  } else {
762
781
  spinner.warn(chalk.yellow('没有找到 Claude 桌面应用第三方推理配置,无需恢复'));
763
782
  }
package/lib/desktop.js CHANGED
@@ -22,25 +22,29 @@ function getClaudeDesktopDataDir(options = {}) {
22
22
  const homeDir = options.homeDir || os.homedir();
23
23
 
24
24
  if (platform === 'darwin') {
25
- return path.join(homeDir, 'Library', 'Application Support', 'Claude-3p');
25
+ return [homeDir, 'Library', 'Application Support', 'Claude-3p'].join('/');
26
26
  }
27
27
 
28
28
  if (platform === 'win32') {
29
- const appData = options.appData || process.env.APPDATA || options.localAppData || path.join(homeDir, 'AppData', 'Roaming');
30
- return path.join(appData, 'Claude-3p');
29
+ const appData = options.appData || process.env.APPDATA || options.localAppData || [homeDir, 'AppData', 'Roaming'].join('\\');
30
+ return appData + '\\Claude-3p';
31
31
  }
32
32
 
33
33
  return null;
34
34
  }
35
35
 
36
36
  function getClaudeDesktopConfigPath(options = {}) {
37
+ const platform = options.platform || process.platform;
37
38
  const dataDir = options.dataDir || getClaudeDesktopDataDir(options);
38
- return dataDir ? path.join(dataDir, 'claude_desktop_config.json') : null;
39
+ if (!dataDir) return null;
40
+ return dataDir + (platform === 'win32' ? '\\' : '/') + 'claude_desktop_config.json';
39
41
  }
40
42
 
41
43
  function getClaudeDesktopConfigLibraryDir(options = {}) {
44
+ const platform = options.platform || process.platform;
42
45
  const dataDir = options.dataDir || getClaudeDesktopDataDir(options);
43
- return dataDir ? path.join(dataDir, 'configLibrary') : null;
46
+ if (!dataDir) return null;
47
+ return dataDir + (platform === 'win32' ? '\\' : '/') + 'configLibrary';
44
48
  }
45
49
 
46
50
  function readJsonFile(file) {
@@ -115,6 +119,11 @@ function clearClaudeDesktopConfigLibrary(options = {}) {
115
119
 
116
120
  // 写入 Claude-3p/configLibrary/ 下的 enterprise config 条目(主进程从此处读取)
117
121
  function writeClaudeDesktopConfig(config, options = {}) {
122
+ const baseUrl = normalizeAnthropicBaseUrl(config.baseUrl);
123
+ if (!baseUrl.startsWith('https://')) {
124
+ throw new Error('Claude 桌面应用要求 Gateway Base URL 使用 HTTPS');
125
+ }
126
+
118
127
  const dataDir = options.dataDir || getClaudeDesktopDataDir(options);
119
128
  if (!dataDir) {
120
129
  return { result: 'unsupported', file: null };
@@ -126,10 +135,6 @@ function writeClaudeDesktopConfig(config, options = {}) {
126
135
  const uuid = existingMeta.appliedId || options.uuid || crypto.randomUUID();
127
136
 
128
137
  const models = collectModels(config);
129
- const baseUrl = normalizeAnthropicBaseUrl(config.baseUrl);
130
- if (!baseUrl.startsWith('https://')) {
131
- throw new Error('Claude 桌面应用要求 Gateway Base URL 使用 HTTPS');
132
- }
133
138
 
134
139
  const entry = {
135
140
  inferenceProvider: 'gateway',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yingclaw",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
4
4
  "description": "Claude Code × 国产大模型一键接入:DeepSeek、Kimi、Qwen、MiniMax、GLM、MiMo",
5
5
  "main": "index.js",
6
6
  "bin": {