openclawsetup 2.0.1 → 2.0.3

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 CHANGED
@@ -41,7 +41,7 @@ npx openclawsetup@latest
41
41
  自动完成以下选择:
42
42
  - ✓ 选择 QuickStart 模式
43
43
  - ✓ 跳过模型配置(后续用 `npx openclawapi` 配置)
44
- - ✓ 跳过渠道配置(后续用 `npx openclawdc/openclawfs` 配置)
44
+ - ✓ 跳过渠道配置(后续用 `npx openclawdc` 或 `npx openclaw-chat-cn@latest feishu` 配置)
45
45
  - ✓ 安装后台服务(开机自启)
46
46
  - ✓ 选择 Web Dashboard
47
47
 
@@ -110,7 +110,7 @@ npx openclawapi@latest
110
110
  npx openclawdc
111
111
 
112
112
  # 飞书
113
- npx openclawfs
113
+ npx openclaw-chat-cn@latest feishu
114
114
  ```
115
115
 
116
116
  ## 常用命令
package/bin/cli.mjs CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
 
14
14
  import { execSync, spawn } from 'child_process';
15
- import { existsSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'fs';
15
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, rmSync, accessSync, constants as fsConstants } from 'fs';
16
16
  import { homedir, platform } from 'os';
17
17
  import { join } from 'path';
18
18
  import { createInterface } from 'readline';
@@ -147,7 +147,7 @@ ${colors.cyan('选项:')}
147
147
  ${colors.cyan('智能安装会自动:')}
148
148
  ✓ 选择 QuickStart 模式
149
149
  ✓ 跳过模型配置(后续用 npx openclawapi 配置)
150
- ✓ 跳过渠道配置(后续用 npx openclawdc/openclawfs 配置)
150
+ ✓ 跳过渠道配置(后续用 npx openclawdc 或 npx openclaw-chat-cn@latest feishu 配置)
151
151
  ✓ 安装后台服务(开机自启)
152
152
  ✓ 选择 Web Dashboard
153
153
 
@@ -188,11 +188,44 @@ function detectExistingInstall() {
188
188
 
189
189
  // ============ 安装 OpenClaw ============
190
190
 
191
+ // 检测是否需要 sudo
192
+ function needsSudo() {
193
+ const os = platform();
194
+ if (os === 'win32' || os === 'darwin') return false;
195
+
196
+ // Linux: 检查 /usr/lib/node_modules 是否可写
197
+ try {
198
+ const testDir = '/usr/lib/node_modules';
199
+ if (existsSync(testDir)) {
200
+ accessSync(testDir, fsConstants.W_OK);
201
+ return false;
202
+ }
203
+ } catch {
204
+ return true;
205
+ }
206
+ return true;
207
+ }
208
+
209
+ // 获取 npm 安装命令
210
+ function getNpmInstallCmd(pkg) {
211
+ const useSudo = needsSudo();
212
+ if (useSudo) {
213
+ return { cmd: 'sudo', args: ['npm', 'install', '-g', pkg] };
214
+ }
215
+ return { cmd: 'npm', args: ['install', '-g', pkg] };
216
+ }
217
+
191
218
  async function installOpenClaw() {
192
219
  log.info('\n[1/2] 安装 OpenClaw CLI...\n');
193
220
 
221
+ const useSudo = needsSudo();
222
+ if (useSudo) {
223
+ log.hint('检测到需要 sudo 权限,可能需要输入密码\n');
224
+ }
225
+
194
226
  return new Promise((resolve, reject) => {
195
- const child = spawn('npm', ['install', '-g', 'openclaw@latest'], {
227
+ const { cmd, args } = getNpmInstallCmd('openclaw@latest');
228
+ const child = spawn(cmd, args, {
196
229
  stdio: 'inherit',
197
230
  shell: true,
198
231
  });
@@ -204,7 +237,8 @@ async function installOpenClaw() {
204
237
  } else {
205
238
  // 尝试 clawdbot
206
239
  log.warn('openclaw 安装失败,尝试 clawdbot...');
207
- const fallback = spawn('npm', ['install', '-g', 'clawdbot@latest'], {
240
+ const { cmd: cmd2, args: args2 } = getNpmInstallCmd('clawdbot@latest');
241
+ const fallback = spawn(cmd2, args2, {
208
242
  stdio: 'inherit',
209
243
  shell: true,
210
244
  });
@@ -237,24 +271,37 @@ async function runOnboardWithAutoResponse(cliName, options) {
237
271
  const os = platform();
238
272
  let child;
239
273
 
274
+ // 设置终端尺寸环境变量
275
+ const termEnv = {
276
+ ...process.env,
277
+ FORCE_COLOR: '1',
278
+ TERM: 'xterm-256color',
279
+ COLUMNS: process.stdout.columns?.toString() || '120',
280
+ LINES: process.stdout.rows?.toString() || '40',
281
+ };
282
+
240
283
  if (os === 'win32') {
241
284
  // Windows: 直接 spawn,可能没有完整的交互体验
242
285
  child = spawn(cliName, ['onboard', '--install-daemon'], {
243
286
  stdio: options.manual ? 'inherit' : ['pipe', 'pipe', 'pipe'],
244
287
  shell: true,
245
- env: { ...process.env, FORCE_COLOR: '1', TERM: 'xterm-256color' },
288
+ env: termEnv,
246
289
  });
247
290
  } else if (os === 'darwin') {
248
291
  // macOS: script -q /dev/null command args...
249
292
  child = spawn('script', ['-q', '/dev/null', cliName, 'onboard', '--install-daemon'], {
250
293
  stdio: options.manual ? 'inherit' : ['pipe', 'pipe', 'pipe'],
251
- env: { ...process.env, FORCE_COLOR: '1', TERM: 'xterm-256color' },
294
+ env: termEnv,
252
295
  });
253
296
  } else {
254
297
  // Linux: script -q -c "command args..." /dev/null
255
- child = spawn('script', ['-q', '-c', `${cliName} onboard --install-daemon`, '/dev/null'], {
298
+ // 使用 stty 设置终端尺寸
299
+ const cols = process.stdout.columns || 120;
300
+ const rows = process.stdout.rows || 40;
301
+ const cmd = `stty cols ${cols} rows ${rows} 2>/dev/null; ${cliName} onboard --install-daemon`;
302
+ child = spawn('script', ['-q', '-c', cmd, '/dev/null'], {
256
303
  stdio: options.manual ? 'inherit' : ['pipe', 'pipe', 'pipe'],
257
- env: { ...process.env, FORCE_COLOR: '1', TERM: 'xterm-256color' },
304
+ env: termEnv,
258
305
  });
259
306
  }
260
307
 
@@ -395,7 +442,7 @@ function showCompletionInfo(cliName) {
395
442
 
396
443
  console.log(colors.cyan('\n配置聊天渠道:'));
397
444
  console.log(` Discord: ${colors.yellow('npx openclawdc')}`);
398
- console.log(` 飞书: ${colors.yellow('npx openclawfs')}`);
445
+ console.log(` 飞书: ${colors.yellow('npx openclaw-chat-cn@latest feishu')}`);
399
446
 
400
447
  console.log('');
401
448
  }
package/install.sh CHANGED
@@ -371,7 +371,7 @@ show_installed_info() {
371
371
 
372
372
  echo -e "${CYAN}\n配置聊天渠道:${NC}"
373
373
  echo " Discord: npx openclawdc"
374
- echo " 飞书: npx openclawfs"
374
+ echo " 飞书: npx openclaw-chat-cn@latest feishu"
375
375
  }
376
376
 
377
377
  # 显示菜单并获取选择
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawsetup",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "OpenClaw 智能安装向导 - 调用官方交互界面,自动选择推荐配置",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,7 +51,7 @@ irm https://unpkg.com/openclawsetup@latest/install.ps1 | iex
51
51
 
52
52
  **为什么跳过模型和渠道?**
53
53
  - 模型配置:后续用 `npx openclawapi` 单独配置,更灵活
54
- - 渠道配置:后续用 `npx openclawdc`(Discord)或 `npx openclawfs`(飞书)配置
54
+ - 渠道配置:后续用 `npx openclawdc`(Discord)或 `npx openclaw-chat-cn@latest feishu`(飞书)配置
55
55
 
56
56
  ## 已安装用户:更新或重装
57
57
 
@@ -78,8 +78,8 @@ npx openclawsetup@latest --reinstall
78
78
 
79
79
  3. **配置聊天渠道(可选)**
80
80
  ```bash
81
- npx openclawdc # Discord
82
- npx openclawfs # 飞书
81
+ npx openclawdc # Discord
82
+ npx openclaw-chat-cn@latest feishu # 飞书
83
83
  ```
84
84
 
85
85
  ## 常见问题