@simonyea/holysheep-cli 1.0.8 → 1.1.0
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/README.md +28 -20
- package/package.json +1 -1
- package/src/commands/setup.js +5 -0
- package/src/tools/cursor.js +26 -24
- package/src/tools/gemini-cli.js +39 -27
package/README.md
CHANGED
|
@@ -34,16 +34,20 @@ Instead of manually editing config files and environment variables for each tool
|
|
|
34
34
|
|
|
35
35
|
### Supported Tools
|
|
36
36
|
|
|
37
|
-
| Tool | Install | Config Method |
|
|
38
|
-
|
|
39
|
-
| [Claude Code](https://docs.anthropic.com/claude-code) | `npm i -g @anthropic-ai/claude-code` | `~/.claude/settings.json` | ✅ |
|
|
40
|
-
| [Codex CLI](https://github.com/openai/codex) | `npm i -g @openai/codex` | `~/.codex/config.
|
|
41
|
-
| [
|
|
42
|
-
| [
|
|
43
|
-
| [
|
|
44
|
-
| [
|
|
45
|
-
| [Cursor](https://cursor.sh) | Download from website | GUI
|
|
46
|
-
| [
|
|
37
|
+
| Tool | Install | Config Method | Status |
|
|
38
|
+
|------|---------|---------------|--------|
|
|
39
|
+
| [Claude Code](https://docs.anthropic.com/claude-code) | `npm i -g @anthropic-ai/claude-code` | `~/.claude/settings.json` | ✅ Auto |
|
|
40
|
+
| [Codex CLI](https://github.com/openai/codex) | `npm i -g @openai/codex` | `~/.codex/config.toml` | ✅ Auto |
|
|
41
|
+
| [Aider](https://aider.chat) | `pip install aider-install && aider-install` | `~/.aider.conf.yml` | ✅ Auto |
|
|
42
|
+
| [Continue.dev](https://continue.dev) | VS Code marketplace | `~/.continue/config.yaml` | ✅ Auto |
|
|
43
|
+
| [OpenCode](https://github.com/sst/opencode) | `npm i -g opencode-ai` | `~/.config/opencode/config.json` | ✅ Auto |
|
|
44
|
+
| [OpenClaw](https://github.com/iOfficeAI/AionUi) | Download from website | `~/.openclaw/settings.json` | ✅ Auto |
|
|
45
|
+
| [Cursor](https://cursor.sh) | Download from website | GUI only (encrypted storage) | ⚠️ Manual |
|
|
46
|
+
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `npm i -g @google/gemini-cli` | Google protocol only | ❌ Not supported |
|
|
47
|
+
|
|
48
|
+
> **Note on Cursor**: Cursor (2025+) requires logging into the official Cursor account. API keys are stored in encrypted secret storage that CLI cannot access. Manual configuration via `Settings → Models → Override OpenAI Base URL` is required after login.
|
|
49
|
+
>
|
|
50
|
+
> **Note on Gemini CLI**: Gemini CLI uses Google's proprietary protocol and does not support custom relay endpoints. Use your own Google Gemini API Key from [aistudio.google.com](https://aistudio.google.com/apikey).
|
|
47
51
|
|
|
48
52
|
### Installation
|
|
49
53
|
|
|
@@ -124,16 +128,20 @@ HolySheep 是面向中国开发者的 Claude/GPT/Gemini 官方 API 中转服务
|
|
|
124
128
|
|
|
125
129
|
### 支持的工具
|
|
126
130
|
|
|
127
|
-
| 工具 | 安装方式 | 配置方式 |
|
|
128
|
-
|
|
129
|
-
| [Claude Code](https://docs.anthropic.com/claude-code) | `npm i -g @anthropic-ai/claude-code` | `~/.claude/settings.json` | ✅ |
|
|
130
|
-
| [Codex CLI](https://github.com/openai/codex) | `npm i -g @openai/codex` | `~/.codex/config.
|
|
131
|
-
| [
|
|
132
|
-
| [
|
|
133
|
-
| [
|
|
134
|
-
| [
|
|
135
|
-
| [Cursor](https://cursor.sh) | 官网下载 |
|
|
136
|
-
| [
|
|
131
|
+
| 工具 | 安装方式 | 配置方式 | 状态 |
|
|
132
|
+
|------|---------|---------|------|
|
|
133
|
+
| [Claude Code](https://docs.anthropic.com/claude-code) | `npm i -g @anthropic-ai/claude-code` | `~/.claude/settings.json` | ✅ 自动 |
|
|
134
|
+
| [Codex CLI](https://github.com/openai/codex) | `npm i -g @openai/codex` | `~/.codex/config.toml` | ✅ 自动 |
|
|
135
|
+
| [Aider](https://aider.chat) | `pip install aider-install && aider-install` | `~/.aider.conf.yml` | ✅ 自动 |
|
|
136
|
+
| [Continue.dev](https://continue.dev) | VS Code 插件市场 | `~/.continue/config.yaml` | ✅ 自动 |
|
|
137
|
+
| [OpenCode](https://github.com/sst/opencode) | `npm i -g opencode-ai` | `~/.config/opencode/config.json` | ✅ 自动 |
|
|
138
|
+
| [OpenClaw](https://github.com/iOfficeAI/AionUi) | 官网下载 | `~/.openclaw/settings.json` | ✅ 自动 |
|
|
139
|
+
| [Cursor](https://cursor.sh) | 官网下载 | GUI 手动配置(加密存储) | ⚠️ 手动 |
|
|
140
|
+
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `npm i -g @google/gemini-cli` | 仅支持 Google 官方协议 | ❌ 不支持 |
|
|
141
|
+
|
|
142
|
+
> **关于 Cursor**:Cursor 新版(2025+)必须登录官方账号,API Key 存储在加密区域,CLI 无法写入。需登录后在 `Settings → Models → Override OpenAI Base URL` 手动填入。
|
|
143
|
+
>
|
|
144
|
+
> **关于 Gemini CLI**:Gemini CLI 使用 Google 专有协议,不支持自定义中转地址。需使用从 [aistudio.google.com](https://aistudio.google.com/apikey) 获取的 Google Gemini API Key。
|
|
137
145
|
|
|
138
146
|
### 安装
|
|
139
147
|
|
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/cursor.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cursor 适配器
|
|
3
|
-
* Cursor 是基于 VSCode 的 AI 编辑器
|
|
4
3
|
*
|
|
5
|
-
* Cursor
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* ⚠️ 重要:Cursor 新版本(2025+)必须登录官方账号才能使用,
|
|
5
|
+
* 即使是「自带 API Key」模式也需要先登录 Cursor 账号。
|
|
6
|
+
* Cursor 的 API Key 和 Base URL 存储在加密的 secret storage 中,
|
|
7
|
+
* CLI 无法直接写入,且官方越来越绑定自己的账号体系。
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* 3. 生成 .cursor/mcp.json 供 Cursor MCP 功能使用
|
|
9
|
+
* 推荐替代方案:
|
|
10
|
+
* - Continue(VS Code/JetBrains 插件,完全支持自定义 API)
|
|
11
|
+
* - Claude Code(命令行,官方支持自定义 base_url)
|
|
12
|
+
* - Aider(命令行,完全支持自定义 API)
|
|
14
13
|
*
|
|
15
|
-
* Cursor
|
|
14
|
+
* 如果仍要手动配置 Cursor:
|
|
15
|
+
* Settings → Models → Override OpenAI Base URL + OpenAI API Key
|
|
16
16
|
*/
|
|
17
17
|
const fs = require('fs')
|
|
18
18
|
const path = require('path')
|
|
@@ -39,31 +39,33 @@ module.exports = {
|
|
|
39
39
|
id: 'cursor',
|
|
40
40
|
checkInstalled() { return checkCursorInstalled() },
|
|
41
41
|
isConfigured() {
|
|
42
|
-
//
|
|
43
|
-
return !!(process.env.OPENAI_API_KEY && process.env.OPENAI_BASE_URL?.includes('holysheep'))
|
|
42
|
+
return false // 无法检测(加密存储)
|
|
44
43
|
},
|
|
45
|
-
configure(apiKey, baseUrlOpenAI) {
|
|
46
|
-
// Cursor
|
|
47
|
-
// 返回 manual
|
|
44
|
+
configure(apiKey, _baseUrlAnthropicNoV1, baseUrlOpenAI) {
|
|
45
|
+
// Cursor 需要登录官方账号,且 API Key 存储在加密区域,CLI 无法写入
|
|
46
|
+
// 返回 manual + warning
|
|
48
47
|
return {
|
|
49
48
|
manual: true,
|
|
50
49
|
steps: [
|
|
51
|
-
'
|
|
52
|
-
'
|
|
50
|
+
'⚠️ Cursor 新版本需要先登录官方账号(免费账号即可)',
|
|
51
|
+
'打开 Cursor → Settings(⌘+, / Ctrl+,)→ 左侧 Models',
|
|
52
|
+
'找到 "OpenAI API Key" 区域,勾选 "Enable OpenAI API Key"',
|
|
53
53
|
`填入 API Key: ${apiKey}`,
|
|
54
|
-
`填入
|
|
55
|
-
'点击 "Verify"
|
|
56
|
-
'
|
|
54
|
+
`填入 Override OpenAI Base URL: ${baseUrlOpenAI}`,
|
|
55
|
+
'点击 "Verify" 验证连接,然后在模型列表中选择 claude-* 模型',
|
|
56
|
+
'💡 推荐使用 Continue(VS Code 插件)替代,配置更简单',
|
|
57
57
|
],
|
|
58
|
-
imageHint: '💡 Cursor Settings → Models → Override OpenAI Base URL',
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
reset() {
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
return {
|
|
62
|
+
manual: true,
|
|
63
|
+
steps: ['打开 Cursor Settings → Models → 清除 API Key 和 Override Base URL'],
|
|
64
|
+
}
|
|
64
65
|
},
|
|
65
66
|
getConfigPath() { return getCursorUserDir() },
|
|
66
|
-
hint: '
|
|
67
|
+
hint: '需要登录 Cursor 账号 + 在 GUI 中手动配置(推荐用 Continue 替代)',
|
|
67
68
|
installCmd: '访问 https://cursor.sh 下载安装',
|
|
68
69
|
docsUrl: 'https://cursor.sh',
|
|
70
|
+
unsupported: true,
|
|
69
71
|
}
|
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
|
}
|