@simonyea/holysheep-cli 1.2.4 → 1.2.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "一键配置所有 AI 编程工具接入 HolySheep API — Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw / Aider / Cursor",
5
5
  "keywords": [
6
6
  "claude",
@@ -70,9 +70,9 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
70
70
  // ── 3. 默认模型 ────────────────────────────────────────────────────
71
71
  if (!config.agents) config.agents = {}
72
72
  if (!config.agents.defaults) config.agents.defaults = {}
73
- // 总是覆写为 HolySheep sonnet-4-6(用户可以在 /model 命令里切换)
73
+ // 总是覆写为 HolySheep 最新 Sonnet(用户可以在 /model 命令里切换)
74
74
  config.agents.defaults.model = {
75
- primary: 'anthropic/claude-sonnet-4-6',
75
+ primary: 'anthropic/claude-sonnet-4-5-20250929',
76
76
  }
77
77
 
78
78
  // ── 4. 自定义 holysheep provider(OpenAI-compatible,支持所有模型)
@@ -84,7 +84,6 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
84
84
  apiKey,
85
85
  api: 'openai-completions',
86
86
  models: [
87
- { id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6 (HolySheep)' },
88
87
  { id: 'claude-sonnet-4-5-20250929', name: 'Claude Sonnet 4.5 (HolySheep)' },
89
88
  { id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4 (HolySheep)' },
90
89
  { id: 'claude-opus-4-5-20251101', name: 'Claude Opus 4.5 (HolySheep)' },
@@ -138,8 +137,8 @@ module.exports = {
138
137
 
139
138
  writeConfig(config)
140
139
 
141
- // 自动启动 Gateway,用户直接打开浏览器即可
142
- _autoStartGateway()
140
+ // 自动初始化并启动 Gateway
141
+ _initAndStartGateway()
143
142
 
144
143
  return { file: CONFIG_FILE, hot: false, _gatewayStarted: true }
145
144
  },
@@ -168,42 +167,64 @@ module.exports = {
168
167
  }
169
168
 
170
169
  /**
171
- * 自动在后台启动 OpenClaw Gateway
170
+ * 自动初始化并启动 OpenClaw Gateway
172
171
  *
173
- * 策略(按顺序尝试):
174
- * 1. openclaw gateway start — 已有 daemon/service 直接启动
175
- * 2. openclaw gateway --port 18789 (detached) — 前台守护模式
176
- *
177
- * 不调用 onboard,因为配置文件已由 configure() 完整写入。
172
+ * 策略:
173
+ * 1. openclaw onboard --non-interactive --install-daemon
174
+ * 读取已写好的 openclaw.json,无交互完成初始化 + 注册系统服务 + 启动 gateway
175
+ * 2. 若 onboard 失败(如 Windows 不支持 daemon),直接 gateway start
176
+ * 3. 仍失败 Windows: start /B openclaw gateway;Unix: detached spawn
178
177
  */
179
- function _autoStartGateway() {
178
+ function _initAndStartGateway() {
180
179
  const chalk = require('chalk')
180
+ const isWin = process.platform === 'win32'
181
181
  const bin = 'openclaw'
182
182
 
183
- console.log(chalk.gray('\n ⚙️ 正在启动 OpenClaw Gateway...'))
183
+ console.log(chalk.gray('\n ⚙️ 正在初始化并启动 OpenClaw Gateway(约 15 秒)...'))
184
184
 
185
- // 先尝试 gateway start(若已注册为系统服务则直接生效)
186
- const r1 = spawnSync(bin, ['gateway', 'start'], {
185
+ // Step 1: 无交互 onboard + install-daemon
186
+ const r1 = spawnSync(bin, ['onboard', '--non-interactive', '--install-daemon'], {
187
187
  shell: true,
188
- timeout: 15000,
188
+ timeout: 60000,
189
189
  stdio: 'pipe',
190
+ env: { ...process.env },
190
191
  })
192
+
191
193
  if (r1.status === 0) {
192
- console.log(chalk.green(' ✓ OpenClaw Gateway 已在后台启动'))
194
+ console.log(chalk.green(' ✓ OpenClaw 初始化完成,Gateway 已在后台启动'))
195
+ console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
193
196
  return
194
197
  }
195
198
 
196
- // 没有 daemon 直接 detached 前台守护运行
197
- const { spawn } = require('child_process')
198
- const child = spawn(bin, ['gateway', '--port', '18789'], {
199
- shell: true,
200
- detached: true,
201
- stdio: 'ignore',
199
+ // Step 2: onboard 失败,直接 gateway start
200
+ const r2 = spawnSync(bin, ['gateway', 'start'], {
201
+ shell: true,
202
+ timeout: 15000,
203
+ stdio: 'pipe',
202
204
  })
203
- child.unref()
205
+ if (r2.status === 0) {
206
+ console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
207
+ console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
208
+ return
209
+ }
210
+
211
+ // Step 3: fallback — 后台守护进程
212
+ if (isWin) {
213
+ // Windows: 用 cmd start 开新窗口后台运行
214
+ spawnSync('cmd', ['/c', `start /B "" openclaw gateway --port 18789`], {
215
+ shell: true, stdio: 'ignore',
216
+ })
217
+ } else {
218
+ const { spawn } = require('child_process')
219
+ const child = spawn(bin, ['gateway', '--port', '18789'], {
220
+ detached: true,
221
+ stdio: 'ignore',
222
+ })
223
+ child.unref()
224
+ }
204
225
 
205
- // 等 2 秒让 gateway 起来
206
- spawnSync('node', ['-e', 'setTimeout(()=>{},2000)'], { timeout: 3000 })
226
+ // 等 3 秒让 gateway 起来
227
+ const t = Date.now(); while (Date.now() - t < 3000) {}
207
228
 
208
229
  console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
209
230
  console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))