@simonyea/holysheep-cli 1.1.2 → 1.1.4
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 +2 -2
- package/package.json +1 -1
- package/src/commands/setup.js +8 -1
- package/src/index.js +10 -2
- package/src/tools/aider.js +1 -1
- package/src/tools/openclaw.js +75 -48
- package/src/utils/config.js +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ Instead of manually editing config files and environment variables for each tool
|
|
|
41
41
|
| [Aider](https://aider.chat) | `pip install aider-install && aider-install` | `~/.aider.conf.yml` | ✅ Auto |
|
|
42
42
|
| [Continue.dev](https://continue.dev) | VS Code marketplace | `~/.continue/config.yaml` | ✅ Auto |
|
|
43
43
|
| [OpenCode](https://opencode.ai) | `brew install anomalyco/tap/opencode` | `~/.config/opencode/opencode.json` | ✅ Auto |
|
|
44
|
-
| [OpenClaw](https://github.com/
|
|
44
|
+
| [OpenClaw](https://github.com/openclaw/openclaw) | `npm i -g openclaw@latest` | `~/.openclaw/openclaw.json` | ✅ Auto |
|
|
45
45
|
| [Cursor](https://cursor.sh) | Download from website | GUI only (encrypted storage) | ⚠️ Manual |
|
|
46
46
|
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `npm i -g @google/gemini-cli` | Google protocol only | ❌ Not supported |
|
|
47
47
|
|
|
@@ -135,7 +135,7 @@ HolySheep 是面向中国开发者的 Claude/GPT/Gemini 官方 API 中转服务
|
|
|
135
135
|
| [Aider](https://aider.chat) | `pip install aider-install && aider-install` | `~/.aider.conf.yml` | ✅ 自动 |
|
|
136
136
|
| [Continue.dev](https://continue.dev) | VS Code 插件市场 | `~/.continue/config.yaml` | ✅ 自动 |
|
|
137
137
|
| [OpenCode](https://opencode.ai) | `brew install anomalyco/tap/opencode` | `~/.config/opencode/opencode.json` | ✅ 自动 |
|
|
138
|
-
| [OpenClaw](https://github.com/
|
|
138
|
+
| [OpenClaw](https://github.com/openclaw/openclaw) | `npm i -g openclaw@latest` | `~/.openclaw/openclaw.json` | ✅ 自动 |
|
|
139
139
|
| [Cursor](https://cursor.sh) | 官网下载 | GUI 手动配置(加密存储) | ⚠️ 手动 |
|
|
140
140
|
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `npm i -g @google/gemini-cli` | 仅支持 Google 官方协议 | ❌ 不支持 |
|
|
141
141
|
|
package/package.json
CHANGED
package/src/commands/setup.js
CHANGED
|
@@ -15,6 +15,7 @@ const AUTO_INSTALL = {
|
|
|
15
15
|
'codex': { cmd: 'npm install -g @openai/codex', mgr: 'npm' },
|
|
16
16
|
'gemini-cli': { cmd: 'npm install -g @google/gemini-cli', mgr: 'npm' },
|
|
17
17
|
'opencode': { cmd: 'npm install -g opencode-ai', mgr: 'npm' },
|
|
18
|
+
'openclaw': { cmd: 'npm install -g openclaw@latest', mgr: 'npm' },
|
|
18
19
|
'aider': { cmd: 'pip install aider-chat', mgr: 'pip' },
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -75,7 +76,13 @@ async function setup(options) {
|
|
|
75
76
|
if (!apiKey) {
|
|
76
77
|
console.log(chalk.yellow('需要 API Key 才能配置工具。'))
|
|
77
78
|
console.log(chalk.cyan(`还没有账号?前往注册:${SHOP_URL}`))
|
|
78
|
-
console.log(chalk.gray(`提示:可先运行 ${chalk.cyan('hs login')} 登录并保存 Key,之后 setup
|
|
79
|
+
console.log(chalk.gray(`提示:可先运行 ${chalk.cyan('hs login')} 登录并保存 Key,之后 setup 将自动读取。`))
|
|
80
|
+
if (process.platform === 'win32') {
|
|
81
|
+
console.log(chalk.gray(` ⚠️ Windows 用户:如果 ${chalk.cyan('hs')} 命令找不到,请用以下方式运行:`))
|
|
82
|
+
console.log(chalk.gray(` ${chalk.white('npx @simonyea/holysheep-cli login')} (无需安装,直接用)`))
|
|
83
|
+
console.log(chalk.gray(` 或重启终端后再试`))
|
|
84
|
+
}
|
|
85
|
+
console.log()
|
|
79
86
|
|
|
80
87
|
const { key } = await inquirer.prompt([{
|
|
81
88
|
type: 'password',
|
package/src/index.js
CHANGED
|
@@ -5,11 +5,19 @@ const { program } = require('commander')
|
|
|
5
5
|
const chalk = require('chalk')
|
|
6
6
|
const pkg = require('../package.json')
|
|
7
7
|
|
|
8
|
+
// Windows 用户:检测 npm bin 路径是否在 PATH 中
|
|
9
|
+
if (process.platform === 'win32') {
|
|
10
|
+
const { execSync } = require('child_process')
|
|
11
|
+
try {
|
|
12
|
+
// 静默检查,只在首次遇到问题时才会走到这(因为已经能运行 node 了)
|
|
13
|
+
} catch {}
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
// Banner
|
|
9
17
|
function printBanner() {
|
|
10
18
|
console.log()
|
|
11
19
|
console.log(chalk.bold('🐑 ' + chalk.hex('#e8a46a')('HolySheep CLI') + ' v' + pkg.version))
|
|
12
|
-
console.log(chalk.gray('官方 Claude/GPT/Gemini API · ¥1=$1 ·
|
|
20
|
+
console.log(chalk.gray('官方 Claude/GPT/Gemini API · ¥1=$1 · holysheep.ai'))
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
program
|
|
@@ -18,7 +26,7 @@ program
|
|
|
18
26
|
.version(pkg.version, '-v, --version')
|
|
19
27
|
.addHelpText('before', `
|
|
20
28
|
🐑 HolySheep CLI v${pkg.version}
|
|
21
|
-
官方 Claude / GPT / Gemini API · ¥1=$1 · https://
|
|
29
|
+
官方 Claude / GPT / Gemini API · ¥1=$1 · https://holysheep.ai
|
|
22
30
|
|
|
23
31
|
支持工具: Claude Code · Codex · Gemini CLI · OpenCode · OpenClaw · Aider · Cursor · Continue
|
|
24
32
|
`)
|
package/src/tools/aider.js
CHANGED
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
|
50
50
|
// Aider 用 openai-api-base(OpenAI 兼容格式,带 /v1)
|
|
51
51
|
// model 格式: openai/<model-name> 表示使用 OpenAI 兼容接口
|
|
52
52
|
const block = `
|
|
53
|
-
# holysheep-cli managed — https://
|
|
53
|
+
# holysheep-cli managed — https://holysheep.ai
|
|
54
54
|
openai-api-key: ${apiKey}
|
|
55
55
|
openai-api-base: ${baseUrlOpenAI}
|
|
56
56
|
model: openai/claude-sonnet-4-5
|
package/src/tools/openclaw.js
CHANGED
|
@@ -1,43 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenClaw 适配器
|
|
3
|
-
* OpenClaw 是基于 Claude Code 架构的开源 AI 编程助手
|
|
4
|
-
* 配置方式与 Claude Code 几乎相同,使用 Anthropic API 格式
|
|
2
|
+
* OpenClaw 适配器 (github.com/openclaw/openclaw)
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* OpenClaw 是个人 AI 助手 + 多渠道消息网关
|
|
5
|
+
* 支持 WhatsApp/Telegram/Signal/Discord/iMessage 等 20+ 渠道
|
|
8
6
|
*
|
|
9
|
-
*
|
|
7
|
+
* 安装方式: npm install -g openclaw@latest
|
|
8
|
+
* 配置文件: ~/.openclaw/openclaw.json (JSON5 格式)
|
|
9
|
+
* 文档: https://docs.openclaw.ai
|
|
10
|
+
*
|
|
11
|
+
* HolySheep 接入方式:通过 env.ANTHROPIC_API_KEY + env.ANTHROPIC_BASE_URL
|
|
12
|
+
* 设置 Anthropic provider 自定义 base URL 指向 HolySheep 中继
|
|
10
13
|
*/
|
|
11
|
-
const fs
|
|
14
|
+
const fs = require('fs')
|
|
12
15
|
const path = require('path')
|
|
13
|
-
const os
|
|
16
|
+
const os = require('os')
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const openclaw = path.join(os.homedir(), '.openclaw', 'settings.json')
|
|
18
|
-
const claude = path.join(os.homedir(), '.claude', 'settings.json')
|
|
19
|
-
if (fs.existsSync(openclaw)) return openclaw
|
|
20
|
-
// 检查是否安装了 openclaw
|
|
21
|
-
try {
|
|
22
|
-
require('child_process').execSync('which openclaw', { stdio: 'ignore' })
|
|
23
|
-
return openclaw
|
|
24
|
-
} catch {
|
|
25
|
-
return openclaw // 默认路径
|
|
26
|
-
}
|
|
27
|
-
}
|
|
18
|
+
const OPENCLAW_DIR = path.join(os.homedir(), '.openclaw')
|
|
19
|
+
const CONFIG_FILE = path.join(OPENCLAW_DIR, 'openclaw.json')
|
|
28
20
|
|
|
29
|
-
function
|
|
21
|
+
function readConfig() {
|
|
30
22
|
try {
|
|
31
|
-
if (fs.existsSync(
|
|
32
|
-
|
|
23
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
24
|
+
// openclaw.json 是 JSON5 格式,先去掉注释再 parse
|
|
25
|
+
const raw = fs.readFileSync(CONFIG_FILE, 'utf8')
|
|
26
|
+
return JSON.parse(raw.replace(/\/\/[^\n]*/g, '').replace(/\/\*[\s\S]*?\*\//g, ''))
|
|
33
27
|
}
|
|
34
28
|
} catch {}
|
|
35
29
|
return {}
|
|
36
30
|
}
|
|
37
31
|
|
|
38
|
-
function
|
|
39
|
-
fs.mkdirSync(
|
|
40
|
-
fs.writeFileSync(
|
|
32
|
+
function writeConfig(data) {
|
|
33
|
+
fs.mkdirSync(OPENCLAW_DIR, { recursive: true })
|
|
34
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(data, null, 2), 'utf8')
|
|
41
35
|
}
|
|
42
36
|
|
|
43
37
|
module.exports = {
|
|
@@ -47,30 +41,63 @@ module.exports = {
|
|
|
47
41
|
return require('../utils/which').commandExists('openclaw')
|
|
48
42
|
},
|
|
49
43
|
isConfigured() {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
const c = readConfig()
|
|
45
|
+
return !!(
|
|
46
|
+
c.env?.ANTHROPIC_BASE_URL?.includes('holysheep') ||
|
|
47
|
+
c.models?.providers?.holysheep
|
|
48
|
+
)
|
|
53
49
|
},
|
|
54
|
-
configure(apiKey, baseUrlAnthropicNoV1) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
configure(apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI) {
|
|
51
|
+
const config = readConfig()
|
|
52
|
+
|
|
53
|
+
// 设置环境变量 — Anthropic provider 使用 ANTHROPIC_BASE_URL 覆盖默认地址
|
|
54
|
+
if (!config.env) config.env = {}
|
|
55
|
+
config.env.ANTHROPIC_API_KEY = apiKey
|
|
56
|
+
config.env.ANTHROPIC_BASE_URL = baseUrlAnthropicNoV1 // https://api.holysheep.ai
|
|
57
|
+
|
|
58
|
+
// 设置默认模型(如果未配置)
|
|
59
|
+
if (!config.agents) config.agents = {}
|
|
60
|
+
if (!config.agents.defaults) config.agents.defaults = {}
|
|
61
|
+
if (!config.agents.defaults.model) {
|
|
62
|
+
config.agents.defaults.model = { primary: 'anthropic/claude-sonnet-4-5' }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 同时注册一个 holysheep 自定义 provider(支持所有模型)
|
|
66
|
+
if (!config.models) config.models = {}
|
|
67
|
+
config.models.mode = 'merge'
|
|
68
|
+
if (!config.models.providers) config.models.providers = {}
|
|
69
|
+
config.models.providers.holysheep = {
|
|
70
|
+
baseUrl: baseUrlOpenAI, // https://api.holysheep.ai/v1
|
|
71
|
+
apiKey,
|
|
72
|
+
api: 'openai-completions',
|
|
73
|
+
models: [
|
|
74
|
+
{ id: 'claude-sonnet-4-5', name: 'Claude Sonnet 4.5 (HolySheep)' },
|
|
75
|
+
{ id: 'claude-opus-4-5', name: 'Claude Opus 4.5 (HolySheep)' },
|
|
76
|
+
{ id: 'gpt-5.4', name: 'GPT-5.4 (HolySheep)' },
|
|
77
|
+
{ id: 'gpt-5', name: 'GPT-5 (HolySheep)' },
|
|
78
|
+
],
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
writeConfig(config)
|
|
82
|
+
return { file: CONFIG_FILE, hot: false }
|
|
62
83
|
},
|
|
63
84
|
reset() {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
delete
|
|
68
|
-
|
|
85
|
+
const config = readConfig()
|
|
86
|
+
if (config.env) {
|
|
87
|
+
delete config.env.ANTHROPIC_API_KEY
|
|
88
|
+
delete config.env.ANTHROPIC_BASE_URL
|
|
89
|
+
}
|
|
90
|
+
if (config.models?.providers) {
|
|
91
|
+
delete config.models.providers.holysheep
|
|
92
|
+
}
|
|
93
|
+
// 如果默认模型是 anthropic/xxx,清掉
|
|
94
|
+
if (config.agents?.defaults?.model?.primary?.startsWith('anthropic/')) {
|
|
95
|
+
delete config.agents.defaults.model
|
|
69
96
|
}
|
|
70
|
-
|
|
97
|
+
writeConfig(config)
|
|
71
98
|
},
|
|
72
|
-
getConfigPath() { return
|
|
73
|
-
hint: '
|
|
74
|
-
installCmd: '
|
|
75
|
-
docsUrl: 'https://
|
|
99
|
+
getConfigPath() { return CONFIG_FILE },
|
|
100
|
+
hint: '切换后重启 OpenClaw 生效;支持 /model 命令切换模型',
|
|
101
|
+
installCmd: 'npm install -g openclaw@latest',
|
|
102
|
+
docsUrl: 'https://docs.openclaw.ai',
|
|
76
103
|
}
|
package/src/utils/config.js
CHANGED
|
@@ -11,7 +11,7 @@ const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json')
|
|
|
11
11
|
|
|
12
12
|
const BASE_URL_ANTHROPIC = 'https://api.holysheep.ai' // 不带 /v1 (Anthropic SDK)
|
|
13
13
|
const BASE_URL_OPENAI = 'https://api.holysheep.ai/v1' // 带 /v1 (OpenAI 兼容)
|
|
14
|
-
const SHOP_URL = 'https://
|
|
14
|
+
const SHOP_URL = 'https://holysheep.ai'
|
|
15
15
|
|
|
16
16
|
function ensureDir() {
|
|
17
17
|
if (!fs.existsSync(CONFIG_DIR)) {
|