claude-rpc 0.21.0 → 0.22.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 CHANGED
@@ -25,7 +25,7 @@
25
25
  [![Node 18+](https://img.shields.io/badge/node-%3E%3D18-43853d.svg?logo=node.js&logoColor=white)](https://nodejs.org)
26
26
  [![Claude Code](https://img.shields.io/badge/Claude%20Code-hooks-d97757.svg)](https://claude.com/claude-code)
27
27
  [![Discord RPC](https://img.shields.io/badge/Discord-RPC-5865F2.svg?logo=discord&logoColor=white)](https://discord.com/developers/docs/topics/rpc)
28
- [![Release](https://img.shields.io/github/v/release/rar-file/claude-rpc?color=4c1)](https://github.com/rar-file/claude-rpc/releases/latest)
28
+ [![Release](https://img.shields.io/npm/v/claude-rpc?color=4c1&label=release&logo=npm&logoColor=white)](https://github.com/rar-file/claude-rpc/releases/latest)
29
29
  [![npm downloads](https://img.shields.io/npm/dm/claude-rpc?color=cb3837&logo=npm&logoColor=white&label=downloads)](https://www.npmjs.com/package/claude-rpc)
30
30
 
31
31
  </div>
@@ -139,7 +139,22 @@ The web dashboard pushes updates via SSE; the TUI refreshes on a 3-second tick.
139
139
 
140
140
  ### beyond your machine
141
141
 
142
- Shields-style badges and a poster-style summary card you can paste into a README or a Discord message:
142
+ Shields-style badges and a poster-style summary card you can paste into a README or a Discord message. The fastest path is one command:
143
+
144
+ ```sh
145
+ claude-rpc readme # prints paste-ready README badge markdown
146
+ claude-rpc readme --raw | pbcopy # straight to your clipboard
147
+ ```
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:
150
+
151
+ ```md
152
+ [![Claude Code hours](https://claude-rpc-totals.claude-rpc.workers.dev/badge/<you>.svg?metric=hours)](https://claude-rpc.vercel.app/?ref=badge)
153
+ ```
154
+
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 same block. The badge refreshes itself as the daemon flushes your profile (~every 30 min).
156
+
157
+ Prefer to render locally? `badge`/`card`/`calendar`/`github-stat` all write SVG, and `--gist` self-hosts a live one:
143
158
 
144
159
  ```sh
145
160
  claude-rpc badge --metric hours --range 7d --out claude-hours.svg
@@ -258,6 +273,17 @@ Frames have a `requires` field; the daemon skips a frame when any of its require
258
273
 
259
274
  The full default config is in [`src/default-config.js`](src/default-config.js) — that's the canonical list of every key. ~140 template variables are available; `claude-rpc vars` is the source of truth.
260
275
 
276
+ ## claude code plugin
277
+
278
+ Prefer to install from inside Claude Code? There's a [plugin](plugin/) for that:
279
+
280
+ ```text
281
+ /plugin marketplace add rar-file/claude-rpc
282
+ /plugin install claude-rpc@claude-rpc
283
+ ```
284
+
285
+ It's a thin bootstrapper — on the first session it just runs `npx claude-rpc@latest setup` for you (the same install as above), then stays out of the way. macOS / Linux / WSL; on Windows use the portable exe. Nothing extra is added to your sessions — the plugin is a single `SessionStart` hook with no model-context cost.
286
+
261
287
  ## commands
262
288
 
263
289
  `claude-rpc --help` lists them all — and after `setup` you rarely need any.
@@ -286,6 +312,7 @@ The full default config is in [`src/default-config.js`](src/default-config.js)
286
312
  | `github-stat` | Embeddable profile stat card (`--handle` `--out` `--gist`) |
287
313
  | `calendar` | Year activity heatmap SVG (`--out` `--gist`) |
288
314
  | `session-card` | Recap card for the current session (`--out`) |
315
+ | `readme` | Paste-ready README badge markdown for your profile (`--raw` to pipe) |
289
316
  | `statusline` | One-line status for tmux/shell prompts (`--template`) |
290
317
  | `mcp install` | Wire the stats MCP server into Claude Code (one command) |
291
318
  | `mcp` | Run the MCP server (stdio) for Claude Code |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-rpc",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
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/cli.js CHANGED
@@ -1057,6 +1057,67 @@ async function doSessionCard(argv) {
1057
1057
  } else process.stdout.write(svg);
1058
1058
  }
1059
1059
 
1060
+ // `claude-rpc readme` — paste-ready markdown for putting your live Claude Code
1061
+ // stats in a README. Pure printer: reads config + the worker endpoint, never
1062
+ // hits the network. The live badges track your published profile and refresh
1063
+ // themselves (no gist, no `gh`, no re-running). `--raw` prints just the
1064
+ // markdown so you can pipe it straight to a clipboard tool.
1065
+ function doReadme(argv) {
1066
+ const raw = argv.includes('--raw') || argv.includes('--plain');
1067
+ const cfg = loadConfig();
1068
+ const endpoint = (cfg.community?.endpoint || 'https://claude-rpc-totals.claude-rpc.workers.dev').replace(/\/+$/, '');
1069
+ const site = 'https://claude-rpc.vercel.app';
1070
+ const profile = cfg.profile || {};
1071
+ const handle = profile.handle;
1072
+ const live = !!profile.enabled && lb.isValidHandle(handle);
1073
+ const metrics = [
1074
+ ['hours', 'Claude Code hours'],
1075
+ ['streak', 'Claude Code streak'],
1076
+ ['tokens', 'Claude Code tokens'],
1077
+ ];
1078
+ const liveMd = (h) => metrics
1079
+ .map(([m, alt]) => `[![${alt}](${endpoint}/badge/${h}.svg?metric=${m})](${site}/?ref=badge)`)
1080
+ .join('\n');
1081
+
1082
+ // Raw mode: just the markdown, for `claude-rpc readme --raw | pbcopy`.
1083
+ if (raw) {
1084
+ process.stdout.write(live
1085
+ ? liveMd(handle) + '\n'
1086
+ : '<!-- live badges need a public profile: claude-rpc profile set --handle <name> && claude-rpc profile on -->\n');
1087
+ return;
1088
+ }
1089
+
1090
+ console.log('');
1091
+ console.log(` ${c.bold}${c.magenta}◆ README badges${c.reset}`);
1092
+ console.log('');
1093
+
1094
+ if (live) {
1095
+ console.log(` ${c.dim}Live badges for ${c.reset}${c.cyan}@${handle}${c.reset}${c.dim} — paste anywhere; they refresh as you work:${c.reset}`);
1096
+ console.log('');
1097
+ for (const line of liveMd(handle).split('\n')) console.log(` ${line}`);
1098
+ console.log('');
1099
+ console.log(` ${c.dim}Pick any metric:${c.reset} ${c.cyan}tokens · sessions · hours · streak${c.reset}`);
1100
+ console.log(` ${c.dim}One-click copy + shareable page:${c.reset} ${c.cyan}${site}/u/${handle}${c.reset}`);
1101
+ console.log(` ${c.dim}Straight to clipboard:${c.reset} ${c.cyan}claude-rpc readme --raw${c.reset}${c.dim} | pbcopy${c.reset}`);
1102
+ } else {
1103
+ console.log(` ${c.dim}A live, always-current badge needs a public profile. Turn one on:${c.reset}`);
1104
+ console.log(` ${c.cyan}claude-rpc profile set --handle <name> && claude-rpc profile on${c.reset}`);
1105
+ console.log('');
1106
+ console.log(` ${c.dim}Then your badges live here (self-refreshing — paste once):${c.reset}`);
1107
+ console.log(` ${c.cyan}${endpoint}/badge/<handle>.svg?metric=hours${c.reset}`);
1108
+ }
1109
+
1110
+ console.log('');
1111
+ console.log(` ${c.dim}── self-host on a GitHub gist instead (works without a profile) ──${c.reset}`);
1112
+ console.log(` ${c.cyan}claude-rpc badge --metric hours --gist${c.reset} ${c.dim}# prints README markdown${c.reset}`);
1113
+ console.log('');
1114
+ console.log(` ${c.dim}Shareable cards:${c.reset}`);
1115
+ console.log(` ${c.cyan}claude-rpc card --range year --out year.svg${c.reset} ${c.dim}# poster${c.reset}`);
1116
+ console.log(` ${c.cyan}claude-rpc calendar --gist${c.reset} ${c.dim}# live year heatmap${c.reset}`);
1117
+ console.log(` ${c.cyan}claude-rpc github-stat --gist${c.reset} ${c.dim}# profile stat card${c.reset}`);
1118
+ console.log('');
1119
+ }
1120
+
1060
1121
  // MCP server — expose stats to Claude Code over stdio. Long-running; never
1061
1122
  // writes to stdout except JSON-RPC frames.
1062
1123
  async function doMcp() {
@@ -1942,6 +2003,7 @@ function help() {
1942
2003
  ['statusline', 'One-line status for tmux/shell prompts (--template)'],
1943
2004
  ['calendar', 'Year activity heatmap SVG (--out --gist)'],
1944
2005
  ['session-card', 'Recap card for the current session (--out)'],
2006
+ ['readme', 'Paste-ready README badges for your profile (--raw to pipe)'],
1945
2007
  ['mcp install', 'Wire the stats MCP server into Claude Code (one command)'],
1946
2008
  ['mcp uninstall', 'Remove the stats MCP server from Claude Code'],
1947
2009
  ['mcp', 'Run the MCP server (stdio) — exposes your stats to Claude'],
@@ -2097,6 +2159,7 @@ process.on('unhandledRejection', (e) => {
2097
2159
  case 'statusline': doStatusline(process.argv.slice(3)); break;
2098
2160
  case 'calendar': await doCalendar(process.argv.slice(3)); break;
2099
2161
  case 'session-card': await doSessionCard(process.argv.slice(3)); break;
2162
+ case 'readme': doReadme(process.argv.slice(3)); break;
2100
2163
  case 'mcp': {
2101
2164
  const sub = process.argv[3];
2102
2165
  if (sub === 'install') { doMcpInstall(process.argv.slice(4)); break; }
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.21.0';
14
+ const BAKED = '0.22.0';
15
15
 
16
16
  function readPkgVersion() {
17
17
  try {