claude-rpc 0.7.0 → 0.7.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/README.md CHANGED
@@ -10,6 +10,10 @@
10
10
  **Discord Rich Presence for [Claude Code](https://claude.com/claude-code).**
11
11
  Your live model, project, current tool, tokens, and lifetime stats — in your Discord profile. Driven by the hooks Claude Code already fires. Zero polling between sessions.
12
12
 
13
+ [![community · sessions](https://claude-rpc-totals.claude-rpc.workers.dev/sessions.svg)](#community-totals)   [![community · tokens](https://claude-rpc-totals.claude-rpc.workers.dev/tokens.svg)](#community-totals)
14
+
15
+ <sub>live — on by default for fresh installs, opt out any time. see [community totals](#community-totals)</sub>
16
+
13
17
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
14
18
  [![Node 18+](https://img.shields.io/badge/node-%3E%3D18-43853d.svg?logo=node.js&logoColor=white)](https://nodejs.org)
15
19
  [![Claude Code](https://img.shields.io/badge/Claude%20Code-hooks-d97757.svg)](https://claude.com/claude-code)
@@ -123,23 +127,18 @@ Live equivalents when the daemon is up:
123
127
 
124
128
  Cost numbers come from `src/pricing.js`, seeded with **approximate** public list prices. Your actual Claude Code subscription bill is unrelated.
125
129
 
126
- ### community totals (opt-in)
127
-
128
- A small Cloudflare Worker ([`worker/`](worker/)) hosts running totals of sessions and tokens across every install that has opted in:
129
-
130
- ![sessions](https://claude-rpc-totals.claude-rpc.workers.dev/sessions.svg)
131
- ![tokens](https://claude-rpc-totals.claude-rpc.workers.dev/tokens.svg)
130
+ ### community totals
132
131
 
133
- The opt-in is per-install and **off by default**:
132
+ The badges at the top of this README are live, served by a small Cloudflare Worker ([`worker/`](worker/)) that holds running totals of sessions and tokens across every install that's reporting. As of v0.7 **fresh installs are on by default** — `setup` mints an anonymous UUID v4 and the daemon starts flushing deltas every 30 minutes. Existing users upgrading from a pre-v0.7 config stay off until they explicitly run `community on` (the consent flow prints the exact payload first).
134
133
 
135
134
  ```sh
136
- claude-rpc community # show state
137
- claude-rpc community on # opt in (consent flow + prints exact payload)
138
- claude-rpc community off # opt out
135
+ claude-rpc community # show state + instanceId (last 8 chars)
136
+ claude-rpc community off # opt out; instanceId retained for re-enable continuity
137
+ claude-rpc community on # explicit consent flow (upgraders / re-enable)
139
138
  claude-rpc community report # one-shot manual flush (testing)
140
139
  ```
141
140
 
142
- Each report sends only: a `sessionsDelta`, a `tokensDelta`, the claude-rpc version, OS family (`linux`/`darwin`/`win32`), and an anonymous UUID v4. No prompts, paths, models, repos, costs, usernames, or hostnames — the Worker's [`validateReport`](worker/src/index.js) is the schema of record. The full Worker source is in this repo so the privacy claim is auditable.
141
+ Each report sends only: a `sessionsDelta`, a `tokensDelta`, the claude-rpc version, OS family (`linux`/`darwin`/`win32`), and the anonymous UUID v4. No prompts, paths, models, repos, costs, usernames, or hostnames — the Worker's [`validateReport`](worker/src/index.js) is the schema of record. The full Worker source is in this repo so the privacy claim is auditable.
143
142
 
144
143
  ## three pieces, glued by json files
145
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-rpc",
3
- "version": "0.7.0",
3
+ "version": "0.7.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/cli.js CHANGED
@@ -800,13 +800,16 @@ function doPrivacy() {
800
800
 
801
801
  // ── Community totals ─────────────────────────────────────────────────────
802
802
  //
803
- // `claude-rpc community` → show current opt-in state + endpoint
803
+ // `claude-rpc community` → show current state + endpoint
804
804
  // `claude-rpc community on` → interactive consent flow, mint instanceId
805
+ // (used by pre-v0.7 upgraders; fresh installs
806
+ // already had setup mint the id)
805
807
  // `claude-rpc community off` → flip the flag off; instanceId retained
806
808
  // `claude-rpc community report` → one-shot manual flush (useful for testing)
807
809
  //
808
810
  // See src/community.js for the payload schema and worker/src/index.js
809
- // for the receiving end. The opt-in is per-install disabled by default.
811
+ // for the receiving end. As of v0.7 this is on by default for fresh
812
+ // installs and preserved-off for pre-v0.7 upgraders (see migrateConfig).
810
813
 
811
814
  function prompt(question) {
812
815
  return new Promise((resolve) => {
@@ -1019,8 +1022,8 @@ function overview() {
1019
1022
 
1020
1023
  function help() {
1021
1024
  const cmds = [
1022
- ['setup', 'Install Claude Code hooks (~/.claude/settings.json)'],
1023
- ['uninstall', 'Remove Claude Code hooks'],
1025
+ ['setup', 'Install Claude Code hooks + Windows startup entry (~/.claude/settings.json)'],
1026
+ ['uninstall', 'Remove Claude Code hooks + Windows startup entry'],
1024
1027
  ['upgrade-config', 'Re-run idempotent migrations on an existing config.json'],
1025
1028
  ['start', 'Start the Discord RPC daemon (detached)'],
1026
1029
  ['stop', 'Stop the daemon'],
@@ -1079,7 +1082,11 @@ const packagedDefault = IS_PACKAGED && !cmd;
1079
1082
  case '--help':
1080
1083
  case '-h':
1081
1084
  case 'help': help(); break;
1082
- case 'setup': await runInstall({ exePath: EXE_PATH || process.execPath, withStartup: false }); break;
1085
+ // `setup` and `install` are aliases as of v0.7: both register hooks AND
1086
+ // the Windows startup entry. Older behavior split them (setup = no
1087
+ // startup, install = with) but in practice users expect one command
1088
+ // to do everything. Non-Windows: addStartupEntry is a no-op + warning.
1089
+ case 'setup':
1083
1090
  case 'install': await runInstall({ exePath: EXE_PATH || process.execPath }); break;
1084
1091
  case 'uninstall': await runUninstall(); break;
1085
1092
  case 'upgrade-config': migrateConfig(); break;
package/src/community.js CHANGED
@@ -1,6 +1,9 @@
1
- // Opt-in community-totals client. Reads aggregate.json + a small cursor
2
- // file to compute counter DELTAs (not absolute values the cursor moves
3
- // forward as we report), then POSTs to the configured worker endpoint.
1
+ // Community-totals client. On by default for fresh installs (setup mints
2
+ // the instanceId into the seeded config); existing users upgrading from a
3
+ // pre-v0.7 config keep the explicit-opt-in flow via `claude-rpc community
4
+ // on`. Reads aggregate.json + a small cursor file to compute counter
5
+ // DELTAs (not absolute values — the cursor moves forward as we report),
6
+ // then POSTs to the configured worker endpoint.
4
7
  //
5
8
  // Three guarantees this module owes the rest of the codebase:
6
9
  //
@@ -39,13 +39,17 @@ export const DEFAULT_CONFIG = {
39
39
  filename: "claude.svg",
40
40
  public: true,
41
41
  },
42
- // Opt-in community totals. Disabled by default. `claude-rpc community on`
43
- // walks through the consent flow and flips `enabled`, mints an anonymous
44
- // instanceId (UUID v4), and the daemon starts batching deltas to the
45
- // endpoint. See worker/src/index.js for the receiving end and exactly
46
- // what payload is accepted (the validator there is the schema of record).
42
+ // Community totals. On by default for fresh installs — `setup` mints an
43
+ // anonymous instanceId (UUID v4) into the freshly-seeded config so the
44
+ // daemon starts batching deltas immediately. Existing users upgrading
45
+ // from a version without this block keep their old behavior: migrateConfig
46
+ // writes `community.enabled: false` into their file, and the consent flow
47
+ // at `claude-rpc community on` is the only path to enable. Opt out at any
48
+ // time with `claude-rpc community off`. See worker/src/index.js for the
49
+ // receiving end and exactly what payload is accepted (the validator there
50
+ // is the schema of record).
47
51
  community: {
48
- enabled: false,
52
+ enabled: true,
49
53
  instanceId: null,
50
54
  endpoint: "https://claude-rpc-totals.claude-rpc.workers.dev",
51
55
  flushIntervalMin: 30,
package/src/install.js CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  } from 'node:fs';
10
10
  import { dirname, join, resolve } from 'node:path';
11
11
  import { spawn, spawnSync } from 'node:child_process';
12
+ import { randomUUID } from 'node:crypto';
12
13
  import {
13
14
  CLAUDE_SETTINGS, CONFIG_PATH, USER_CONFIG_DIR, ROOT,
14
15
  HOOK_SCRIPT, IS_PACKAGED, IS_NPM_INSTALL,
@@ -211,8 +212,18 @@ export function seedConfig() {
211
212
  return false;
212
213
  }
213
214
  mkdirSync(USER_CONFIG_DIR, { recursive: true });
214
- writeFileSync(CONFIG_PATH, JSON.stringify(DEFAULT_CONFIG, null, 2));
215
+ // Fresh install: mint an anonymous instanceId so community.enabled:true
216
+ // (the new default in v0.7) is immediately actionable — the daemon needs
217
+ // an id to actually flush. Users who want out: `claude-rpc community off`.
218
+ const seeded = JSON.parse(JSON.stringify(DEFAULT_CONFIG));
219
+ if (seeded.community?.enabled && !seeded.community.instanceId) {
220
+ seeded.community.instanceId = randomUUID();
221
+ }
222
+ writeFileSync(CONFIG_PATH, JSON.stringify(seeded, null, 2));
215
223
  console.log(` config seeded → ${CONFIG_PATH}`);
224
+ if (seeded.community?.enabled && seeded.community.instanceId) {
225
+ console.log(` community totals on by default → opt out with \`claude-rpc community off\``);
226
+ }
216
227
  return true;
217
228
  }
218
229
 
@@ -279,6 +290,16 @@ export function migrateConfig() {
279
290
  added.push('presence.byStatus.thinking.state');
280
291
  }
281
292
 
293
+ // v0.7: community.enabled flipped to true in DEFAULT_CONFIG. For users
294
+ // upgrading from a version without a community block, we must NOT
295
+ // silently turn telemetry on — write an explicit `enabled: false` so
296
+ // the deep-merge in loadConfig sees their opt-out. They can run
297
+ // `claude-rpc community on` to consent.
298
+ if (!cfg.community) {
299
+ cfg.community = { enabled: false };
300
+ added.push('community (preserved-off)');
301
+ }
302
+
282
303
  if (added.length === 0) {
283
304
  console.log(` config up to date → ${CONFIG_PATH}`);
284
305
  return false;
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.7.0';
14
+ const BAKED = '0.7.1';
15
15
 
16
16
  function readPkgVersion() {
17
17
  try {