@simonyea/holysheep-cli 1.7.10 → 1.7.11
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 +1 -1
- package/src/commands/setup.js +31 -11
- package/src/tools/codex.js +10 -7
- package/src/utils/shell.js +18 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.11",
|
|
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",
|
package/src/commands/setup.js
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
writeEnvToShell,
|
|
12
12
|
ensureWindowsUserPathHasNpmBin,
|
|
13
13
|
installWindowsCliShims,
|
|
14
|
+
removeWindowsUserEnvVars,
|
|
14
15
|
} = require('../utils/shell')
|
|
15
16
|
const { commandExists } = require('../utils/which')
|
|
16
17
|
const TOOLS = require('../tools')
|
|
@@ -57,7 +58,7 @@ function getWindowsImmediateLaunchCmd(tool) {
|
|
|
57
58
|
|
|
58
59
|
function getPreferredCliPrefix() {
|
|
59
60
|
if (process.platform === 'win32') {
|
|
60
|
-
return '
|
|
61
|
+
return 'hs'
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
const mainEntry = String(require.main?.filename || '')
|
|
@@ -149,8 +150,8 @@ async function setup(options) {
|
|
|
149
150
|
console.log(chalk.gray(` (¥10 起充,按量计费,支持微信/支付宝)`))
|
|
150
151
|
console.log(chalk.gray(`提示:可先运行 ${chalk.cyan('hs login')} 登录并保存 Key,之后 setup 将自动读取。`))
|
|
151
152
|
if (process.platform === 'win32') {
|
|
152
|
-
console.log(chalk.gray(` ⚠️ Windows 用户:如果 ${chalk.cyan('hs')}
|
|
153
|
-
console.log(chalk.gray(` ${chalk.white('npx @simonyea/holysheep-cli login')}
|
|
153
|
+
console.log(chalk.gray(` ⚠️ Windows 用户:如果 ${chalk.cyan('hs')} 命令暂时找不到,请先运行:`))
|
|
154
|
+
console.log(chalk.gray(` ${chalk.white('npx @simonyea/holysheep-cli@latest login')}`))
|
|
154
155
|
console.log(chalk.gray(` 或重启终端后再试`))
|
|
155
156
|
}
|
|
156
157
|
console.log()
|
|
@@ -314,14 +315,25 @@ async function setup(options) {
|
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
// Step 5: 写入通用环境变量
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
const needsAnthropicEnv = toConfigureTools.some(t => t.id === 'claude-code')
|
|
319
|
+
const needsOpenAIEnv = toConfigureTools.some(t => t.id === 'codex' || t.id === 'aider')
|
|
320
|
+
if (needsAnthropicEnv || needsOpenAIEnv || Object.keys(envVarsToWrite).length > 0) {
|
|
321
|
+
if (needsAnthropicEnv) {
|
|
322
|
+
Object.assign(envVarsToWrite, {
|
|
323
|
+
ANTHROPIC_API_KEY: apiKey,
|
|
324
|
+
ANTHROPIC_BASE_URL: BASE_URL_ANTHROPIC,
|
|
325
|
+
})
|
|
326
|
+
}
|
|
327
|
+
if (needsOpenAIEnv) {
|
|
328
|
+
Object.assign(envVarsToWrite, {
|
|
329
|
+
OPENAI_API_KEY: apiKey,
|
|
330
|
+
})
|
|
331
|
+
if (toConfigureTools.some(t => t.id === 'aider')) {
|
|
332
|
+
Object.assign(envVarsToWrite, {
|
|
333
|
+
OPENAI_BASE_URL: BASE_URL_OPENAI,
|
|
334
|
+
})
|
|
335
|
+
}
|
|
336
|
+
}
|
|
325
337
|
}
|
|
326
338
|
|
|
327
339
|
if (Object.keys(envVarsToWrite).length > 0) {
|
|
@@ -334,6 +346,14 @@ async function setup(options) {
|
|
|
334
346
|
}
|
|
335
347
|
}
|
|
336
348
|
|
|
349
|
+
if (process.platform === 'win32' && toConfigureTools.some(t => t.id === 'codex') && !toConfigureTools.some(t => t.id === 'aider')) {
|
|
350
|
+
const removed = removeWindowsUserEnvVars(['OPENAI_BASE_URL'])
|
|
351
|
+
if (removed.length > 0) {
|
|
352
|
+
console.log(chalk.gray(`已移除过时环境变量: ${removed.map(item => chalk.cyan(item)).join(', ')}`))
|
|
353
|
+
console.log()
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
337
357
|
if (process.platform === 'win32' && windowsCliArtifacts.length > 0) {
|
|
338
358
|
console.log(chalk.gray(`Windows 启动器已就绪: ${windowsCliArtifacts.map(item => chalk.cyan(item)).join(', ')}`))
|
|
339
359
|
console.log()
|
package/src/tools/codex.js
CHANGED
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* [model_providers.holysheep]
|
|
13
13
|
* name = "HolySheep"
|
|
14
14
|
* base_url = "https://api.holysheep.ai/v1"
|
|
15
|
-
*
|
|
15
|
+
* env_key = "OPENAI_API_KEY"
|
|
16
|
+
* wire_api = "responses"
|
|
16
17
|
*
|
|
17
18
|
* 注意:旧的 config.json 会被 Rust Codex 忽略!
|
|
18
|
-
*
|
|
19
|
+
* 注意:Rust Codex 当前读取 env_key,不读取自定义 api_key 字段。
|
|
19
20
|
*/
|
|
20
21
|
const fs = require('fs')
|
|
21
22
|
const path = require('path')
|
|
@@ -88,7 +89,8 @@ function isConfiguredInToml() {
|
|
|
88
89
|
const content = readTomlConfig()
|
|
89
90
|
return content.includes('model_provider = "holysheep"') &&
|
|
90
91
|
content.includes('base_url') &&
|
|
91
|
-
content.includes('holysheep.ai')
|
|
92
|
+
content.includes('holysheep.ai') &&
|
|
93
|
+
content.includes('env_key = "OPENAI_API_KEY"')
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
/**
|
|
@@ -111,7 +113,8 @@ function writeTomlConfig(apiKey, baseUrlOpenAI, model) {
|
|
|
111
113
|
`[model_providers.holysheep]`,
|
|
112
114
|
`name = "HolySheep"`,
|
|
113
115
|
`base_url = "${baseUrlOpenAI}"`,
|
|
114
|
-
`
|
|
116
|
+
`env_key = "OPENAI_API_KEY"`,
|
|
117
|
+
`wire_api = "responses"`,
|
|
115
118
|
'',
|
|
116
119
|
].join('\n')
|
|
117
120
|
|
|
@@ -135,12 +138,13 @@ function writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model) {
|
|
|
135
138
|
jsonConfig.model_providers.holysheep = {
|
|
136
139
|
name: 'HolySheep',
|
|
137
140
|
base_url: baseUrlOpenAI,
|
|
138
|
-
|
|
141
|
+
env_key: 'OPENAI_API_KEY',
|
|
142
|
+
wire_api: 'responses',
|
|
139
143
|
}
|
|
140
144
|
jsonConfig.providers.holysheep = {
|
|
141
145
|
name: 'HolySheep',
|
|
142
146
|
baseURL: baseUrlOpenAI,
|
|
143
|
-
|
|
147
|
+
envKey: 'OPENAI_API_KEY',
|
|
144
148
|
}
|
|
145
149
|
fs.writeFileSync(CONFIG_FILE_JSON, JSON.stringify(jsonConfig, null, 2), 'utf8')
|
|
146
150
|
} catch {}
|
|
@@ -169,7 +173,6 @@ module.exports = {
|
|
|
169
173
|
hot: false,
|
|
170
174
|
envVars: {
|
|
171
175
|
OPENAI_API_KEY: apiKey,
|
|
172
|
-
OPENAI_BASE_URL: baseUrlOpenAI,
|
|
173
176
|
},
|
|
174
177
|
}
|
|
175
178
|
},
|
package/src/utils/shell.js
CHANGED
|
@@ -187,6 +187,22 @@ function writeEnvToShell(envVars) {
|
|
|
187
187
|
return written
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
function removeWindowsUserEnvVars(keys = []) {
|
|
191
|
+
if (process.platform !== 'win32') return []
|
|
192
|
+
|
|
193
|
+
const removed = []
|
|
194
|
+
for (const key of keys) {
|
|
195
|
+
try {
|
|
196
|
+
execSync(
|
|
197
|
+
`powershell.exe -NoProfile -Command "[Environment]::SetEnvironmentVariable('${key}', $null, 'User')"`,
|
|
198
|
+
{ stdio: 'ignore' }
|
|
199
|
+
)
|
|
200
|
+
removed.push(`[系统环境变量] ${key}`)
|
|
201
|
+
} catch {}
|
|
202
|
+
}
|
|
203
|
+
return removed
|
|
204
|
+
}
|
|
205
|
+
|
|
190
206
|
function removeEnvFromShell(extraKeys = []) {
|
|
191
207
|
// 默认清理的 key 列表(holysheep 相关的所有环境变量)
|
|
192
208
|
const HS_KEYS = [
|
|
@@ -220,5 +236,6 @@ module.exports = {
|
|
|
220
236
|
writeEnvToShell,
|
|
221
237
|
removeEnvFromShell,
|
|
222
238
|
ensureWindowsUserPathHasNpmBin,
|
|
223
|
-
installWindowsCliShims
|
|
239
|
+
installWindowsCliShims,
|
|
240
|
+
removeWindowsUserEnvVars
|
|
224
241
|
}
|