claudelink-bridge 0.1.30 → 0.1.31
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/bin/cli.js +21 -10
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -88,13 +88,14 @@ ${BOLD}Useful commands:${RESET}
|
|
|
88
88
|
// ─── start (manual run) ───────────────────────────────────────────────────────
|
|
89
89
|
|
|
90
90
|
else if (cmd === 'start') {
|
|
91
|
-
// Check if already running before starting
|
|
92
91
|
const port = parseInt(process.env.CLAUDELINK_PORT ?? '9999');
|
|
93
92
|
const alreadyRunning = await checkPortRunning(port);
|
|
94
93
|
if (alreadyRunning) {
|
|
95
94
|
ok(`Bridge is already running on port ${port}. Nothing to do.`);
|
|
96
95
|
process.exit(0);
|
|
97
96
|
}
|
|
97
|
+
// Auto-kill whatever is on the port before starting
|
|
98
|
+
await killPort(port);
|
|
98
99
|
info('Starting bridge server (Ctrl+C to stop)…');
|
|
99
100
|
await import('../lib/server.js');
|
|
100
101
|
}
|
|
@@ -103,15 +104,9 @@ else if (cmd === 'start') {
|
|
|
103
104
|
|
|
104
105
|
else if (cmd === 'kill') {
|
|
105
106
|
const port = parseInt(process.env.CLAUDELINK_PORT ?? '9999');
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
execSync(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${port}') do taskkill /F /PID %a`, { shell: true, stdio: 'ignore' });
|
|
110
|
-
} else {
|
|
111
|
-
execSync(`lsof -ti:${port} | xargs kill -9 2>/dev/null || true`, { shell: true, stdio: 'ignore' });
|
|
112
|
-
}
|
|
113
|
-
ok(`Killed process on port ${port}`);
|
|
114
|
-
} catch { warn(`Nothing was running on port ${port}`); }
|
|
107
|
+
const killed = await killPort(port);
|
|
108
|
+
if (killed) ok(`Killed process on port ${port}`);
|
|
109
|
+
else warn(`Nothing was running on port ${port}`);
|
|
115
110
|
}
|
|
116
111
|
|
|
117
112
|
// ─── status ───────────────────────────────────────────────────────────────────
|
|
@@ -159,6 +154,22 @@ Commands:
|
|
|
159
154
|
|
|
160
155
|
// ─── Helper ───────────────────────────────────────────────────────────────────
|
|
161
156
|
|
|
157
|
+
async function killPort(port) {
|
|
158
|
+
try {
|
|
159
|
+
const { execSync } = await import('child_process');
|
|
160
|
+
if (OS === 'win32') {
|
|
161
|
+
execSync(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${port}') do taskkill /F /PID %a`, { shell: true, stdio: 'ignore' });
|
|
162
|
+
} else {
|
|
163
|
+
const pids = execSync(`lsof -ti:${port} 2>/dev/null || true`, { shell: true }).toString().trim();
|
|
164
|
+
if (pids) execSync(`kill -9 ${pids}`, { shell: true, stdio: 'ignore' });
|
|
165
|
+
else return false;
|
|
166
|
+
}
|
|
167
|
+
// Small wait so OS releases the port before we try to bind
|
|
168
|
+
await new Promise(r => setTimeout(r, 300));
|
|
169
|
+
return true;
|
|
170
|
+
} catch { return false; }
|
|
171
|
+
}
|
|
172
|
+
|
|
162
173
|
async function checkPortRunning(port) {
|
|
163
174
|
return new Promise((resolve) => {
|
|
164
175
|
import('ws').then(({ default: WS }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudelink-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "Bridge your browser to Claude Code CLI. The local server for the ClaudeLink Chrome extension — send screenshots, page content, and custom commands from any webpage directly to Claude Code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|