bingocode 1.1.140 → 1.1.142

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.
@@ -8,7 +8,9 @@
8
8
  "Bash(git:*)",
9
9
  "WebFetch(domain:docs.anthropic.com)",
10
10
  "WebSearch",
11
- "WebFetch(domain:www.anthropic.com)"
11
+ "WebFetch(domain:www.anthropic.com)",
12
+ "Bash(grep -v \"node_modules\\\\|bun:\\\\|bun/\\\\|bun@\\\\|\\\\.bun\\\\|bunfig\\\\|bundl\\\\|bunny\\\\|abun\\\\|debug\\\\|comment\\\\|//.*bun\\\\|bunta\\\\|buno\")",
13
+ "Bash(grep:*)"
12
14
  ]
13
15
  }
14
16
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('node:child_process');
3
+ const { spawn, spawnSync } = require('node:child_process');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
6
  const fs = require('fs');
@@ -33,11 +33,39 @@ process.env.NoDefaultCurrentDirectoryInExePath = '1';
33
33
  }
34
34
  })();
35
35
 
36
- // 自动定位 bun 路径(优先用环境变量,再检查默认安装位置,最后 fallback 到 PATH
37
- const bunPath =
38
- process.env.BUN_PATH ||
39
- path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
40
- const bun = fs.existsSync(bunPath) ? bunPath : 'bun';
36
+ // 自动定位 bun 可执行路径(返回绝对路径或 null
37
+ function resolveBunExe() {
38
+ // 优先环境变量
39
+ if (process.env.BUN_PATH && fs.existsSync(process.env.BUN_PATH)) {
40
+ return process.env.BUN_PATH;
41
+ }
42
+ // npm install -g bun 的真实位置:{npm prefix -g}/node_modules/bun/bin/bun.exe
43
+ try {
44
+ const npmPrefix = spawnSync('npm', ['prefix', '-g'], { shell: true, encoding: 'utf-8' });
45
+ if (npmPrefix.status === 0) {
46
+ const npmBun = path.join(npmPrefix.stdout.trim(), 'node_modules', 'bun', 'bin', 'bun.exe');
47
+ if (fs.existsSync(npmBun)) return npmBun;
48
+ }
49
+ } catch (_) {}
50
+ // ~/.bun/bin/bun.exe(bun 官方安装脚本的位置)
51
+ const homeBun = path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
52
+ if (fs.existsSync(homeBun)) return homeBun;
53
+ // where bun.exe 兜底
54
+ try {
55
+ const where = spawnSync('where', ['bun.exe'], { shell: true, encoding: 'utf-8' });
56
+ if (where.status === 0) {
57
+ const found = where.stdout.trim().split(/\r?\n/)[0];
58
+ if (found && fs.existsSync(found)) return found;
59
+ }
60
+ } catch (_) {}
61
+ return null;
62
+ }
63
+
64
+ const bun = resolveBunExe();
65
+ if (!bun) {
66
+ console.error('[bingocode] 找不到 bun.exe,请先执行: npm install -g bun');
67
+ process.exit(1);
68
+ }
41
69
 
42
70
  // 主 CLI 入口
43
71
  const entry = path.join(__dirname, '..', 'src', 'entrypoints', 'cli.tsx');
package/bin/claude CHANGED
@@ -19,6 +19,20 @@ fi
19
19
 
20
20
  cd "$ROOT_DIR"
21
21
 
22
+ # ── bun 检测与自动安装 ──
23
+ if ! command -v bun &>/dev/null && [[ ! -x "$HOME/.bun/bin/bun" ]]; then
24
+ echo "[bingocode] bun 未检测到,正在通过 npm install -g bun 安装..."
25
+ if npm install -g bun --loglevel error; then
26
+ echo "[bingocode] bun 安装完成,正在启动..."
27
+ export PATH="$HOME/.bun/bin:$PATH"
28
+ else
29
+ echo "[bingocode] npm install -g bun 失败,请手动安装 bun: https://bun.sh" >&2
30
+ exit 1
31
+ fi
32
+ fi
33
+
34
+ BUN_BIN="$(command -v bun 2>/dev/null || echo "$HOME/.bun/bin/bun")"
35
+
22
36
  # When spawned by the desktop/web server as a child CLI process,
