claude-live 0.4.5 → 0.4.7

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.
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Check if plugin version has changed and restart server if needed
5
+ * Called on SessionStart to ensure server version matches plugin version
6
+ */
7
+
8
+ import { readFileSync, writeFileSync, mkdirSync } from 'fs';
9
+ import { dirname, join } from 'path';
10
+ import { fileURLToPath, pathToFileURL } from 'url';
11
+ import { execSync } from 'child_process';
12
+ import { homedir } from 'os';
13
+
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const pluginRoot = dirname(__dirname);
16
+ const versionFile = join(homedir(), '.claude', 'claude-live-version.txt');
17
+
18
+ try {
19
+ // Read current plugin version
20
+ const packageJsonPath = join(pluginRoot, 'package.json');
21
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
22
+ const currentVersion = packageJson.version;
23
+
24
+ // Read last known version
25
+ let lastVersion = '';
26
+ try {
27
+ lastVersion = readFileSync(versionFile, 'utf8').trim();
28
+ } catch {
29
+ // File doesn't exist yet, that's ok
30
+ }
31
+
32
+ // If versions differ, restart server
33
+ if (lastVersion && lastVersion !== currentVersion) {
34
+ console.log(`[claude-live] Plugin updated: ${lastVersion} → ${currentVersion}`);
35
+ console.log('[claude-live] Restarting server...');
36
+
37
+ // Kill any existing claude-live processes
38
+ try {
39
+ execSync('pkill -f "node.*claude-live" || true', { stdio: 'ignore' });
40
+ // Give it a moment to die
41
+ await new Promise(r => setTimeout(r, 500));
42
+ } catch {
43
+ // Process might not exist
44
+ }
45
+ }
46
+
47
+ // Save current version
48
+ mkdirSync(dirname(versionFile), { recursive: true });
49
+ writeFileSync(versionFile, currentVersion);
50
+
51
+ // Start server if not running
52
+ const serverUrl = process.env.CLAUDE_LIVE_URL || 'http://localhost:43451';
53
+ try {
54
+ execSync(`curl -sf ${serverUrl}/buffer >/dev/null 2>&1`, { stdio: 'ignore' });
55
+ console.log('[claude-live] Server already running');
56
+ } catch {
57
+ console.log('[claude-live] Starting server...');
58
+ execSync(`npx claude-live@${currentVersion} >/tmp/claude-live.log 2>&1 &`, { stdio: 'ignore' });
59
+ }
60
+ } catch (error) {
61
+ console.error('[claude-live] Error:', error.message);
62
+ process.exit(1);
63
+ }
package/hooks/hooks.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "hooks": [
6
6
  {
7
7
  "type": "command",
8
- "command": "curl -sf http://localhost:43451/buffer >/dev/null 2>&1 || (npx claude-live@latest >/tmp/claude-live.log 2>&1 &)",
8
+ "command": "node \"$(npm root -g)/claude-live/bin/check-and-restart.js\" 2>/dev/null || node \"./node_modules/claude-live/bin/check-and-restart.js\" 2>/dev/null || true",
9
9
  "async": true
10
10
  },
11
11
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-live",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Realtime Claude Code activity visualizer",
5
5
  "bin": {
6
6
  "claude-live": "./bin/claude-live.js"