@simonyea/holysheep-cli 1.0.8 → 1.0.9
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 +5 -0
- package/src/tools/gemini-cli.js +39 -27
package/package.json
CHANGED
package/src/commands/setup.js
CHANGED
|
@@ -174,6 +174,11 @@ async function setup(options) {
|
|
|
174
174
|
spinner.info(`${chalk.yellow(tool.name)} 需要手动配置:`)
|
|
175
175
|
result.steps.forEach((s, i) => console.log(` ${chalk.gray(i + 1 + '.')} ${s}`))
|
|
176
176
|
results.push({ tool, status: 'manual' })
|
|
177
|
+
} else if (result.warning) {
|
|
178
|
+
if (result.envVars) Object.assign(envVarsToWrite, result.envVars)
|
|
179
|
+
spinner.warn(`${chalk.yellow(tool.name)} ${chalk.gray(result.file ? `→ ${result.file}` : '')}`)
|
|
180
|
+
console.log(chalk.yellow(` ⚠️ ${result.warning}`))
|
|
181
|
+
results.push({ tool, status: 'warning', result })
|
|
177
182
|
} else {
|
|
178
183
|
if (result.envVars) Object.assign(envVarsToWrite, result.envVars)
|
|
179
184
|
spinner.succeed(`${chalk.green(tool.name)} ${chalk.gray(result.file ? `→ ${result.file}` : '')}`)
|
package/src/tools/gemini-cli.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gemini CLI 适配器 (@google/gemini-cli)
|
|
3
3
|
*
|
|
4
|
-
* Gemini CLI
|
|
5
|
-
*
|
|
4
|
+
* ⚠️ 重要:Gemini CLI 不支持自定义 base_url/中继
|
|
5
|
+
* 它只能连接 Google 官方 Gemini API。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* 配置方式:
|
|
8
|
+
* 1. settings.json 写入 selectedAuthType = "gemini-api-key"(跳过登录向导)
|
|
9
|
+
* 2. 设置环境变量 GEMINI_API_KEY(需要 Google Gemini API Key,从 aistudio.google.com 获取)
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* 实际测试: Gemini CLI 0.30.0 支持 otherAIProvider 配置
|
|
14
|
-
* 参考: https://github.com/google-gemini/gemini-cli/blob/main/docs/configuration.md
|
|
11
|
+
* HolySheep 暂不支持 Gemini CLI 中继(Gemini CLI 使用 Google 专有协议,非 OpenAI 兼容格式)
|
|
12
|
+
* 建议用户使用 Claude Code / Codex / Aider 等支持中继的工具。
|
|
15
13
|
*/
|
|
16
|
-
const fs
|
|
14
|
+
const fs = require('fs')
|
|
17
15
|
const path = require('path')
|
|
18
|
-
const os
|
|
16
|
+
const os = require('os')
|
|
19
17
|
|
|
20
|
-
const
|
|
18
|
+
const GEMINI_DIR = path.join(os.homedir(), '.gemini')
|
|
19
|
+
const SETTINGS_FILE = path.join(GEMINI_DIR, 'settings.json')
|
|
21
20
|
|
|
22
21
|
function readSettings() {
|
|
23
22
|
try {
|
|
@@ -29,42 +28,55 @@ function readSettings() {
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
function writeSettings(data) {
|
|
32
|
-
|
|
33
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
|
|
31
|
+
if (!fs.existsSync(GEMINI_DIR)) fs.mkdirSync(GEMINI_DIR, { recursive: true })
|
|
34
32
|
fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), 'utf8')
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
module.exports = {
|
|
38
36
|
name: 'Gemini CLI',
|
|
39
37
|
id: 'gemini-cli',
|
|
38
|
+
|
|
40
39
|
checkInstalled() {
|
|
41
40
|
return require('../utils/which').commandExists('gemini')
|
|
42
41
|
},
|
|
42
|
+
|
|
43
43
|
isConfigured() {
|
|
44
|
+
// 检查是否设置了 GEMINI_API_KEY 环境变量
|
|
45
|
+
if (process.env.GEMINI_API_KEY) return true
|
|
46
|
+
// 检查 settings.json 是否已跳过向导
|
|
44
47
|
const s = readSettings()
|
|
45
|
-
return
|
|
48
|
+
return s.selectedAuthType === 'gemini-api-key'
|
|
46
49
|
},
|
|
47
|
-
|
|
50
|
+
|
|
51
|
+
configure(apiKey, _baseUrlAnthropicNoV1, _baseUrlOpenAI) {
|
|
52
|
+
// Gemini CLI 不支持 HolySheep 中继,只能配置为使用官方 Gemini API Key 模式
|
|
53
|
+
// 写入 settings.json 跳过认证向导
|
|
48
54
|
const settings = readSettings()
|
|
55
|
+
settings.selectedAuthType = 'gemini-api-key'
|
|
56
|
+
writeSettings(settings)
|
|
49
57
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
// 环境变量:GEMINI_API_KEY 需要用户自己的 Google Gemini API Key
|
|
59
|
+
// HolySheep API Key (cr_xxx) 无法用于 Gemini CLI
|
|
60
|
+
return {
|
|
61
|
+
file: SETTINGS_FILE,
|
|
62
|
+
hot: false,
|
|
63
|
+
// 不注入 GEMINI_API_KEY,因为 HolySheep key 对 Gemini CLI 无效
|
|
64
|
+
// 用户需要手动设置真正的 Gemini API Key
|
|
65
|
+
envVars: {},
|
|
66
|
+
warning: 'Gemini CLI 需要 Google 官方 Gemini API Key,无法使用 HolySheep 中继。\n请从 https://aistudio.google.com/apikey 获取 API Key 后设置环境变量:\n export GEMINI_API_KEY="your-google-api-key"',
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
// 同时保留原有 general 配置
|
|
58
|
-
writeSettings(settings)
|
|
59
|
-
return { file: SETTINGS_FILE, hot: false }
|
|
60
68
|
},
|
|
69
|
+
|
|
61
70
|
reset() {
|
|
62
71
|
const settings = readSettings()
|
|
63
|
-
delete settings.
|
|
72
|
+
delete settings.selectedAuthType
|
|
64
73
|
writeSettings(settings)
|
|
65
74
|
},
|
|
75
|
+
|
|
66
76
|
getConfigPath() { return SETTINGS_FILE },
|
|
67
|
-
hint: '
|
|
77
|
+
hint: 'Gemini CLI 不支持 HolySheep 中继,需使用 Google 官方 Gemini API Key',
|
|
68
78
|
installCmd: 'npm install -g @google/gemini-cli',
|
|
69
79
|
docsUrl: 'https://github.com/google-gemini/gemini-cli',
|
|
80
|
+
envVarFormat: 'gemini',
|
|
81
|
+
unsupported: true, // 标记为不支持中继
|
|
70
82
|
}
|