claude-rpc 0.22.0 → 0.23.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/README.md +4 -2
- package/package.json +1 -1
- package/src/cli.js +17 -9
- package/src/install.js +25 -9
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -146,13 +146,15 @@ claude-rpc readme # prints paste-ready README badge markdown
|
|
|
146
146
|
claude-rpc readme --raw | pbcopy # straight to your clipboard
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
**Live badges, paste once.** With a public profile (`claude-rpc profile set --handle <you> && claude-rpc profile on`), your stats are served as always-current badges from the community worker — no `gh`, no gist, nothing to re-run:
|
|
149
|
+
**Live card + badges, paste once.** With a public profile (`claude-rpc profile set --handle <you> && claude-rpc profile on`), your stats are served as an always-current card (and badges) from the community worker — no `gh`, no gist, nothing to re-run:
|
|
150
150
|
|
|
151
151
|
```md
|
|
152
|
+
[](https://claude-rpc.vercel.app/u/<you>)
|
|
153
|
+
|
|
152
154
|
[](https://claude-rpc.vercel.app/?ref=badge)
|
|
153
155
|
```
|
|
154
156
|
|
|
155
|
-
`metric=` is one of `tokens · sessions · hours · streak` (optional `&label=` to retitle). Your profile page at `/u/<you>` has a one-click "copy" for the
|
|
157
|
+
The card shows tokens, sessions, active hours and streak; badge `metric=` is one of `tokens · sessions · hours · streak` (optional `&label=` to retitle). Both refresh themselves as the daemon flushes your profile (~every 30 min). Your profile page at `/u/<you>` has a one-click "copy" for the whole block.
|
|
156
158
|
|
|
157
159
|
Prefer to render locally? `badge`/`card`/`calendar`/`github-stat` all write SVG, and `--gist` self-hosts a live one:
|
|
158
160
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1075,35 +1075,43 @@ function doReadme(argv) {
|
|
|
1075
1075
|
['streak', 'Claude Code streak'],
|
|
1076
1076
|
['tokens', 'Claude Code tokens'],
|
|
1077
1077
|
];
|
|
1078
|
-
|
|
1078
|
+
// The hero: a live stat card that auto-refreshes from your published profile.
|
|
1079
|
+
const cardMd = (h) => `[](${site}/u/${h})`;
|
|
1080
|
+
const badgesMd = (h) => metrics
|
|
1079
1081
|
.map(([m, alt]) => `[](${site}/?ref=badge)`)
|
|
1080
1082
|
.join('\n');
|
|
1083
|
+
const liveMd = (h) => `${cardMd(h)}\n\n${badgesMd(h)}`;
|
|
1081
1084
|
|
|
1082
1085
|
// Raw mode: just the markdown, for `claude-rpc readme --raw | pbcopy`.
|
|
1083
1086
|
if (raw) {
|
|
1084
1087
|
process.stdout.write(live
|
|
1085
1088
|
? liveMd(handle) + '\n'
|
|
1086
|
-
: '<!-- live badges need a public profile: claude-rpc profile set --handle <name> && claude-rpc profile on -->\n');
|
|
1089
|
+
: '<!-- live card/badges need a public profile: claude-rpc profile set --handle <name> && claude-rpc profile on -->\n');
|
|
1087
1090
|
return;
|
|
1088
1091
|
}
|
|
1089
1092
|
|
|
1090
1093
|
console.log('');
|
|
1091
|
-
console.log(` ${c.bold}${c.magenta}◆ README badges${c.reset}`);
|
|
1094
|
+
console.log(` ${c.bold}${c.magenta}◆ README card + badges${c.reset}`);
|
|
1092
1095
|
console.log('');
|
|
1093
1096
|
|
|
1094
1097
|
if (live) {
|
|
1095
|
-
console.log(` ${c.dim}Live
|
|
1098
|
+
console.log(` ${c.dim}Live stat card for ${c.reset}${c.cyan}@${handle}${c.reset}${c.dim} — paste once; it auto-updates as you work:${c.reset}`);
|
|
1096
1099
|
console.log('');
|
|
1097
|
-
|
|
1100
|
+
console.log(` ${cardMd(handle)}`);
|
|
1098
1101
|
console.log('');
|
|
1099
|
-
console.log(` ${c.dim}
|
|
1102
|
+
console.log(` ${c.dim}…or compact badges:${c.reset}`);
|
|
1103
|
+
console.log('');
|
|
1104
|
+
for (const line of badgesMd(handle).split('\n')) console.log(` ${line}`);
|
|
1105
|
+
console.log('');
|
|
1106
|
+
console.log(` ${c.dim}Badge metrics:${c.reset} ${c.cyan}tokens · sessions · hours · streak${c.reset}`);
|
|
1100
1107
|
console.log(` ${c.dim}One-click copy + shareable page:${c.reset} ${c.cyan}${site}/u/${handle}${c.reset}`);
|
|
1101
1108
|
console.log(` ${c.dim}Straight to clipboard:${c.reset} ${c.cyan}claude-rpc readme --raw${c.reset}${c.dim} | pbcopy${c.reset}`);
|
|
1102
1109
|
} else {
|
|
1103
|
-
console.log(` ${c.dim}A live, always-current
|
|
1110
|
+
console.log(` ${c.dim}A live, always-current card + badges need a public profile. Turn one on:${c.reset}`);
|
|
1104
1111
|
console.log(` ${c.cyan}claude-rpc profile set --handle <name> && claude-rpc profile on${c.reset}`);
|
|
1105
1112
|
console.log('');
|
|
1106
|
-
console.log(` ${c.dim}Then your badges live here (self-refreshing — paste once):${c.reset}`);
|
|
1113
|
+
console.log(` ${c.dim}Then your card + badges live here (self-refreshing — paste once):${c.reset}`);
|
|
1114
|
+
console.log(` ${c.cyan}${endpoint}/card/<handle>.svg${c.reset}`);
|
|
1107
1115
|
console.log(` ${c.cyan}${endpoint}/badge/<handle>.svg?metric=hours${c.reset}`);
|
|
1108
1116
|
}
|
|
1109
1117
|
|
|
@@ -2003,7 +2011,7 @@ function help() {
|
|
|
2003
2011
|
['statusline', 'One-line status for tmux/shell prompts (--template)'],
|
|
2004
2012
|
['calendar', 'Year activity heatmap SVG (--out --gist)'],
|
|
2005
2013
|
['session-card', 'Recap card for the current session (--out)'],
|
|
2006
|
-
['readme', 'Paste-ready README badges for your profile (--raw to pipe)'],
|
|
2014
|
+
['readme', 'Paste-ready README card + badges for your profile (--raw to pipe)'],
|
|
2007
2015
|
['mcp install', 'Wire the stats MCP server into Claude Code (one command)'],
|
|
2008
2016
|
['mcp uninstall', 'Remove the stats MCP server from Claude Code'],
|
|
2009
2017
|
['mcp', 'Run the MCP server (stdio) — exposes your stats to Claude'],
|
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
|
-
|
|
639
|
-
|
|
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
|
|
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
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
} catch {
|
|
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
|