@simonyea/holysheep-cli 1.2.0 → 1.2.2
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/tools/openclaw.js +7 -5
- package/src/utils/shell.js +47 -9
package/package.json
CHANGED
package/src/tools/openclaw.js
CHANGED
|
@@ -59,7 +59,7 @@ module.exports = {
|
|
|
59
59
|
if (!config.agents) config.agents = {}
|
|
60
60
|
if (!config.agents.defaults) config.agents.defaults = {}
|
|
61
61
|
if (!config.agents.defaults.model) {
|
|
62
|
-
config.agents.defaults.model = { primary: 'anthropic/claude-sonnet-4-5' }
|
|
62
|
+
config.agents.defaults.model = { primary: 'anthropic/claude-sonnet-4-5-20250929' }
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// 同时注册一个 holysheep 自定义 provider(支持所有模型)
|
|
@@ -71,10 +71,12 @@ module.exports = {
|
|
|
71
71
|
apiKey,
|
|
72
72
|
api: 'openai-completions',
|
|
73
73
|
models: [
|
|
74
|
-
{ id: 'claude-sonnet-4-5', name: 'Claude Sonnet 4.5 (HolySheep)' },
|
|
75
|
-
{ id: 'claude-
|
|
76
|
-
{ id: '
|
|
77
|
-
{ id: '
|
|
74
|
+
{ id: 'claude-sonnet-4-5-20250929', name: 'Claude Sonnet 4.5 (HolySheep)' },
|
|
75
|
+
{ id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4 (HolySheep)' },
|
|
76
|
+
{ id: 'claude-opus-4-5-20251101', name: 'Claude Opus 4.5 (HolySheep)' },
|
|
77
|
+
{ id: 'claude-opus-4-20250514', name: 'Claude Opus 4 (HolySheep)' },
|
|
78
|
+
{ id: 'gpt-4o', name: 'GPT-4o (HolySheep)' },
|
|
79
|
+
{ id: 'gemini-2.5-pro', name: 'Gemini 2.5 Pro (HolySheep)' },
|
|
78
80
|
],
|
|
79
81
|
}
|
|
80
82
|
|
package/src/utils/shell.js
CHANGED
|
@@ -41,26 +41,50 @@ function removeHsBlock(content) {
|
|
|
41
41
|
return content.replace(re, '')
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* 移除 rc 文件里用户手动写的同名 export/set -gx 行
|
|
46
|
+
* 防止旧值在 holysheep-cli managed 块之后覆盖新值
|
|
47
|
+
*/
|
|
48
|
+
function removeStaleExports(content, keys, isFish = false) {
|
|
49
|
+
let result = content
|
|
50
|
+
for (const key of keys) {
|
|
51
|
+
if (isFish) {
|
|
52
|
+
// fish: set -gx KEY "..." 或 set -gx KEY ...
|
|
53
|
+
result = result.replace(new RegExp(`\\n?set\\s+-gx\\s+${escapeRegex(key)}\\s+[^\\n]*\\n?`, 'g'), '\n')
|
|
54
|
+
} else {
|
|
55
|
+
// bash/zsh: export KEY="..." 或 export KEY=...
|
|
56
|
+
result = result.replace(new RegExp(`\\n?export\\s+${escapeRegex(key)}=[^\\n]*\\n?`, 'g'), '\n')
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// 清理多余空行
|
|
60
|
+
return result.replace(/\n{3,}/g, '\n\n')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function buildEnvBlock(envVars, isFish = false) {
|
|
45
64
|
const lines = [MARKER_START]
|
|
46
65
|
for (const [k, v] of Object.entries(envVars)) {
|
|
47
|
-
|
|
66
|
+
// fish shell 用 set -gx,其他 shell 用 export
|
|
67
|
+
lines.push(isFish ? `set -gx ${k} "${v}"` : `export ${k}="${v}"`)
|
|
48
68
|
}
|
|
49
69
|
lines.push(MARKER_END)
|
|
50
70
|
return '\n' + lines.join('\n') + '\n'
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
function writeEnvToShell(envVars) {
|
|
54
|
-
// Windows: 用 setx
|
|
74
|
+
// Windows: 用 setx 写入用户级环境变量(需重启终端生效)
|
|
55
75
|
if (process.platform === 'win32') {
|
|
56
76
|
const { execSync } = require('child_process')
|
|
57
77
|
const written = []
|
|
58
78
|
for (const [k, v] of Object.entries(envVars)) {
|
|
59
79
|
try {
|
|
60
80
|
execSync(`setx ${k} "${v}"`, { stdio: 'ignore' })
|
|
61
|
-
written.push(`[
|
|
81
|
+
written.push(`[系统环境变量] ${k}`)
|
|
62
82
|
} catch {}
|
|
63
83
|
}
|
|
84
|
+
if (written.length > 0) {
|
|
85
|
+
const chalk = require('chalk')
|
|
86
|
+
console.log(chalk.yellow('\n ⚠️ Windows 环境变量已写入,需要重启终端后生效'))
|
|
87
|
+
}
|
|
64
88
|
return written
|
|
65
89
|
}
|
|
66
90
|
|
|
@@ -70,23 +94,37 @@ function writeEnvToShell(envVars) {
|
|
|
70
94
|
for (const file of files) {
|
|
71
95
|
let content = ''
|
|
72
96
|
try { content = fs.readFileSync(file, 'utf8') } catch {}
|
|
97
|
+
const isFish = file.endsWith('config.fish')
|
|
98
|
+
// 1. 清理旧的 holysheep managed 块
|
|
73
99
|
content = removeHsBlock(content)
|
|
74
|
-
|
|
100
|
+
// 2. 清理用户手动写的同名 export(防止旧值覆盖新值)
|
|
101
|
+
content = removeStaleExports(content, Object.keys(envVars), isFish)
|
|
102
|
+
// 3. 追加新的 managed 块
|
|
103
|
+
content += buildEnvBlock(envVars, isFish)
|
|
75
104
|
fs.writeFileSync(file, content, 'utf8')
|
|
76
105
|
written.push(file)
|
|
77
106
|
}
|
|
78
107
|
return written
|
|
79
108
|
}
|
|
80
109
|
|
|
81
|
-
function removeEnvFromShell() {
|
|
110
|
+
function removeEnvFromShell(extraKeys = []) {
|
|
111
|
+
// 默认清理的 key 列表(holysheep 相关的所有环境变量)
|
|
112
|
+
const HS_KEYS = [
|
|
113
|
+
'ANTHROPIC_AUTH_TOKEN', 'ANTHROPIC_API_KEY', 'ANTHROPIC_BASE_URL',
|
|
114
|
+
'OPENAI_API_KEY', 'OPENAI_BASE_URL',
|
|
115
|
+
'HOLYSHEEP_API_KEY',
|
|
116
|
+
...extraKeys,
|
|
117
|
+
]
|
|
82
118
|
const files = getShellRcFiles()
|
|
83
119
|
const cleaned = []
|
|
84
120
|
for (const file of files) {
|
|
85
121
|
if (!fs.existsSync(file)) continue
|
|
122
|
+
const isFish = file.endsWith('config.fish')
|
|
86
123
|
let content = fs.readFileSync(file, 'utf8')
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
124
|
+
let updated = removeHsBlock(content)
|
|
125
|
+
updated = removeStaleExports(updated, HS_KEYS, isFish)
|
|
126
|
+
if (updated !== content) {
|
|
127
|
+
fs.writeFileSync(file, updated, 'utf8')
|
|
90
128
|
cleaned.push(file)
|
|
91
129
|
}
|
|
92
130
|
}
|