claude-rpc 0.8.0 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-rpc",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Discord Rich Presence for Claude Code — live model, project, tokens, and lifetime stats driven by Claude Code's hook system.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/daemon.js CHANGED
@@ -7,6 +7,7 @@ import { scan, readAggregate, findLiveSessions, readSessionTokens } from './scan
7
7
  import { detectGithubUrl } from './git.js';
8
8
  import { applyPrivacy } from './privacy.js';
9
9
  import { loadConfig } from './config.js';
10
+ import { migrateConfig } from './install.js';
10
11
  import { CONFIG_PATH, STATE_PATH, PID_PATH, LOG_PATH, STATE_DIR, AGGREGATE_PATH } from './paths.js';
11
12
 
12
13
  if (!existsSync(STATE_DIR)) mkdirSync(STATE_DIR, { recursive: true });
@@ -51,6 +52,20 @@ function loadConfigWithLog() {
51
52
  return loadConfig({ onError: (msg) => log(msg) });
52
53
  }
53
54
 
55
+ // Bring an existing config.json up to date with the current defaults before
56
+ // we load it. This is how upgrades reach users who just `npm update` + restart
57
+ // the daemon without re-running `claude-rpc setup` — e.g. the v0.8.1 button-URL
58
+ // move. Idempotent: only writes when something actually changes, so steady-state
59
+ // restarts are a no-op and can't loop the config watcher. Best-effort — a
60
+ // migration failure must never stop the daemon from starting.
61
+ try {
62
+ if (migrateConfig({ silent: true })) {
63
+ log('config.json migrated to current defaults on startup');
64
+ }
65
+ } catch (e) {
66
+ log('startup config migration failed (continuing):', e?.message || String(e));
67
+ }
68
+
54
69
  let config = loadConfigWithLog();
55
70
  let aggregate = readAggregate() || null;
56
71
  let liveSessions = [];
package/src/install.js CHANGED
@@ -235,12 +235,12 @@ export function seedConfig() {
235
235
  // without clobbering the user's customizations. Anything the user already
236
236
  // has — including a pre-existing byStatus, custom rotation array, custom
237
237
  // appName etc. — is left untouched.
238
- export function migrateConfig() {
238
+ export function migrateConfig({ silent = false } = {}) {
239
239
  if (!existsSync(CONFIG_PATH)) return false;
240
240
  let cfg;
241
241
  try { cfg = JSON.parse(readFileSync(CONFIG_PATH, 'utf8')); }
242
242
  catch (e) {
243
- console.warn(` ! could not read config for migration: ${e.message}`);
243
+ if (!silent) console.warn(` ! could not read config for migration: ${e.message}`);
244
244
  return false;
245
245
  }
246
246
  if (!cfg || typeof cfg !== 'object') return false;
@@ -300,13 +300,31 @@ export function migrateConfig() {
300
300
  added.push('community (preserved-off)');
301
301
  }
302
302
 
303
+ // v0.8.1: the default presence button moved from the Claude Code website
304
+ // to the project repo. Existing configs carry their own `buttons` array,
305
+ // which fully REPLACES the default (arrays don't deep-merge) — so the new
306
+ // default never reaches upgraders just by bumping the package. Rewrite
307
+ // ONLY a button still pointing at the verbatim old default URL; anything a
308
+ // user has customized (label or url) is left untouched.
309
+ const OLD_BTN_URL = 'https://claude.com/claude-code';
310
+ const NEW_BTN_URL = DEFAULT_CONFIG.presence?.buttons?.[0]?.url;
311
+ if (NEW_BTN_URL && Array.isArray(cfg.presence?.buttons)) {
312
+ let changed = false;
313
+ for (const b of cfg.presence.buttons) {
314
+ if (b && b.url === OLD_BTN_URL) { b.url = NEW_BTN_URL; changed = true; }
315
+ }
316
+ if (changed) added.push('presence.buttons[].url → repo');
317
+ }
318
+
303
319
  if (added.length === 0) {
304
- console.log(` config up to date → ${CONFIG_PATH}`);
320
+ if (!silent) console.log(` config up to date → ${CONFIG_PATH}`);
305
321
  return false;
306
322
  }
307
323
  writeFileSync(CONFIG_PATH, JSON.stringify(cfg, null, 2));
308
- console.log(` config migrated → ${CONFIG_PATH}`);
309
- console.log(` added: ${added.join(', ')}`);
324
+ if (!silent) {
325
+ console.log(` config migrated → ${CONFIG_PATH}`);
326
+ console.log(` added: ${added.join(', ')}`);
327
+ }
310
328
  return true;
311
329
  }
312
330
 
package/src/version.js CHANGED
@@ -11,7 +11,7 @@ import { readFileSync } from 'node:fs';
11
11
  import { join } from 'node:path';
12
12
  import { ROOT } from './paths.js';
13
13
 
14
- const BAKED = '0.8.0';
14
+ const BAKED = '0.8.1';
15
15
 
16
16
  function readPkgVersion() {
17
17
  try {