23
37
  # skip .env loading — the server has already set the correct env
24
38
  # via bingo/settings.json. Loading .env would re-inject stale
@@ -35,8 +49,8 @@ fi
35
49
 
36
50
  # Force recovery CLI (simple readline REPL, no Ink TUI)
37
51
  if [[ "${CLAUDE_CODE_FORCE_RECOVERY_CLI:-0}" == "1" ]]; then
38
- exec bun $ENV_FILE_FLAG ./src/localRecoveryCli.ts "$@"
52
+ exec "$BUN_BIN" $ENV_FILE_FLAG ./src/localRecoveryCli.ts "$@"
39
53
  fi
40
54
 
41
55
  # Default: full CLI with Ink TUI
42
- exec bun $ENV_FILE_FLAG ./src/entrypoints/cli.tsx "$@"
56
+ exec "$BUN_BIN" $ENV_FILE_FLAG ./src/entrypoints/cli.tsx "$@"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('node:child_process');
3
+ const { spawn, spawnSync } = require('node:child_process');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
6
  const fs = require('fs');
@@ -32,11 +32,38 @@ process.env.NoDefaultCurrentDirectoryInExePath = '1';
32
32
  }
33
33
  })();
34
34
 
35
- // 自动定位 bun 路径(优先用环境变量,再检查默认安装位置,最后 fallback 到 PATH
36
- const bunPath =
37
- process.env.BUN_PATH ||
38
- path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
39
- const bun = fs.existsSync(bunPath) ? bunPath : 'bun';
35
+ // 自动定位 bun 可执行路径(返回绝对路径或 null
36
+ function resolveBunExe() {
37
+ if (process.env.BUN_PATH && fs.existsSync(process.env.BUN_PATH)) {
38
+ return process.env.BUN_PATH;
39
+ }
40
+ // npm install -g bun 的真实位置:{npm prefix -g}/node_modules/bun/bin/bun.exe
41
+ try {
42
+ const npmPrefix = spawnSync('npm', ['prefix', '-g'], { shell: true, encoding: 'utf-8' });
43
+ if (npmPrefix.status === 0) {
44
+ const npmBun = path.join(npmPrefix.stdout.trim(), 'node_modules', 'bun', 'bin', 'bun.exe');
45
+ if (fs.existsSync(npmBun)) return npmBun;
46
+ }
47
+ } catch (_) {}
48
+ // ~/.bun/bin/bun.exe(bun 官方安装脚本的位置)
49
+ const homeBun = path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
50
+ if (fs.existsSync(homeBun)) return homeBun;
51
+ // where bun.exe 兜底
52
+ try {
53
+ const where = spawnSync('where', ['bun.exe'], { shell: true, encoding: 'utf-8' });
54
+ if (where.status === 0) {
55
+ const found = where.stdout.trim().split(/\r?\n/)[0];
56
+ if (found && fs.existsSync(found)) return found;
57
+ }
58
+ } catch (_) {}
59
+ return null;
60
+ }
61
+
62
+ const bun = resolveBunExe();
63
+ if (!bun) {
64
+ console.error('[claude] 找不到 bun.exe,请先执行: npm install -g bun');
65
+ process.exit(1);
66
+ }
40
67
 
41
68
  // 主 CLI 入口
42
69
  const entry = path.join(__dirname, '..', 'src', 'entrypoints', 'cli.tsx');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bingocode",
3
- "version": "1.1.140",
3
+ "version": "1.1.142",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "claude": "bin/claude-win.cjs",
@@ -664,7 +664,7 @@ export class ConversationService {
664
664
  }
665
665
 
666
666
  if (/\.(?:[cm]?[jt]s|tsx?)$/i.test(cliCommand)) {
667
- return ['bun', cliCommand, ...baseArgs]
667
+ return [process.execPath, cliCommand, ...baseArgs]
668
668
  }
669
669
 
670
670
  const cliBaseName = path.basename(cliCommand)
@@ -413,7 +413,7 @@ export class CronScheduler {
413
413
 
414
414
  const proc = Bun.spawn(
415
415
  [
416
- 'bun',
416
+ process.execPath,
417
417
  '--preload',
418
418
  preloadPath,
419
419
  cliPath,