@simonyea/holysheep-cli 1.7.21 → 1.7.23

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.21",
3
+ "version": "1.7.23",
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",
@@ -56,11 +56,22 @@ function getWindowsImmediateLaunchCmd(tool) {
56
56
  return null
57
57
  }
58
58
 
59
- function getPreferredCliPrefix() {
60
- if (process.platform === 'win32') {
61
- return 'hs'
59
+ // 检测当前 shell 里的 hs 命令是否已包含 claude 子命令
60
+ function isHsClaudeAvailable() {
61
+ try {
62
+ const out = execSync('hs --help', {
63
+ encoding: 'utf8',
64
+ timeout: 4000,
65
+ shell: process.platform === 'win32',
66
+ stdio: ['ignore', 'pipe', 'ignore'],
67
+ })
68
+ return out.includes('claude')
69
+ } catch {
70
+ return false
62
71
  }
72
+ }
63
73
 
74
+ function getPreferredCliPrefix() {
64
75
  const mainEntry = String(require.main?.filename || '')
65
76
  const runningFromNpxCache =
66
77
  /[\\/]_npx[\\/]/i.test(mainEntry) ||
@@ -394,6 +405,11 @@ async function setup(options) {
394
405
  const immediateCmd = getWindowsImmediateLaunchCmd({ ...r.tool, launchCmd: preferredLaunchCmd || r.tool.launchCmd })
395
406
  console.log(` ${chalk.gray('▶ 立即启动:')} ${chalk.cyan.bold(immediateCmd || preferredLaunchCmd || r.tool.launchCmd)}`)
396
407
  console.log(` ${chalk.gray('▶ 新开终端后:')} ${chalk.cyan.bold(preferredLaunchCmd || r.tool.launchCmd)}`)
408
+ } else if (r.tool.id === 'claude-code' && !isHsClaudeAvailable()) {
409
+ // hs claude 在当前 shell 不可用(hs 未安装或版本过旧),显示两条命令
410
+ const npxCmd = `npx @simonyea/holysheep-cli@${pkg.version} claude`
411
+ console.log(` ${chalk.gray('▶ 立即启动:')} ${chalk.cyan.bold(npxCmd)}`)
412
+ console.log(` ${chalk.gray('▶ 新开终端后:')} ${chalk.cyan.bold('hs claude')}`)
397
413
  } else {
398
414
  console.log(` ${chalk.gray('▶ 启动命令:')} ${chalk.cyan.bold(preferredLaunchCmd || r.tool.launchCmd)}`)
399
415
  }
@@ -205,10 +205,10 @@ function startBridge(port) {
205
205
  const scriptPath = path.join(__dirname, '..', 'index.js')
206
206
  // Windows: use shell+node command to avoid ERROR_FILE_NOT_FOUND with process.execPath
207
207
  // (Windows Store / nvm paths can be unresolvable when spawning detached)
208
+ // Windows: use 'node' (resolved via PATH by CreateProcess) without shell:true.
209
+ // shell:true spawns cmd.exe /c which exits after the command, breaking detach.
208
210
  const spawnCmd = isWin ? 'node' : process.execPath
209
- const spawnOpts = isWin
210
- ? { shell: true, detached: true, stdio: 'ignore', windowsHide: true }
211
- : { detached: true, stdio: 'ignore' }
211
+ const spawnOpts = { detached: true, stdio: 'ignore', windowsHide: true }
212
212
  const child = spawn(spawnCmd, [scriptPath, 'openclaw-bridge', '--port', String(port)], spawnOpts)
213
213
  child.unref()
214
214
  return waitForBridge(port)
@@ -416,7 +416,7 @@ function normalizeRequestedModels(selectedModels) {
416
416
  return Array.from(new Set(requestedModels))
417
417
  }
418
418
 
419
- function buildManagedPlan(baseUrlBridge, primaryModel, selectedModels) {
419
+ function buildManagedPlan(baseUrlBridge, apiKey, primaryModel, selectedModels) {
420
420
  const requestedModels = normalizeRequestedModels(selectedModels)
421
421
  const managedModelRefs = requestedModels.map((model) => `${OPENCLAW_PROVIDER_NAME}/${model}`)
422
422
  const fallbackPrimaryModel = pickPrimaryModel(primaryModel, requestedModels)
@@ -428,6 +428,7 @@ function buildManagedPlan(baseUrlBridge, primaryModel, selectedModels) {
428
428
  providers: {
429
429
  [OPENCLAW_PROVIDER_NAME]: {
430
430
  baseUrl: baseUrlBridge,
431
+ apiKey,
431
432
  api: 'openai-completions',
432
433
  models: requestedModels.map(buildModelEntry),
433
434
  },
@@ -445,10 +446,10 @@ function isHolySheepProvider(provider) {
445
446
  )
446
447
  }
447
448
 
448
- function writeManagedConfig(baseConfig, bridgeBaseUrl, primaryModel, selectedModels, gatewayPort) {
449
+ function writeManagedConfig(baseConfig, bridgeBaseUrl, apiKey, primaryModel, selectedModels, gatewayPort) {
449
450
  fs.mkdirSync(OPENCLAW_DIR, { recursive: true })
450
451
 
451
- const plan = buildManagedPlan(bridgeBaseUrl, primaryModel, selectedModels)
452
+ const plan = buildManagedPlan(bridgeBaseUrl, apiKey, primaryModel, selectedModels)
452
453
  const existingProviders = baseConfig?.models?.providers || {}
453
454
  const managedProviderIds = Object.entries(existingProviders)
454
455
  .filter(([providerId, provider]) => providerId === OPENCLAW_PROVIDER_NAME || isHolySheepProvider(provider))
@@ -692,6 +693,7 @@ module.exports = {
692
693
  const plan = writeManagedConfig(
693
694
  result.status === 0 ? readConfig() : {},
694
695
  bridgeBaseUrl,
696
+ apiKey,
695
697
  resolvedPrimaryModel,
696
698
  selectedModels,
697
699
  gatewayPort,