claude-home 1.0.0 → 1.0.2
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/README.md +7 -3
- package/bin/cli.js +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,13 +29,17 @@ claude-home is a local Express server that reads your `~/.claude/` directory dir
|
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
```bash
|
|
33
|
+
npx claude-home
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or install globally:
|
|
33
37
|
|
|
34
38
|
```bash
|
|
35
|
-
npm install -g
|
|
39
|
+
npm install -g claude-home
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
> Requires Node.js 18+.
|
|
42
|
+
> Requires Node.js 18+.
|
|
39
43
|
|
|
40
44
|
### From source
|
|
41
45
|
|
package/bin/cli.js
CHANGED
|
@@ -57,16 +57,56 @@ if (subcommand === 'setup-hook') {
|
|
|
57
57
|
|
|
58
58
|
// ─── Main: start server or reuse existing ────────────────────────────────────
|
|
59
59
|
|
|
60
|
+
checkForUpdates(); // async, non-blocking
|
|
61
|
+
|
|
60
62
|
isPortFree(port).then(free => {
|
|
61
63
|
if (free) {
|
|
62
64
|
const { startServer } = require('../server.js');
|
|
63
65
|
startServer(port);
|
|
64
66
|
} else {
|
|
65
|
-
console.log(`
|
|
67
|
+
console.log(`claude-home already running at http://localhost:${port}`);
|
|
66
68
|
}
|
|
67
69
|
if (!noOpen) openBrowser(`http://localhost:${port}`);
|
|
68
70
|
});
|
|
69
71
|
|
|
72
|
+
// ─── Update check ────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
function checkForUpdates() {
|
|
75
|
+
const cacheFile = path.join(os.homedir(), '.claude', 'sessions-browser', '.update-check');
|
|
76
|
+
const TTL = 24 * 60 * 60 * 1000; // 24h
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
|
|
80
|
+
if (Date.now() - cache.checkedAt < TTL) return; // still fresh
|
|
81
|
+
} catch { /* no cache yet */ }
|
|
82
|
+
|
|
83
|
+
const https = require('https');
|
|
84
|
+
https.get(`https://registry.npmjs.org/claude-home/latest`, { headers: { 'User-Agent': 'claude-home' } }, res => {
|
|
85
|
+
let data = '';
|
|
86
|
+
res.on('data', c => data += c);
|
|
87
|
+
res.on('end', () => {
|
|
88
|
+
try {
|
|
89
|
+
const latest = JSON.parse(data).version;
|
|
90
|
+
fs.writeFileSync(cacheFile, JSON.stringify({ checkedAt: Date.now(), latest }), 'utf8');
|
|
91
|
+
if (latest && latest !== pkg.version && isNewer(latest, pkg.version)) {
|
|
92
|
+
console.log(`\n Update available: ${pkg.version} → ${latest}`);
|
|
93
|
+
console.log(` Run: npm install -g claude-home@latest\n`);
|
|
94
|
+
}
|
|
95
|
+
} catch { /* ignore parse errors */ }
|
|
96
|
+
});
|
|
97
|
+
}).on('error', () => { /* ignore network errors */ });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function isNewer(a, b) {
|
|
101
|
+
const pa = a.split('.').map(Number);
|
|
102
|
+
const pb = b.split('.').map(Number);
|
|
103
|
+
for (let i = 0; i < 3; i++) {
|
|
104
|
+
if (pa[i] > pb[i]) return true;
|
|
105
|
+
if (pa[i] < pb[i]) return false;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
70
110
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
71
111
|
|
|
72
112
|
function isPortFree(p) {
|