@surething/cockpit 1.0.176 → 1.0.178

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 (34) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +12 -12
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/server/app/_global-error.html +2 -2
  6. package/.next-prod/server/app/_global-error.rsc +1 -1
  7. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next-prod/server/app/_not-found.html +2 -2
  14. package/.next-prod/server/app/_not-found.rsc +1 -1
  15. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +1 -1
  16. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  17. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +1 -1
  18. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  19. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  20. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next-prod/server/app-paths-manifest.json +12 -12
  22. package/.next-prod/server/pages/404.html +2 -2
  23. package/.next-prod/server/pages/500.html +2 -2
  24. package/.next-prod/server/server-reference-manifest.json +1 -1
  25. package/.next-prod/trace +12 -12
  26. package/.next-prod/trace-build +1 -1
  27. package/README.md +9 -1
  28. package/README.zh.md +9 -1
  29. package/bin/cock.mjs +71 -15
  30. package/bin/postinstall.mjs +15 -5
  31. package/package.json +1 -1
  32. package/server.mjs +3 -1
  33. /package/.next-prod/static/{gNSsQIN6Pvg_vxYJVkZfN → 7AsMj_iNkeEBoqPIBmtH6}/_buildManifest.js +0 -0
  34. /package/.next-prod/static/{gNSsQIN6Pvg_vxYJVkZfN → 7AsMj_iNkeEBoqPIBmtH6}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- [{"name":"run-webpack","duration":11888831,"timestamp":141422768,"id":17,"parentId":1,"tags":{},"startTime":1774468973736,"traceId":"8f590c95dd85e35b"},{"name":"run-typescript","duration":13533963,"timestamp":153315551,"id":1412,"parentId":1,"tags":{},"startTime":1774468985629,"traceId":"8f590c95dd85e35b"},{"name":"static-check","duration":739714,"timestamp":166868944,"id":1415,"parentId":1,"tags":{},"startTime":1774468999182,"traceId":"8f590c95dd85e35b"},{"name":"static-generation","duration":5462974,"timestamp":167794865,"id":1615,"parentId":1,"tags":{},"startTime":1774469000108,"traceId":"8f590c95dd85e35b"},{"name":"collect-build-traces","duration":17739484,"timestamp":167609467,"id":1612,"parentId":1,"tags":{},"startTime":1774468999923,"traceId":"8f590c95dd85e35b"},{"name":"telemetry-flush","duration":58,"timestamp":185352122,"id":1624,"parentId":1,"tags":{},"startTime":1774469017665,"traceId":"8f590c95dd85e35b"},{"name":"next-build","duration":44291120,"timestamp":141061073,"id":1,"tags":{"buildMode":"default","version":"16.1.6","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1774468973374,"traceId":"8f590c95dd85e35b"}]
1
+ [{"name":"run-webpack","duration":11649582,"timestamp":135689337,"id":17,"parentId":1,"tags":{},"startTime":1774508096181,"traceId":"f2d23f9ead8f3bf6"},{"name":"run-typescript","duration":13425343,"timestamp":147342493,"id":1412,"parentId":1,"tags":{},"startTime":1774508107834,"traceId":"f2d23f9ead8f3bf6"},{"name":"static-check","duration":730191,"timestamp":160788440,"id":1415,"parentId":1,"tags":{},"startTime":1774508121280,"traceId":"f2d23f9ead8f3bf6"},{"name":"static-generation","duration":5296546,"timestamp":161692933,"id":1615,"parentId":1,"tags":{},"startTime":1774508122185,"traceId":"f2d23f9ead8f3bf6"},{"name":"collect-build-traces","duration":17187755,"timestamp":161519340,"id":1612,"parentId":1,"tags":{},"startTime":1774508122011,"traceId":"f2d23f9ead8f3bf6"},{"name":"telemetry-flush","duration":52,"timestamp":178710150,"id":1624,"parentId":1,"tags":{},"startTime":1774508139202,"traceId":"f2d23f9ead8f3bf6"},{"name":"next-build","duration":43376548,"timestamp":135333665,"id":1,"tags":{"buildMode":"default","version":"16.1.6","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1774508095826,"traceId":"f2d23f9ead8f3bf6"}]
package/README.md CHANGED
@@ -53,13 +53,21 @@ A unified development cockpit built on **Claude Code (Agent SDK)** — chat, cod
53
53
  - Chrome extension (Manifest V3) for browser automation bridge
54
54
  - CLI tools: `cock browser` / `cock terminal` for headless automation
55
55
 
56
+ ## Prerequisites
57
+
58
+ - **Node.js ≥ 20** — [nodejs.org](https://nodejs.org/)
59
+ - **Claude Code** — [docs.anthropic.com](https://docs.anthropic.com/en/docs/claude-code) (Cockpit uses Claude Code Agent SDK under the hood)
60
+ - **Git** — for git features (blame, diff, branch switching, etc.)
61
+ - **Chrome** — (optional) for Browser Bubble automation, install the bundled extension from `~/.cockpit/chrome-extension`
62
+
56
63
  ## Install
57
64
 
58
65
  ```bash
59
66
  npm install -g @surething/cockpit
60
67
  cock # Start server → http://localhost:3457
68
+ cock . # Open current directory as project
69
+ cock ~/my-project # Open specified directory
61
70
  cock -h # Show help
62
- cock -v # Show version
63
71
  ```
64
72
 
65
73
  ### From Source
package/README.zh.md CHANGED
@@ -59,13 +59,21 @@
59
59
  - Chrome 插件 (Manifest V3) 浏览器自动化桥接
60
60
  - CLI 工具:`cock browser` / `cock terminal` 无头自动化
61
61
 
62
+ ## 前置依赖
63
+
64
+ - **Node.js ≥ 20** — [nodejs.org](https://nodejs.org/)
65
+ - **Claude Code** — [docs.anthropic.com](https://docs.anthropic.com/en/docs/claude-code)(Cockpit 底层使用 Claude Code Agent SDK)
66
+ - **Git** — 用于 Git 相关功能(blame、diff、分支切换等)
67
+ - **Chrome** —(可选)浏览器气泡自动化,需安装 `~/.cockpit/chrome-extension` 中的扩展
68
+
62
69
  ## 安装
63
70
 
64
71
  ```bash
65
72
  npm install -g @surething/cockpit
66
73
  cock # 启动服务 → http://localhost:3457
74
+ cock . # 打开当前目录为项目
75
+ cock ~/my-project # 打开指定目录
67
76
  cock -h # 查看帮助
68
- cock -v # 查看版本
69
77
  ```
70
78
 
71
79
  ### 从源码安装
package/bin/cock.mjs CHANGED
@@ -13,19 +13,21 @@ if (process.argv[2] === '--help' || process.argv[2] === '-h' || process.argv[2]
13
13
  const pkg = JSON.parse(readFileSync(resolve(PROJECT_ROOT, 'package.json'), 'utf8'));
14
14
  console.log(`Cockpit v${pkg.version} - One seat. One AI. Everything under control.
15
15
 
16
- Usage: cock [command]
16
+ Usage: cock [path] [options]
17
17
 
18
18
  Commands:
19
- (default) Start Cockpit server (port 3457)
20
- browser <id> <action> Control browser bubbles
21
- terminal <id> <action> Control terminal bubbles
22
- update Update to latest version
19
+ cock Start server, open last project
20
+ cock . Start server, open current directory
21
+ cock <path> Start server, open specified directory
22
+ browser <id> <action> Control browser bubbles
23
+ terminal <id> <action> Control terminal bubbles
24
+ update Update to latest version
23
25
 
24
26
  Options:
25
- --port <port> Set server port (default: 3457)
26
- --no-open Don't open browser after start
27
- -v, --version Show version
28
- -h, --help Show this help`);
27
+ --port <port> Set server port (default: 3457)
28
+ --no-open Don't open browser after start
29
+ -v, --version Show version
30
+ -h, --help Show this help`);
29
31
  process.exit(0);
30
32
  }
31
33
 
@@ -58,8 +60,7 @@ if (!process.env.COCKPIT_PORT) {
58
60
 
59
61
  // Subcommand routing
60
62
  if (process.argv[2] === 'browser') {
61
- // cock browser <id> <action> [args...] → delegate to cock-browser.mjs
62
- process.argv.splice(2, 1); // Remove 'browser' so cock-browser.mjs parses from argv[2]
63
+ process.argv.splice(2, 1);
63
64
  const mod = await import('./cock-browser.mjs');
64
65
  await mod.done;
65
66
  process.exit(0);
@@ -83,17 +84,72 @@ if (process.argv[2] === 'update') {
83
84
  process.exit(result.status ?? 1);
84
85
  }
85
86
 
86
- // Start (foreground, Ctrl+C to stop)
87
+ // ============================================
88
+ // Resolve project directory (if provided)
89
+ // ============================================
90
+ const { existsSync, mkdirSync } = await import('fs');
91
+ const { homedir } = await import('os');
92
+
93
+ const knownCommands = new Set(['browser', 'terminal', 'update', 'help']);
94
+ const arg = process.argv[2];
95
+ let projectDir = null;
96
+
97
+ // 第一个参数不是 flag 且不是已知子命令 → 视为目录路径
98
+ if (arg && !arg.startsWith('-') && !knownCommands.has(arg)) {
99
+ // 展开 ~ 为 home 目录
100
+ const raw = arg.startsWith('~') ? arg.replace(/^~/, homedir()) : arg;
101
+ projectDir = resolve(raw);
102
+ // 目录不存在则创建
103
+ if (!existsSync(projectDir)) {
104
+ mkdirSync(projectDir, { recursive: true });
105
+ console.log(`Created ${projectDir}`);
106
+ }
107
+ }
108
+
109
+ // ============================================
110
+ // Check if server is already running
111
+ // ============================================
112
+ const port = process.env.PORT || process.env.COCKPIT_PORT || '3457';
113
+
114
+ async function isServerRunning() {
115
+ try {
116
+ const res = await fetch(`http://localhost:${port}/api/version`, { signal: AbortSignal.timeout(1000) });
117
+ return res.ok;
118
+ } catch {
119
+ return false;
120
+ }
121
+ }
122
+
123
+ const { exec } = await import('child_process');
124
+ const running = await isServerRunning();
125
+
126
+ if (running) {
127
+ // 服务已运行 → 打开浏览器,立即退出
128
+ const base = `http://localhost:${port}`;
129
+ const url = projectDir ? `${base}/?cwd=${encodeURIComponent(projectDir)}` : base;
130
+ if (!process.env.COCKPIT_NO_OPEN) {
131
+ const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
132
+ exec(`${cmd} ${url}`);
133
+ }
134
+ console.log(`Cockpit is already running → ${url}`);
135
+ process.exit(0);
136
+ }
137
+
138
+ // ============================================
139
+ // Start server (foreground, Ctrl+C to stop)
140
+ // ============================================
87
141
  const isDev = process.env.COCKPIT_ENV === 'dev';
88
- const { existsSync } = await import('fs');
89
- // prod mode requires a pre-built artifact; dev mode is compiled on-the-fly by Next.js
90
142
  if (!isDev && !existsSync(resolve(PROJECT_ROOT, '.next-prod', 'BUILD_ID'))) {
91
143
  console.error('No production build found.\n');
92
144
  console.error('Run: npm run build');
93
145
  process.exit(1);
94
146
  }
95
147
 
148
+ // 传递项目目录给 server.mjs,让它打开正确的 URL
149
+ if (projectDir) {
150
+ process.env.COCKPIT_OPEN_PROJECT = projectDir;
151
+ }
152
+
96
153
  console.log('Starting Cockpit...');
97
- // dev: tsx for on-the-fly TS compilation; prod: pre-compiled dist/
98
154
  const args = isDev ? ['--import', 'tsx', 'server.mjs'] : ['server.mjs'];
99
155
  spawnSync('node', args, { cwd: PROJECT_ROOT, stdio: 'inherit' });
@@ -28,13 +28,23 @@ const isNpmInstall = !existsSync(join(projectRoot, 'src'));
28
28
  if (isNpmInstall) {
29
29
  try {
30
30
  const src = join(projectRoot, 'chrome-extension');
31
- const dest = join(homedir(), '.cockpit', 'chrome-extension');
31
+ const cockpitDir = join(homedir(), '.cockpit');
32
+ const dest = join(cockpitDir, 'chrome-extension');
32
33
  accessSync(src);
33
- mkdirSync(join(homedir(), '.cockpit'), { recursive: true });
34
+ mkdirSync(cockpitDir, { recursive: true });
34
35
  cpSync(src, dest, { recursive: true, force: true });
35
- // macOS: 清除 com.apple.provenance 等扩展属性
36
- if (process.platform === 'darwin') {
37
- try { execSync(`xattr -cr "${dest}"`); } catch {}
36
+
37
+ if (process.platform !== 'win32') {
38
+ // sudo 安装时文件 owner root,Chrome 无法写入 _metadata/
39
+ // 用 SUDO_USER 还原为真实用户
40
+ const realUser = process.env.SUDO_USER;
41
+ if (realUser) {
42
+ try { execSync(`chown -R "${realUser}" "${cockpitDir}"`); } catch {}
43
+ }
44
+ // macOS: 清除 com.apple.provenance 等扩展属性
45
+ if (process.platform === 'darwin') {
46
+ try { execSync(`xattr -cr "${dest}"`); } catch {}
47
+ }
38
48
  }
39
49
  } catch {}
40
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surething/cockpit",
3
- "version": "1.0.176",
3
+ "version": "1.0.178",
4
4
  "description": "The Cockpit That Drives AI",
5
5
  "author": "Robert",
6
6
  "license": "MIT",
package/server.mjs CHANGED
@@ -71,8 +71,10 @@ app.prepare().then(async () => {
71
71
 
72
72
  // prod 模式自动打开浏览器(--no-open 禁用)
73
73
  if (!dev && !process.env.COCKPIT_NO_OPEN) {
74
+ const openProject = process.env.COCKPIT_OPEN_PROJECT;
75
+ const openUrl = openProject ? `${url}/?cwd=${encodeURIComponent(openProject)}` : url;
74
76
  const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
75
- exec(`${cmd} ${url}`);
77
+ exec(`${cmd} ${openUrl}`);
76
78
  }
77
79
  });
78
80