@simonyea/holysheep-cli 1.7.27 → 1.7.29
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 +2 -20
- package/src/tools/aider.js +5 -0
- package/src/tools/codex.js +4 -3
- package/src/utils/shell.js +18 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.29",
|
|
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
|
@@ -329,20 +329,12 @@ async function setup(options) {
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
|
|
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 等)
|
|
332
|
+
// Step 5: 清理 shell 环境变量(所有工具改用 JSON/config 文件配置,不再写 shell)
|
|
341
333
|
const staleKeys = ['ANTHROPIC_API_KEY', 'ANTHROPIC_BASE_URL', 'OPENAI_API_KEY', 'OPENAI_BASE_URL']
|
|
342
334
|
try {
|
|
343
335
|
const cleaned = removeEnvFromShell(staleKeys)
|
|
344
336
|
if (cleaned.length > 0) {
|
|
345
|
-
console.log(chalk.gray(
|
|
337
|
+
console.log(chalk.gray(`已清理 shell 中的过时变量: ${cleaned.map(f => chalk.cyan(f)).join(', ')}`))
|
|
346
338
|
}
|
|
347
339
|
} catch {}
|
|
348
340
|
if (process.platform === 'win32') {
|
|
@@ -352,16 +344,6 @@ async function setup(options) {
|
|
|
352
344
|
}
|
|
353
345
|
}
|
|
354
346
|
|
|
355
|
-
if (Object.keys(envVarsToWrite).length > 0) {
|
|
356
|
-
const spinner = ora('写入环境变量到 shell 配置文件...').start()
|
|
357
|
-
try {
|
|
358
|
-
const written = writeEnvToShell(envVarsToWrite)
|
|
359
|
-
spinner.succeed(`环境变量已写入: ${written.map(f => chalk.cyan(f)).join(', ')}`)
|
|
360
|
-
} catch (e) {
|
|
361
|
-
spinner.fail(`写入环境变量失败: ${e.message}`)
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
347
|
if (process.platform === 'win32' && windowsCliArtifacts.length > 0) {
|
|
366
348
|
console.log(chalk.gray(`Windows 启动器已就绪: ${windowsCliArtifacts.map(item => chalk.cyan(item)).join(', ')}`))
|
|
367
349
|
console.log()
|
package/src/tools/aider.js
CHANGED
|
@@ -70,4 +70,9 @@ model: openai/${model}
|
|
|
70
70
|
launchCmd: 'aider',
|
|
71
71
|
installCmd: 'pip install aider-chat',
|
|
72
72
|
docsUrl: 'https://aider.chat',
|
|
73
|
+
envVars: (apiKey, baseUrlOpenAI) => ({
|
|
74
|
+
OPENAI_API_KEY: apiKey,
|
|
75
|
+
OPENAI_BASE_URL: baseUrlOpenAI,
|
|
76
|
+
AIDER_OPENAI_API_BASE: baseUrlOpenAI,
|
|
77
|
+
}),
|
|
73
78
|
}
|
package/src/tools/codex.js
CHANGED
|
@@ -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
|
-
|
|
93
|
+
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 = "
|
|
116
|
+
`env_key = "OPENAI_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: '
|
|
141
|
+
env_key: 'OPENAI_API_KEY',
|
|
142
142
|
wire_api: 'responses',
|
|
143
143
|
}
|
|
144
144
|
jsonConfig.providers.holysheep = {
|
|
@@ -171,6 +171,7 @@ module.exports = {
|
|
|
171
171
|
return {
|
|
172
172
|
file: CONFIG_FILE,
|
|
173
173
|
hot: false,
|
|
174
|
+
envVars: { OPENAI_API_KEY: apiKey },
|
|
174
175
|
}
|
|
175
176
|
},
|
|
176
177
|
reset() {
|
package/src/utils/shell.js
CHANGED
|
@@ -82,7 +82,7 @@ function ensureWindowsUserPathHasNpmBin() {
|
|
|
82
82
|
let currentPath = ''
|
|
83
83
|
try {
|
|
84
84
|
currentPath = execSync(
|
|
85
|
-
'powershell.exe -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"',
|
|
85
|
+
'powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"',
|
|
86
86
|
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }
|
|
87
87
|
).trim()
|
|
88
88
|
} catch {
|
|
@@ -101,11 +101,17 @@ function ensureWindowsUserPathHasNpmBin() {
|
|
|
101
101
|
try {
|
|
102
102
|
const escapedPath = nextPath.replace(/'/g, "''")
|
|
103
103
|
execSync(
|
|
104
|
-
`powershell.exe -NoProfile -Command "[Environment]::SetEnvironmentVariable('Path', '${escapedPath}', 'User')"`,
|
|
104
|
+
`powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "[Environment]::SetEnvironmentVariable('Path', '${escapedPath}', 'User')"`,
|
|
105
105
|
{ stdio: 'ignore' }
|
|
106
106
|
)
|
|
107
107
|
return ['[用户 PATH] %APPDATA%\\npm']
|
|
108
108
|
} catch {
|
|
109
|
+
try {
|
|
110
|
+
const chalk = require('chalk')
|
|
111
|
+
console.warn(chalk.yellow(
|
|
112
|
+
` ⚠️ 无法自动更新 PATH,请手动将以下路径加入系统环境变量 PATH:\n ${npmBin}`
|
|
113
|
+
))
|
|
114
|
+
} catch {}
|
|
109
115
|
return []
|
|
110
116
|
}
|
|
111
117
|
}
|
|
@@ -120,10 +126,13 @@ function installWindowsCliShims() {
|
|
|
120
126
|
fs.mkdirSync(npmBin, { recursive: true })
|
|
121
127
|
|
|
122
128
|
const cliSpec = `@simonyea/holysheep-cli@${pkg.version}`
|
|
129
|
+
// 优先使用本地安装的包(npm install -g 场景),避免依赖 PATH 中的 hs 命令
|
|
123
130
|
const cmdContent = [
|
|
124
131
|
'@echo off',
|
|
125
132
|
'setlocal',
|
|
126
|
-
'if exist "%~
|
|
133
|
+
'if exist "%~dp0node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js" (',
|
|
134
|
+
' node "%~dp0node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js" %*',
|
|
135
|
+
') else if exist "%~dp0npx.cmd" (',
|
|
127
136
|
` call "%~dp0npx.cmd" ${cliSpec} %*`,
|
|
128
137
|
') else (',
|
|
129
138
|
` call npx ${cliSpec} %*`,
|
|
@@ -132,9 +141,12 @@ function installWindowsCliShims() {
|
|
|
132
141
|
].join('\r\n')
|
|
133
142
|
|
|
134
143
|
const ps1Content = [
|
|
135
|
-
'$
|
|
136
|
-
'
|
|
137
|
-
|
|
144
|
+
'$dir = $PSScriptRoot',
|
|
145
|
+
'$localPkg = Join-Path $dir "node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js"',
|
|
146
|
+
'if (Test-Path $localPkg) {',
|
|
147
|
+
' & node $localPkg @args',
|
|
148
|
+
'} elseif (Test-Path (Join-Path $dir "npx.cmd")) {',
|
|
149
|
+
` & (Join-Path $dir "npx.cmd") "${cliSpec}" @args`,
|
|
138
150
|
'} else {',
|
|
139
151
|
` & npx "${cliSpec}" @args`,
|
|
140
152
|
'}',
|