yingclaw 2.5.19 → 2.5.20

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/README.md CHANGED
@@ -47,11 +47,10 @@ claw code
47
47
  接入 Claude 桌面应用:
48
48
  ```bash
49
49
  claw desktop
50
- claw gateway
51
50
  ```
52
51
  `claw desktop` 会把 Claude Desktop 指向 yingclaw 本机 Gateway,并只暴露 `claude-sonnet-4-6`、`claude-opus-4-7`、`claude-haiku-4-5` 这类 Claude Desktop 可接受的模型名。真实第三方模型仍按 `claw config` 保存的主模型和快速模型转发。
53
52
 
54
- 使用 Claude Desktop 时需要保持 `claw gateway` 运行。
53
+ `claw desktop` 会设置 Gateway 登录自动运行;如果自动启动失败,可以手动运行 `claw gateway`。
55
54
 
56
55
  ## 支持的厂商
57
56
 
@@ -95,7 +94,7 @@ claw setup # 兼容旧命令:config + code
95
94
  |------|---------|---------|
96
95
  | macOS | ✅ 写入 `~/.zshrc` | ✅ 自动启动本机 Gateway 并重启 Claude Desktop |
97
96
  | Linux / WSL | ✅ 写入 `~/.zshrc` / `~/.bashrc` | — |
98
- | Windows | ✅ 写入用户级环境变量(需重开终端) | ✅ 写入 `%APPDATA%\Claude-3p\`,并写入登录启动脚本 |
97
+ | Windows | ✅ 写入用户级环境变量(需重开终端) | ✅ 同步写入 `%APPDATA%\Claude-3p\` 和 `%LOCALAPPDATA%\Claude-3p\`,并写入登录启动脚本 |
99
98
 
100
99
  ## 原理
101
100
 
@@ -118,6 +117,7 @@ CLAUDE_CODE_EFFORT_LEVEL
118
117
  - Claude Desktop 访问 `http://127.0.0.1:18080/yingclaw`
119
118
  - Gateway 再转发到当前保存的 Anthropic 兼容接口
120
119
  - macOS 使用 LaunchAgent 登录启动 Gateway,Windows 使用 Startup 目录脚本登录启动 Gateway
120
+ - Windows 会同时写入 Roaming / Local 两个 Claude-3p 位置,以兼容不同 Claude Desktop 安装方式
121
121
  - 终端接入仍直接使用 `ANTHROPIC_*` 环境变量,不受桌面 Gateway 影响
122
122
 
123
123
  使用 `inferenceProvider=gateway`、`inferenceGatewayAuthScheme=bearer`,将 Gateway Base URL 指向 yingclaw 本机 Gateway。高级用户可用 `claw desktop --direct` 保留旧式直连写入,但新版 Claude Desktop 可能拒绝非 Claude 模型名。
package/bin/cli.js CHANGED
@@ -23,7 +23,14 @@ const { execSync, spawn, spawnSync } = require('child_process');
23
23
  const pkg = require('../package.json');
24
24
  const { getGatewayAutostartStatus, installGatewayAutostart, removeGatewayAutostart } = require('../lib/autostart');
25
25
  const { buildMenuStatusLines, buildStatusView } = require('../lib/panel');
26
- const { buildClaudeInstallCommand, checkNodeEnv, getNodeInstallGuide, getInstallFailureHints } = require('../lib/install');
26
+ const {
27
+ buildClaudeInstallCommand,
28
+ buildYingclawUpgradeCommand,
29
+ buildWindowsYingclawUpgradeScript,
30
+ checkNodeEnv,
31
+ getNodeInstallGuide,
32
+ getInstallFailureHints,
33
+ } = require('../lib/install');
27
34
  const { clearClaudeDesktopConfig, isDesktopConfigured, openClaudeDesktop, writeClaudeDesktopConfig } = require('../lib/desktop');
28
35
  const {
29
36
  DEFAULT_DESKTOP_GATEWAY_PORT,
@@ -1065,12 +1072,31 @@ program
1065
1072
  ],
1066
1073
  });
1067
1074
 
