@simonyea/holysheep-cli 1.2.4 → 1.2.6

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