claude-friends 0.3.3 → 0.4.0
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/cli.js +23 -2
- package/daemon.js +27 -0
- package/package.json +3 -2
package/cli.js
CHANGED
|
@@ -114,21 +114,42 @@ if (command === "setup") {
|
|
|
114
114
|
console.log("Could not install token hook (non-critical):", err.message);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
// Install statusline
|
|
117
|
+
// Install statusline + daemon hooks (read settings once)
|
|
118
118
|
try {
|
|
119
119
|
const settingsPath2 = join(homedir(), ".claude", "settings.json");
|
|
120
120
|
let settings = {};
|
|
121
121
|
if (existsSync(settingsPath2)) {
|
|
122
122
|
settings = JSON.parse(readFileSync(settingsPath2, "utf-8"));
|
|
123
123
|
}
|
|
124
|
+
|
|
124
125
|
if (!settings.statusLine) {
|
|
125
126
|
settings.statusLine = {
|
|
126
127
|
type: "command",
|
|
127
128
|
command: `node ${join(__dirname, "statusline.js")}`,
|
|
128
129
|
};
|
|
129
|
-
writeFileSync(settingsPath2, JSON.stringify(settings, null, 2));
|
|
130
130
|
console.log("Installed status line.");
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
// SessionStart hook: spawn daemon to keep user online
|
|
134
|
+
if (!settings.hooks) settings.hooks = {};
|
|
135
|
+
const daemonCmd = `node ${join(__dirname, "daemon.js")}`;
|
|
136
|
+
|
|
137
|
+
if (!settings.hooks.SessionStart) settings.hooks.SessionStart = [];
|
|
138
|
+
const daemonInstalled = settings.hooks.SessionStart.some((h) =>
|
|
139
|
+
h.hooks?.some((hk) => hk.command?.includes("daemon.js"))
|
|
140
|
+
);
|
|
141
|
+
if (!daemonInstalled) {
|
|
142
|
+
settings.hooks.SessionStart.push({
|
|
143
|
+
hooks: [{
|
|
144
|
+
type: "command",
|
|
145
|
+
command: daemonCmd,
|
|
146
|
+
async: true,
|
|
147
|
+
}],
|
|
148
|
+
});
|
|
149
|
+
console.log("Installed presence daemon (keeps you online).");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
writeFileSync(settingsPath2, JSON.stringify(settings, null, 2));
|
|
132
153
|
} catch {}
|
|
133
154
|
|
|
134
155
|
console.log(`
|
package/daemon.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Background daemon that keeps you online in claude-friends.
|
|
4
|
+
// Runs as a persistent WebSocket connection.
|
|
5
|
+
// Started automatically by the SessionStart hook.
|
|
6
|
+
|
|
7
|
+
import { getConfig, createConnection } from "./client.js";
|
|
8
|
+
|
|
9
|
+
const config = getConfig();
|
|
10
|
+
if (!config) process.exit(0);
|
|
11
|
+
|
|
12
|
+
const ws = createConnection(config.username);
|
|
13
|
+
|
|
14
|
+
ws.addEventListener("open", () => {
|
|
15
|
+
// Silently connected — we're online
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
ws.addEventListener("close", () => {
|
|
19
|
+
// Reconnect after a delay (partysocket handles this automatically)
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Keep process alive
|
|
23
|
+
setInterval(() => {}, 60000);
|
|
24
|
+
|
|
25
|
+
// Clean exit
|
|
26
|
+
process.on("SIGINT", () => { ws.close(); process.exit(0); });
|
|
27
|
+
process.on("SIGTERM", () => { ws.close(); process.exit(0); });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-friends",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "See who's online in Claude Code. Add friends, share status, nudge each other.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"statusline.js",
|
|
18
18
|
"client.js",
|
|
19
19
|
"commands/",
|
|
20
|
-
"hooks/"
|
|
20
|
+
"hooks/",
|
|
21
|
+
"daemon.js"
|
|
21
22
|
],
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"@modelcontextprotocol/sdk": "^1.12.1",
|