claude-rpc 0.22.0 → 0.22.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.22.0",
3
+ "version": "0.22.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/install.js CHANGED
@@ -635,18 +635,34 @@ function verifyHookPipe(exePath) {
635
635
  // hooks to the now-persistent global bin exactly like a normal npm install.
636
636
  // Best-effort + loud: a failed -g (perms, offline) returns false so the caller
637
637
  // can stop with the manual command rather than wire a dead hook.
638
- function promoteNpxToGlobal() {
639
- // Already promoted on a previous run? The PATH-resolved bin answers fast.
638
+ // Version of the GLOBALLY-installed claude-rpc, read straight off disk via
639
+ // `npm root -g` NOT through PATH. While setup runs under `npx
640
+ // claude-rpc@latest`, npx prepends its own throwaway cache (the current
641
+ // VERSION) to PATH, so a bare `claude-rpc --version` resolves to npx's copy and
642
+ // always looks current — which made promoteNpxToGlobal skip the real upgrade
643
+ // and silently leave a stale older global behind (it printed ✓ but did
644
+ // nothing). Reading the global package.json sidesteps that PATH shadowing.
645
+ function globalInstalledVersion() {
640
646
  try {
641
- const v = spawnSync('claude-rpc', ['--version'], {
647
+ const r = spawnSync('npm', ['root', '-g'], {
642
648
  encoding: 'utf8', timeout: 4000, windowsHide: true,
643
- shell: process.platform === 'win32',
649
+ shell: process.platform === 'win32', // npm is npm.cmd on Windows
644
650
  });
645
- if ((v.stdout || '').trim() === `claude-rpc ${VERSION}`) {
646
- noop('global install current');
647
- return true;
648
- }
649
- } catch { /* not installed yet promote below */ }
651
+ const root = (r.stdout || '').trim();
652
+ if (!root) return null;
653
+ const pkg = JSON.parse(readFileSync(join(root, 'claude-rpc', 'package.json'), 'utf8'));
654
+ return typeof pkg.version === 'string' ? pkg.version : null;
655
+ } catch { return null; } // not installed / npm missing / unreadable
656
+ }
657
+
658
+ function promoteNpxToGlobal() {
659
+ // Already promoted on a previous run AND current? Skip the redundant -g (also
660
+ // lets setup succeed when a correct global exists but `npm -g` would fail —
661
+ // perms/offline). Checks the on-disk global, immune to npx's PATH shadowing.
662
+ if (globalInstalledVersion() === VERSION) {
663
+ noop('global install current');
664
+ return true;
665
+ }
650
666
  const r = spawnSync('npm', ['install', '-g', `claude-rpc@${VERSION}`], {
651
667
  encoding: 'utf8',
652
668
  shell: process.platform === 'win32', // npm is npm.cmd on Windows
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.22.0';
14
+ const BAKED = '0.22.1';
15
15
 
16
16
  function readPkgVersion() {
17
17
  try {