bingocode 1.1.58 → 1.1.60
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
|
@@ -17,8 +17,6 @@ import { TopToolbar } from '../manager/TopToolbar.tsx';
|
|
|
17
17
|
|
|
18
18
|
// 主题切换(Hook)
|
|
19
19
|
import { useTheme } from '../components/design-system/ThemeProvider.js';
|
|
20
|
-
import { createRequire } from 'module';
|
|
21
|
-
const require = createRequire(import.meta.url);
|
|
22
20
|
// Markdown 渲染(纯函数,不依赖 AppStateProvider context)
|
|
23
21
|
import { applyMarkdown } from '../utils/markdown.js';
|
|
24
22
|
import { Ansi } from '../ink/Ansi.js';
|
|
@@ -288,46 +286,7 @@ export const CliMenuManager: React.FC = () => {
|
|
|
288
286
|
(async () => {
|
|
289
287
|
if (apiUrl) return;
|
|
290
288
|
|
|
291
|
-
|
|
292
|
-
let entry = "";
|
|
293
|
-
try {
|
|
294
|
-
// 利用 Node.js 的模块解析机制寻找 bingocode 包的根目录
|
|
295
|
-
// 这种方法在 npm install -g 这种复杂路径下最可靠
|
|
296
|
-
const bingoPkgPath = require.resolve('bingocode/package.json');
|
|
297
|
-
const root = path.dirname(bingoPkgPath);
|
|
298
|
-
|
|
299
|
-
const possiblePaths = [
|
|
300
|
-
path.join(root, 'src/server/index.ts'),
|
|
301
|
-
path.join(root, 'src/server/index.js'),
|
|
302
|
-
path.join(root, 'dist/server.js')
|
|
303
|
-
];
|
|
304
|
-
|
|
305
|
-
for (const p of possiblePaths) {
|
|
306
|
-
if (fs.existsSync(p)) {
|
|
307
|
-
entry = p;
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
} catch (e) {
|
|
312
|
-
// Fallback: 如果 require.resolve 失败(比如还没发布为包),使用现有的路径逻辑
|
|
313
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
314
|
-
const __dirname = path.dirname(__filename);
|
|
315
|
-
const pkgRoot = path.resolve(__dirname, '../../');
|
|
316
|
-
|
|
317
|
-
const fbPaths = [
|
|
318
|
-
path.join(__dirname, '../server/index.ts'),
|
|
319
|
-
path.join(pkgRoot, 'src/server/index.ts'),
|
|
320
|
-
];
|
|
321
|
-
for (const p of fbPaths) {
|
|
322
|
-
if (fs.existsSync(p)) { entry = p; break; }
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (!entry || !fs.existsSync(entry)) {
|
|
327
|
-
setBootErr(`无法定位服务器入口文件。\n最后尝试路径: ${entry || '未探测到'}`);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
|
|
289
|
+
const entry = path.resolve(import.meta.dir, '../server/index.ts');
|
|
331
290
|
const MAX_RETRIES = 3;
|
|
332
291
|
const RETRY_DELAYS = [0, 2000, 5000]; // 首次无延迟,第2次2秒,第3次5秒
|
|
333
292
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import axios from 'axios';
|
|
8
8
|
|
|
9
|
+
const LOG_FILE = path.join(os.homedir(), '.claude-cli', 'runtime', 'boot.log');
|
|
10
|
+
function log(msg: string) {
|
|
11
|
+
try {
|
|
12
|
+
const line = `[${new Date().toISOString()}] ${msg}\n`;
|
|
13
|
+
fs.mkdirSync(path.dirname(LOG_FILE), { recursive: true });
|
|
14
|
+
fs.appendFileSync(LOG_FILE, line);
|
|
15
|
+
} catch {}
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
type Handle = {
|
|
10
19
|
baseUrl: string;
|
|
11
20
|
stopIfLast: () => Promise<void>;
|