claude-code-inspector 0.1.4 → 0.1.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.
Files changed (3) hide show
  1. package/.yarnrc +1 -0
  2. package/bin/cli.js +70 -1
  3. package/package.json +5 -2
package/.yarnrc ADDED
@@ -0,0 +1 @@
1
+ engine-strict false
package/bin/cli.js CHANGED
@@ -1,13 +1,82 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const { execSync } = require('child_process');
3
4
  const path = require('path');
5
+ const fs = require('fs');
4
6
  const { createServer } = require('http');
5
7
  const next = require('next');
6
8
  const { WebSocketServer } = require('ws');
7
9
  const { parse } = require('url');
8
10
 
9
11
  // 切换到包的安装目录,确保 Next.js 能正确找到文件
10
- process.chdir(path.resolve(__dirname, '..'));
12
+ const installDir = path.resolve(__dirname, '..');
13
+ process.chdir(installDir);
14
+
15
+ // 检查并安装 @types/node 和 @types/react,防止 Next.js 自动安装
16
+ // 使用 npm 而不是 yarn 来避免 eslint-visitor-keys 兼容性问题
17
+ function installTypesIfNeeded() {
18
+ try {
19
+ const typesNodePath = path.join(installDir, 'node_modules', '@types', 'node');
20
+ const typesReactPath = path.join(installDir, 'node_modules', '@types', 'react');
21
+
22
+ if (!fs.existsSync(typesNodePath) || !fs.existsSync(typesReactPath)) {
23
+ console.log('[CLI] Installing @types/node and @types/react...');
24
+ execSync('npm install --no-save @types/node @types/react', {
25
+ stdio: 'inherit',
26
+ env: { ...process.env, npm_config_legacy_peer_deps: 'true' }
27
+ });
28
+ }
29
+ } catch (error) {
30
+ console.error('[CLI] Failed to install types:', error.message);
31
+ }
32
+ }
33
+
34
+ installTypesIfNeeded();
35
+
36
+ // 临时重命名 tsconfig.json,防止 Next.js 尝试自动安装依赖
37
+ // Next.js 会检测 tsconfig.json 并尝试安装 @types/node 和 @types/react
38
+ // 但由于 eslint-visitor-keys 兼容性问题 (Node 23),yarn 安装会失败
39
+ // 解决方案:移动原始 tsconfig.json,创建一个简化版仅包含路径别名
40
+ const tsconfigPath = path.join(installDir, 'tsconfig.json');
41
+ const tsconfigBackupPath = path.join(installDir, 'tsconfig.json.bak');
42
+ let tsconfigMoved = false;
43
+
44
+ if (fs.existsSync(tsconfigPath)) {
45
+ fs.renameSync(tsconfigPath, tsconfigBackupPath);
46
+ tsconfigMoved = true;
47
+ // 创建一个简化的 tsconfig.json,只包含路径别名配置
48
+ const minimalTsconfig = {
49
+ compilerOptions: {
50
+ baseUrl: '.',
51
+ paths: {
52
+ '@/*': ['./*']
53
+ }
54
+ }
55
+ };
56
+ fs.writeFileSync(tsconfigPath, JSON.stringify(minimalTsconfig, null, 2));
57
+
58
+ // 进程退出时恢复原始文件
59
+ process.on('exit', () => {
60
+ if (tsconfigMoved && fs.existsSync(tsconfigBackupPath)) {
61
+ fs.renameSync(tsconfigBackupPath, tsconfigPath);
62
+ }
63
+ });
64
+
65
+ // 捕获信号,确保恢复文件
66
+ process.on('SIGINT', () => {
67
+ if (tsconfigMoved && fs.existsSync(tsconfigBackupPath)) {
68
+ fs.renameSync(tsconfigBackupPath, tsconfigPath);
69
+ }
70
+ process.exit();
71
+ });
72
+
73
+ process.on('SIGTERM', () => {
74
+ if (tsconfigMoved && fs.existsSync(tsconfigBackupPath)) {
75
+ fs.renameSync(tsconfigBackupPath, tsconfigPath);
76
+ }
77
+ process.exit();
78
+ });
79
+ }
11
80
 
12
81
  const port = parseInt(process.env.PORT || '3000', 10);
13
82
  const dev = process.env.NODE_ENV !== 'production';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-inspector",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "cc-inspector": "./bin/cli.js"
@@ -17,7 +17,8 @@
17
17
  "next.config.js",
18
18
  "tsconfig.json",
19
19
  "postcss.config.mjs",
20
- "server.ts"
20
+ "server.ts",
21
+ ".yarnrc"
21
22
  ],
22
23
  "scripts": {
23
24
  "dev": "tsx server.ts",
@@ -30,6 +31,8 @@
30
31
  },
31
32
  "dependencies": {
32
33
  "@tailwindcss/postcss": "^4",
34
+ "@types/node": "^20",
35
+ "@types/react": "^19",
33
36
  "axios": "^1.13.6",
34
37
  "better-sqlite3": "^12.8.0",
35
38
  "next": "16.1.6",