@simonyea/holysheep-cli 1.7.1 → 1.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
5
5
  "keywords": [
6
6
  "openai-china",
@@ -11,7 +11,12 @@ const TOOLS = require('../tools')
11
11
 
12
12
  // 工具的自动安装命令(npm/pip)
13
13
  const AUTO_INSTALL = {
14
- 'claude-code': { cmd: 'npm install -g @anthropic-ai/claude-code', mgr: 'npm' },
14
+ 'claude-code': {
15
+ cmd: process.platform === 'win32'
16
+ ? 'powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://claude.ai/install.ps1 | iex"'
17
+ : 'curl -fsSL https://claude.ai/install.sh | bash',
18
+ mgr: process.platform === 'win32' ? 'powershell' : 'bash',
19
+ },
15
20
  'codex': { cmd: 'npm install -g @openai/codex', mgr: 'npm' },
16
21
  'gemini-cli': { cmd: 'npm install -g @google/gemini-cli', mgr: 'npm' },
17
22
  'opencode': { cmd: 'npm install -g opencode-ai', mgr: 'npm' },
@@ -19,6 +24,27 @@ const AUTO_INSTALL = {
19
24
  'aider': { cmd: 'pip install aider-chat', mgr: 'pip' },
20
25
  }
21
26
 
27
+ function getWindowsImmediateLaunchCmd(tool) {
28
+ if (process.platform !== 'win32' || !tool?.launchCmd) return null
29
+
30
+ const cmdBin = tool.launchCmd.split(' ')[0]
31
+
32
+ try {
33
+ const npmPrefix = execSync('npm prefix -g', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
34
+ if (npmPrefix) {
35
+ const directCmd = `${npmPrefix}\\${cmdBin}.cmd`
36
+ return `& "${directCmd}"`
37
+ }
38
+ } catch {}
39
+
40
+ const appData = process.env.APPDATA
41
+ if (appData) {
42
+ return `& "${appData}\\npm\\${cmdBin}.cmd"`
43
+ }
44
+
45
+ return null
46
+ }
47
+
22
48
  function canAutoInstall(toolId) {
23
49
  return !!AUTO_INSTALL[toolId]
24
50
  }
@@ -37,10 +63,7 @@ async function tryAutoInstall(tool) {
37
63
 
38
64
  const spinner = ora(`正在安装 ${tool.name}...`).start()
39
65
  try {
40
- const ret = spawnSync(info.cmd.split(' ')[0], info.cmd.split(' ').slice(1), {
41
- stdio: 'inherit',
42
- shell: true,
43
- })
66
+ const ret = spawnSync(info.cmd, [], { stdio: 'inherit', shell: true })
44
67
  if (ret.status !== 0) {
45
68
  spinner.fail(`安装失败,请手动运行: ${chalk.cyan(info.cmd)}`)
46
69
  return false
@@ -290,10 +313,9 @@ async function setup(options) {
290
313
  })
291
314
  } else if (r.tool.launchCmd) {
292
315
  if (r.tool._winJustInstalled) {
293
- const cmdBin = r.tool.launchCmd.split(' ')[0]
294
- const cmdArgs = r.tool.launchCmd.split(' ').slice(1).join(' ')
295
- const npxCmd = 'npx ' + cmdBin + (cmdArgs ? ' ' + cmdArgs : '')
296
- console.log(` ${chalk.gray('▶ 启动命令:')} ${chalk.cyan.bold(npxCmd)}`)
316
+ const immediateCmd = getWindowsImmediateLaunchCmd(r.tool)
317
+ console.log(` ${chalk.gray('▶ 立即启动:')} ${chalk.cyan.bold(immediateCmd || r.tool.launchCmd)}`)
318
+ console.log(` ${chalk.gray('▶ 新开终端后:')} ${chalk.cyan.bold(r.tool.launchCmd)}`)
297
319
  } else {
298
320
  console.log(` ${chalk.gray('▶ 启动命令:')} ${chalk.cyan.bold(r.tool.launchCmd)}`)
299
321
  }
@@ -12,8 +12,10 @@ const UPGRADABLE_TOOLS = [
12
12
  id: 'claude-code',
13
13
  command: 'claude',
14
14
  versionCmd: 'claude --version',
15
- npmPkg: '@anthropic-ai/claude-code',
16
- installCmd: 'npm install -g @anthropic-ai/claude-code@latest',
15
+ npmPkg: null,
16
+ installCmd: process.platform === 'win32'
17
+ ? 'powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://claude.ai/install.ps1 | iex"'
18
+ : 'curl -fsSL https://claude.ai/install.sh | bash',
17
19
  },
18
20
  {
19
21
  name: 'Codex CLI',
@@ -114,6 +116,18 @@ async function upgrade() {
114
116
 
115
117
  const latestVer = await getLatestVersion(tool.npmPkg)
116
118
 
119
+ if (!tool.npmPkg) {
120
+ console.log(`\r ${chalk.yellow('↑')} ${chalk.yellow(tool.name.padEnd(18))} ${chalk.gray('v' + (localVer || '?'))} → ${chalk.cyan('official installer')} `)
121
+ const success = runUpgrade(tool)
122
+ if (success) {
123
+ const newVer = getLocalVersion(tool)
124
+ console.log(` ${chalk.green('✓')} ${chalk.green(tool.name)} 升级成功 → ${chalk.cyan('v' + (newVer || 'latest'))}`)
125
+ upgraded++
126
+ }
127
+ console.log()
128
+ continue
129
+ }
130
+
117
131
  if (!latestVer) {
118
132
  console.log(chalk.yellow(' 无法获取最新版本'))
119
133
  continue
@@ -142,7 +156,7 @@ async function upgrade() {
142
156
  if (!hasInstalled) {
143
157
  console.log(chalk.yellow('没有检测到已安装的 AI 编程工具。'))
144
158
  console.log(chalk.gray('支持的工具: Claude Code, Codex CLI, Gemini CLI'))
145
- console.log(chalk.gray('安装示例: npm install -g @anthropic-ai/claude-code'))
159
+ console.log(chalk.gray(`安装示例: ${process.platform === 'win32' ? 'irm https://claude.ai/install.ps1 | iex' : 'curl -fsSL https://claude.ai/install.sh | bash'}`))
146
160
  } else if (upgraded > 0) {
147
161
  console.log(chalk.green(`✓ 升级了 ${upgraded} 个工具`))
148
162
  } else if (alreadyLatest > 0) {
@@ -107,7 +107,9 @@ module.exports = {
107
107
  getConfigPath() { return SETTINGS_FILE },
108
108
  hint: '通过 HolySheep 本地 Bridge 接入,支持热切换,无需重启终端',
109
109
  launchCmd: 'claude',
110
- installCmd: 'npm install -g @anthropic-ai/claude-code',
110
+ installCmd: process.platform === 'win32'
111
+ ? 'irm https://claude.ai/install.ps1 | iex'
112
+ : 'curl -fsSL https://claude.ai/install.sh | bash',
111
113
  docsUrl: 'https://docs.anthropic.com/claude-code',
112
114
  getBridgePort() {
113
115
  return getConfiguredBridgePort()