bingocode 1.0.37 → 1.0.38

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/LICENSE CHANGED
@@ -1,29 +1,29 @@
1
- MIT License
2
-
3
- Copyright (c) 2025-2026 Leanchy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
- ---
24
-
25
- BingoCode is an independent open-source project by Leanchy, built upon and
26
- substantially modified from Claude Code (originally developed by Anthropic, PBC).
27
- Original upstream components remain the property of their respective copyright holders.
28
- All modifications, extensions, and original contributions in this repository are
29
- copyright Leanchy, released under the MIT License above.
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Leanchy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ BingoCode is an independent open-source project by Leanchy, built upon and
26
+ substantially modified from Claude Code (originally developed by Anthropic, PBC).
27
+ Original upstream components remain the property of their respective copyright holders.
28
+ All modifications, extensions, and original contributions in this repository are
29
+ copyright Leanchy, released under the MIT License above.
package/bin/bingo-win.cjs CHANGED
@@ -8,17 +8,38 @@ const fs = require('fs');
8
8
  process.env.NoDefaultCurrentDirectoryInExePath = '1';
9
9
 
10
10
  // ── 首次部署:将默认 bingo 配置复制到 ~/.claude/bingo/ ──
11
- // 确保新电脑首次启动时 settings.json 存在(含占位符 ANTHROPIC_AUTH_TOKEN),
12
- // 这样 isOfficialMode() 返回 false,子进程不会走 OAuth 流程。
13
- // 用户通过 ProviderPanel 激活 provider syncToSettings() 会覆盖此文件。
11
+ /**
12
+ * 更加健壮的根目录定位:
13
+ * 1. 如果 preload.ts ../ (当前 bin/ 目录下运行)
14
+ * 2. 否则查找同级及上级目录中的 package.json
15
+ */
16
+ function getProjectRoot() {
17
+ let curr = __dirname;
18
+ try {
19
+ while (curr !== path.dirname(curr)) {
20
+ if (fs.existsSync(path.join(curr, 'preload.ts')) || fs.existsSync(path.join(curr, 'package.json'))) {
21
+ return curr;
22
+ }
23
+ const parent = path.dirname(curr);
24
+ if (fs.existsSync(path.join(parent, 'preload.ts'))) return parent;
25
+ curr = parent;
26
+ }
27
+ } catch (err) {
28
+ // 防止权限拒绝等导致挂死
29
+ }
30
+ return path.join(__dirname, '..');
31
+ }
32
+
33
+ const ROOT_DIR = getProjectRoot();
34
+
14
35
  (function deployBingoDefaults() {
15
36
  const configDir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
16
37
  const bingoDir = path.join(configDir, 'bingo');
17
38
  const targetSettings = path.join(bingoDir, 'settings.json');
18
39
 
19
- // 只在 settings.json 不存在时才部署(不覆盖已有配置)
40
+ // 只在 settings.json 不存在时才部署
20
41
  if (!fs.existsSync(targetSettings)) {
21
- const defaultsDir = path.join(__dirname, '..', 'config', 'bingo-defaults');
42
+ const defaultsDir = path.join(ROOT_DIR, 'config', 'bingo-defaults');
22
43
  const srcSettings = path.join(defaultsDir, 'settings.json');
23
44
 
24
45
  if (fs.existsSync(srcSettings)) {
@@ -40,42 +61,53 @@ const bunPath =
40
61
  process.env.BUN_PATH ||
41
62
  path.join(os.homedir(), '.bun', 'bin', 'bun.exe');
42
63
 
43
- // 检查 bun 是否可用(先看固定路径,再看 PATH)
64
+ // 检查 bun 是否可用
44
65
  function bunExists() {
45
66
  if (fs.existsSync(bunPath)) return true;
46
- // 尝试 PATH 中的 bun
47
- const result = spawnSync('bun', ['--version'], { stdio: 'ignore', shell: true });
48
- return result.status === 0;
67
+ try {
68
+ const result = spawnSync('bun', ['--version'], { stdio: 'ignore', shell: true });
69
+ return result.status === 0;
70
+ } catch (e) {
71
+ return false;
72
+ }
49
73
  }
50
74
 
51
- // 安装 bun(Windows PowerShell 方式)
75
+ // 安装 bun
52
76
  function installBun() {
53
77
  console.log('[bingocode] bun 未检测到,正在自动安装...');
54
- const result = spawnSync(
55
- 'powershell',
56
- ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
57
- 'irm bun.sh/install.ps1 | iex'],
58
- { stdio: 'inherit', shell: false }
59
- );
60
- if (result.status !== 0) {
61
- console.error('[bingocode] bun 安装失败,请手动安装:https://bun.sh');
62
- process.exit(1);
78
+ try {
79
+ const result = spawnSync(
80
+ 'powershell',
81
+ ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
82
+ 'irm bun.sh/install.ps1 | iex'],
83
+ { stdio: 'inherit', shell: false }
84
+ );
85
+ if (result.status !== 0) {
86
+ throw new Error(`Exit code ${result.status}`);
87
+ }
88
+ console.log('[bingocode] bun 安装完成,正在启动...');
89
+ } catch (err) {
90
+ console.error(`[bingocode] bun 自动安装失败: ${err.message}`);
91
+ console.log('[bingocode] 请手动从 https://bun.sh 安装 Bun 后重试。');
92
+ return false;
63
93
  }
64
- console.log('[bingocode] bun 安装完成,正在启动...');
94
+ return true;
65
95
  }
66
96
 
67
97
  if (!bunExists()) {
68
- installBun();
98
+ if (!installBun()) {
99
+ process.exit(1);
100
+ }
69
101
  }
70
102
 
71
103
  // 安装后 bun.exe 在固定位置;若在 PATH 里则直接用 "bun"
72
104
  const bun = fs.existsSync(bunPath) ? bunPath : 'bun';
73
105
 
74
- // Bingo Manager 入口(窗口管理控制台,不走 cli.tsx 完整启动流程)
75
- const entry = path.join(__dirname, '..', 'src', 'entrypoints', 'manager.tsx');
106
+ // Bingo Manager 入口
107
+ const entry = path.join(ROOT_DIR, 'src', 'entrypoints', 'manager.tsx');
76
108
 
77
- // preload shim(定义 MACRO 全局变量)——必须用绝对路径,bunfig.toml 在 npm 全局安装后不生效
78
- const preload = path.join(__dirname, '..', 'preload.ts');
109
+ // preload shim
110
+ const preload = path.join(ROOT_DIR, 'preload.ts');
79
111
  if (!fs.existsSync(preload)) {
80
112
  console.error('[bingocode] 找不到 preload.ts,MACRO 将无法注入:' + preload);
81
113
  process.exit(1);
@@ -83,7 +115,7 @@ if (!fs.existsSync(preload)) {
83
115
 
84
116
  // 检查 .env
85
117
  let envFlag = '';
86
- const envPath = path.join(__dirname, '..', '.env');
118
+ const envPath = path.join(ROOT_DIR, '.env');
87
119
  if (fs.existsSync(envPath)) {
88
120
  envFlag = `--env-file=${envPath}`;
89
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bingocode",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "claude": "bin/claude-win.cjs",
@@ -1,10 +1,10 @@
1
- /**
2
- * Bingo Manager 入口
3
- * 直接渲染 CliMenuManager(窗口管理控制台),不走 cli.tsx 的完整启动流程。
4
- * 由 bin/bingo-win.cjs 和 bin/bingo 调用。
5
- */
6
- import React from 'react';
7
- import { render } from 'ink';
8
- import { CliMenuManager } from '../manager/CliMenuManager.tsx';
9
-
10
- render(<CliMenuManager />);
1
+ /**
2
+ * Bingo Manager 入口
3
+ * 直接渲染 CliMenuManager(窗口管理控制台),不走 cli.tsx 的完整启动流程。
4
+ * 由 bin/bingo-win.cjs 和 bin/bingo 调用。
5
+ */
6
+ import React from 'react';
7
+ import { render } from 'ink';
8
+ import { CliMenuManager } from '../manager/CliMenuManager.tsx';
9
+
10
+ render(<CliMenuManager />);
@@ -82,11 +82,11 @@ const ProvidersMenu: React.FC = () => {
82
82
  refresh();
83
83
  });
84
84
  }
85
- } else if (inputKey.toLowerCase() === 'q') {
85
+ } else if (inputKey.toLowerCase() === 'q' || key.escape) {
86
86
  setRemoveConfirm(false); setMode('list');
87
87
  }
88
88
  }
89
- });
89
+ }, { isActive: mode === 'list' || mode === 'removeConfirm' });
90
90
 
91
91
  // ADD模式交互
92
92
  useInput((inputKey, key) => {
@@ -102,7 +102,7 @@ const ProvidersMenu: React.FC = () => {
102
102
  else if (key.upArrow) setModelSelectIdx(idx => Math.max(0, idx - 1));
103
103
  else if (key.return) { setAddStep(1); }
104
104
  }
105
- });
105
+ }, { isActive: mode === 'add' });
106
106
 
107
107
  // 新增表单
108
108
  const addSubmit = async (keyInput: string) => {