@simonyea/holysheep-cli 1.7.26 → 1.7.27

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.26",
3
+ "version": "1.7.27",
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",
@@ -44,6 +44,7 @@ async function runClaude(args = []) {
44
44
 
45
45
  const env = {
46
46
  ...process.env,
47
+ ANTHROPIC_API_KEY: undefined, // 防止与 ANTHROPIC_AUTH_TOKEN 冲突
47
48
  ANTHROPIC_AUTH_TOKEN: apiKey,
48
49
  ANTHROPIC_BASE_URL: BASE_URL_ANTHROPIC,
49
50
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
@@ -9,6 +9,7 @@ const pkg = require('../../package.json')
9
9
  const { saveConfig, getApiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI, SHOP_URL } = require('../utils/config')
10
10
  const {
11
11
  writeEnvToShell,
12
+ removeEnvFromShell,
12
13
  ensureWindowsUserPathHasNpmBin,
13
14
  installWindowsCliShims,
14
15
  removeWindowsUserEnvVars,
@@ -328,25 +329,26 @@ async function setup(options) {
328
329
  }
329
330
  }
330
331
 
331
- // Step 5: 写入通用环境变量
332
- const needsAnthropicEnv = toConfigureTools.some(t => t.id === 'claude-code')
333
- const needsOpenAIEnv = toConfigureTools.some(t => t.id === 'codex' || t.id === 'aider')
334
- if (needsAnthropicEnv || needsOpenAIEnv || Object.keys(envVarsToWrite).length > 0) {
335
- if (needsAnthropicEnv) {
336
- Object.assign(envVarsToWrite, {
337
- ANTHROPIC_API_KEY: apiKey,
338
- ANTHROPIC_BASE_URL: BASE_URL_ANTHROPIC,
339
- })
332
+ // Step 5: 写入环境变量
333
+ // 策略:所有工具尽量用各自 JSON/config 文件,减少 shell 污染。
334
+ // 例外:Codex Rust 版必须通过 env_key 读取一个环境变量,使用 HOLYSHEEP_API_KEY。
335
+ const needsCodexEnv = toConfigureTools.some(t => t.id === 'codex')
336
+ if (needsCodexEnv) {
337
+ Object.assign(envVarsToWrite, { HOLYSHEEP_API_KEY: apiKey })
338
+ }
339
+
340
+ // 清理旧版本写入的过时 shell 变量(ANTHROPIC_API_KEY / OPENAI_API_KEY 等)
341
+ const staleKeys = ['ANTHROPIC_API_KEY', 'ANTHROPIC_BASE_URL', 'OPENAI_API_KEY', 'OPENAI_BASE_URL']
342
+ try {
343
+ const cleaned = removeEnvFromShell(staleKeys)
344
+ if (cleaned.length > 0) {
345
+ console.log(chalk.gray(`已清理过时 shell 变量: ${cleaned.map(f => chalk.cyan(f)).join(', ')}`))
340
346
  }
341
- if (needsOpenAIEnv) {
342
- Object.assign(envVarsToWrite, {
343
- OPENAI_API_KEY: apiKey,
344
- })
345
- if (toConfigureTools.some(t => t.id === 'aider')) {
346
- Object.assign(envVarsToWrite, {
347
- OPENAI_BASE_URL: BASE_URL_OPENAI,
348
- })
349
- }
347
+ } catch {}
348
+ if (process.platform === 'win32') {
349
+ const removed = removeWindowsUserEnvVars(staleKeys)
350
+ if (removed.length > 0) {
351
+ console.log(chalk.gray(`已移除过时环境变量: ${removed.map(item => chalk.cyan(item)).join(', ')}`))
350
352
  }
351
353
  }
352
354
 
@@ -360,14 +362,6 @@ async function setup(options) {
360
362
  }
361
363
  }
362
364
 
363
- if (process.platform === 'win32' && toConfigureTools.some(t => t.id === 'codex') && !toConfigureTools.some(t => t.id === 'aider')) {
364
- const removed = removeWindowsUserEnvVars(['OPENAI_BASE_URL'])
365
- if (removed.length > 0) {
366
- console.log(chalk.gray(`已移除过时环境变量: ${removed.map(item => chalk.cyan(item)).join(', ')}`))
367
- console.log()
368
- }
369
- }
370
-
371
365
  if (process.platform === 'win32' && windowsCliArtifacts.length > 0) {
372
366
  console.log(chalk.gray(`Windows 启动器已就绪: ${windowsCliArtifacts.map(item => chalk.cyan(item)).join(', ')}`))
373
367
  console.log()
@@ -70,10 +70,4 @@ model: openai/${model}
70
70
  launchCmd: 'aider',
71
71
  installCmd: 'pip install aider-chat',
72
72
  docsUrl: 'https://aider.chat',
73
- // Aider 优先用环境变量
74
- envVars: (apiKey, baseUrlOpenAI) => ({
75
- OPENAI_API_KEY: apiKey,
76
- OPENAI_BASE_URL: baseUrlOpenAI,
77
- AIDER_OPENAI_API_BASE: baseUrlOpenAI,
78
- }),
79
73
  }
@@ -90,7 +90,7 @@ function isConfiguredInToml() {
90
90
  return content.includes('model_provider = "holysheep"') &&
91
91
  content.includes('base_url') &&
92
92
  content.includes('holysheep.ai') &&
93
- content.includes('env_key = "OPENAI_API_KEY"')
93
+ (content.includes('env_key = "HOLYSHEEP_API_KEY"') || content.includes('env_key = "OPENAI_API_KEY"'))
94
94
  }
95
95
 
96
96
  /**
@@ -113,7 +113,7 @@ function writeTomlConfig(apiKey, baseUrlOpenAI, model) {
113
113
  `[model_providers.holysheep]`,
114
114
  `name = "HolySheep"`,
115
115
  `base_url = "${baseUrlOpenAI}"`,
116
- `env_key = "OPENAI_API_KEY"`,
116
+ `env_key = "HOLYSHEEP_API_KEY"`,
117
117
  `wire_api = "responses"`,
118
118
  '',
119
119
  ].join('\n')
@@ -138,7 +138,7 @@ function writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model) {
138
138
  jsonConfig.model_providers.holysheep = {
139
139
  name: 'HolySheep',
140
140
  base_url: baseUrlOpenAI,
141
- env_key: 'OPENAI_API_KEY',
141
+ env_key: 'HOLYSHEEP_API_KEY',
142
142
  wire_api: 'responses',
143
143
  }
144
144
  jsonConfig.providers.holysheep = {
@@ -171,9 +171,6 @@ module.exports = {
171
171
  return {
172
172
  file: CONFIG_FILE,
173
173
  hot: false,
174
- envVars: {
175
- OPENAI_API_KEY: apiKey,
176
- },
177
174
  }
178
175
  },
179
176
  reset() {