1068
- const upgradeArgs = ['install', '-g', 'yingclaw@latest'];
1069
- if (network === 'cn') upgradeArgs.push('--registry=https://registry.npmmirror.com');
1070
- const upgradeCmd = { command: 'npm', args: upgradeArgs };
1075
+ const upgradeCmd = buildYingclawUpgradeCommand(network);
1076
+
1077
+ if (process.platform === 'win32') {
1078
+ const fs = require('fs');
1079
+ const os = require('os');
1080
+ const path = require('path');
1081
+ const scriptFile = path.join(os.tmpdir(), `yingclaw-upgrade-${Date.now()}.cmd`);
1082
+ fs.writeFileSync(scriptFile, buildWindowsYingclawUpgradeScript(network), 'utf8');
1083
+ const child = spawn('cmd', ['/c', 'start', '', scriptFile], {
1084
+ detached: true,
1085
+ stdio: 'ignore',
1086
+ windowsHide: false,
1087
+ });
1088
+ if (child && typeof child.unref === 'function') child.unref();
1089
+ console.log(boxen(
1090
+ chalk.bold(`已打开独立更新窗口,准备升级到 v${latest}\n\n`) +
1091
+ chalk.dim('Windows 会锁定当前正在运行的包目录,所以更新会在当前 claw 退出后执行。\n') +
1092
+ chalk.dim('更新完成后重新运行 ') + chalk.cyan('claw'),
1093
+ { padding: { top: 0, bottom: 0, left: 2, right: 2 }, borderStyle: 'round', borderColor: 'green', margin: { top: 1, bottom: 1 } }
1094
+ ));
1095
+ process.exit(0);
1096
+ }
1071
1097
 
1072
1098
  console.log(chalk.dim('\n升级中...\n'));
1073
- const result = spawnSync(upgradeCmd.command, upgradeCmd.args, { stdio: 'inherit', shell: process.platform === 'win32' });
1099
+ const result = spawnSync(upgradeCmd.command, upgradeCmd.args, { stdio: 'inherit' });
1074
1100
 
1075
1101
  if (result.status === 0) {
1076
1102
  console.log(boxen(
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  ...require('./lib/config'),
3
+ ...require('./lib/autostart'),
3
4
  ...require('./lib/desktop'),
4
5
  ...require('./lib/gateway'),
5
6
  ...require('./lib/install'),
package/lib/install.js CHANGED
@@ -8,6 +8,44 @@ function buildClaudeInstallCommand(network) {
8
8
  return { command: 'npm', args };
9
9
  }
10
10
 
11
+ function buildYingclawUpgradeCommand(network) {
12
+ const args = ['install', '-g', 'yingclaw@latest'];
13
+ if (network === 'cn') {
14
+ args.push('--registry=https://registry.npmmirror.com');
15
+ }
16
+ return { command: 'npm', args };
17
+ }
18
+
19
+ function quoteWindowsBatchArg(value) {
20
+ return `"${String(value).replace(/"/g, '""')}"`;
21
+ }
22
+
23
+ function buildWindowsYingclawUpgradeScript(network) {
24
+ const { command, args } = buildYingclawUpgradeCommand(network);
25
+ const commandLine = [command, ...args].map(quoteWindowsBatchArg).join(' ');
26
+ return [
27
+ '@echo off',
28
+ 'chcp 65001 >nul',
29
+ 'echo yingclaw Windows updater',
30
+ 'echo.',
31
+ 'echo 当前 claw 进程退出后开始升级,避免 Windows 文件锁 EBUSY...',
32
+ 'timeout /t 2 /nobreak >nul',
33
+ commandLine,
34
+ 'set "code=%ERRORLEVEL%"',
35
+ 'echo.',
36
+ 'if "%code%"=="0" (',
37
+ ' echo yingclaw 更新完成,请重新运行 claw',
38
+ ') else (',
39
+ ' echo yingclaw 更新失败,错误码 %code%',
40
+ ` echo 请手动运行: ${commandLine}`,
41
+ ')',
42
+ 'echo.',
43
+ 'pause',
44
+ 'del "%~f0" >nul 2>nul',
45
+ '',
46
+ ].join('\r\n');
47
+ }
48
+
11
49
  function checkNodeEnv() {
12
50
  const nodeVersion = process.versions.node;
13
51
  const nodeMajor = parseInt(nodeVersion.split('.')[0], 10);
@@ -91,4 +129,11 @@ function getInstallFailureHints(result, chalk) {
91
129
  ];
92
130
  }
93
131
 
94
- module.exports = { buildClaudeInstallCommand, checkNodeEnv, getNodeInstallGuide, getInstallFailureHints };
132
+ module.exports = {
133
+ buildClaudeInstallCommand,
134
+ buildYingclawUpgradeCommand,
135
+ buildWindowsYingclawUpgradeScript,
136
+ checkNodeEnv,
137
+ getNodeInstallGuide,
138
+ getInstallFailureHints,
139
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yingclaw",
3
- "version": "2.5.19",
3
+ "version": "2.5.20",
4
4
  "description": "Claude Code × 国产大模型一键接入:DeepSeek、Kimi、Qwen、MiniMax、GLM、MiMo",
5
5
  "main": "index.js",
6
6
  "bin": {