cc-rehab 3.0.1 → 3.1.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/index.mjs +26 -8
- package/package.json +2 -1
package/index.mjs
CHANGED
|
@@ -174,10 +174,23 @@ function deriveStatsServer(sessions) {
|
|
|
174
174
|
|
|
175
175
|
// ── Supabase sync ──
|
|
176
176
|
async function syncToSupabase(stats, cfg) {
|
|
177
|
+
// Fetch existing row to preserve _name/_avatar set by frontend
|
|
178
|
+
let existingName = "Anonymous", existingAvatar = "🫠";
|
|
179
|
+
try {
|
|
180
|
+
const r = await fetch(`${SUPA_URL}/rest/v1/user_stats?id=eq.${cfg.uid}&select=stats&limit=1`, {
|
|
181
|
+
headers: { apikey: SUPA_KEY },
|
|
182
|
+
});
|
|
183
|
+
if (r.ok) {
|
|
184
|
+
const rows = await r.json();
|
|
185
|
+
if (rows[0]?.stats?._name) existingName = rows[0].stats._name;
|
|
186
|
+
if (rows[0]?.stats?._avatar) existingAvatar = rows[0].stats._avatar;
|
|
187
|
+
}
|
|
188
|
+
} catch {}
|
|
189
|
+
|
|
177
190
|
const body = {
|
|
178
191
|
id: cfg.uid,
|
|
179
192
|
pair_code: cfg.token,
|
|
180
|
-
stats,
|
|
193
|
+
stats: { _name: existingName, _avatar: existingAvatar, ...stats },
|
|
181
194
|
updated_at: new Date().toISOString(),
|
|
182
195
|
};
|
|
183
196
|
try {
|
|
@@ -242,13 +255,18 @@ function tryListen(port) {
|
|
|
242
255
|
console.log(` ✓ Scanned ${cached.fileCount} files, ${cached.sessions.length} sessions`);
|
|
243
256
|
console.log(synced ? " ✓ Synced to cloud" : " ✗ Cloud sync failed (will retry)");
|
|
244
257
|
console.log("");
|
|
245
|
-
console.log("
|
|
246
|
-
console.log(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
258
|
+
console.log(" Open this link on ANY device:\n");
|
|
259
|
+
console.log(` ${appLink}\n`);
|
|
260
|
+
|
|
261
|
+
// Terminal QR code
|
|
262
|
+
try {
|
|
263
|
+
const qr = await import("qrcode-terminal");
|
|
264
|
+
qr.default.generate(appLink, { small: true }, (code) => {
|
|
265
|
+
code.split("\n").forEach(l => console.log(" " + l));
|
|
266
|
+
console.log("");
|
|
267
|
+
});
|
|
268
|
+
} catch {}
|
|
269
|
+
|
|
252
270
|
console.log(` Local API: http://localhost:${port}/api/sessions`);
|
|
253
271
|
ips.forEach(ip => console.log(` LAN: http://${ip}:${port}/api/sessions`));
|
|
254
272
|
console.log("\n Syncs every 5 min. Ctrl+C to stop.\n");
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-rehab",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Claude Code addiction monitor — syncs your usage to the cloud dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "cc-rehab": "index.mjs" },
|
|
7
7
|
"files": ["index.mjs"],
|
|
8
|
+
"dependencies": { "qrcode-terminal": "^0.12.0" },
|
|
8
9
|
"keywords": ["claude", "claude-code", "usage", "monitor", "rehab"]
|
|
9
10
|
}
|