claude-rpc 1.3.1 → 1.4.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 +1 -1
- package/SECURITY.md +10 -0
- package/package.json +1 -1
- package/src/cli.js +109 -20
- package/src/gist.js +10 -0
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ claude-rpc setup
|
|
|
72
72
|
|
|
73
73
|
That's the whole pitch.
|
|
74
74
|
|
|
75
|
-
> `setup` registers a Windows startup entry and wires hooks into Claude Code's `settings.json`, and the daemon reports anonymous totals by default. All of it is reversible (`claude-rpc uninstall`, `community off`) and fully documented in [`SECURITY.md`](SECURITY.md) — read it first if you want to know exactly what runs.
|
|
75
|
+
> `setup` registers a Windows startup entry and wires hooks into Claude Code's `settings.json`, and the daemon reports anonymous totals by default. It ends with one optional y/N — *connect GitHub?* — which publishes a verified public [leaderboard](https://claude-rpc.com/leaderboard) profile only if you say yes (asked once; Enter skips). All of it is reversible (`claude-rpc uninstall`, `community off`, `profile off`) and fully documented in [`SECURITY.md`](SECURITY.md) — read it first if you want to know exactly what runs.
|
|
76
76
|
|
|
77
77
|
The Discord *desktop* app must be running. The browser client doesn't expose the local IPC bridge that Rich Presence uses.
|
|
78
78
|
|
package/SECURITY.md
CHANGED
|
@@ -208,6 +208,16 @@ anonymous 3a report, this one carries your chosen public identity. The
|
|
|
208
208
|
It sends absolute totals (not deltas) and is idempotent worker-side (a SET, not
|
|
209
209
|
an add). `profile off` stops it.
|
|
210
210
|
|
|
211
|
+
**The setup-time "connect GitHub?" question.** Since v1.4, an interactive
|
|
212
|
+
`claude-rpc setup` ends with one explicit y/N: *connect GitHub?* Answering
|
|
213
|
+
**y** runs the standard opt-in flow above (public profile, handle defaulting
|
|
214
|
+
to your GitHub login, gist verification) — nothing beyond that flow's
|
|
215
|
+
documented payload. Answering **n** (or Enter, the default) sends nothing and
|
|
216
|
+
stores only a local `ghConnectAsked` marker so setup never asks again;
|
|
217
|
+
non-interactive setups are never asked. There is no private identity tier:
|
|
218
|
+
the only way claude-rpc ever learns a GitHub identity is this same public,
|
|
219
|
+
consented profile flow.
|
|
220
|
+
|
|
211
221
|
**Claude Wrapped (opt-in one-shot, never automatic).** `claude-rpc wrapped
|
|
212
222
|
--publish` publishes a year-in-review blob under your profile handle to
|
|
213
223
|
`<endpoint>/wrapped`, rendered at `claude-rpc.com/wrapped/<handle>`. It never
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -2001,28 +2001,26 @@ async function profilePublish() {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
}
|
|
2003
2003
|
|
|
2004
|
-
//
|
|
2005
|
-
//
|
|
2006
|
-
|
|
2007
|
-
|
|
2004
|
+
// The gist-verification dance shared by `profile verify` and setup's optional
|
|
2005
|
+
// GitHub-connect question: worker token → public proof gist → worker check →
|
|
2006
|
+
// persist the verified identity locally. Prints its own progress lines (they
|
|
2007
|
+
// read the same in both contexts) and returns { ok, who } on success. It never
|
|
2008
|
+
// exits: hard failures come back as { ok: false, fatal: {label, hint, code} }
|
|
2009
|
+
// so profileVerify can fail() loudly while setup — where the whole step is
|
|
2010
|
+
// optional — shrugs and finishes the install.
|
|
2011
|
+
async function gistVerifyDance(cfg) {
|
|
2008
2012
|
const profile = cfg.profile || {};
|
|
2009
2013
|
const community = cfg.community || {};
|
|
2010
|
-
// No --github required up front: the worker treats it as a hint only and
|
|
2011
|
-
// takes the authoritative identity from whoever owns the proof gist —
|
|
2012
|
-
// and publishing that gist already requires gh auth, so the account is
|
|
2013
|
-
// known by the time it matters.
|
|
2014
|
-
if (!profile.githubUser) {
|
|
2015
|
-
console.log(` ${c.dim}no --github set — your verified identity will be the account that owns the proof gist${c.reset}`);
|
|
2016
|
-
}
|
|
2017
2014
|
if (!community.instanceId) {
|
|
2018
|
-
return
|
|
2015
|
+
return { ok: false, fatal: { label: 'enable the profile first', hint: 'claude-rpc profile on', code: EX_BAD_STATE } };
|
|
2019
2016
|
}
|
|
2020
2017
|
const endpoint = (community.endpoint || '').replace(/\/+$/, '');
|
|
2021
2018
|
if (!endpoint) {
|
|
2022
|
-
return
|
|
2019
|
+
return { ok: false, fatal: {
|
|
2020
|
+
label: 'no community endpoint configured',
|
|
2023
2021
|
hint: 'config.json is missing community.endpoint — re-run `claude-rpc setup` to restore the default',
|
|
2024
2022
|
code: EX_BAD_STATE,
|
|
2025
|
-
}
|
|
2023
|
+
} };
|
|
2026
2024
|
}
|
|
2027
2025
|
|
|
2028
2026
|
const post = async (path, body) => {
|
|
@@ -2043,7 +2041,9 @@ async function profileVerify() {
|
|
|
2043
2041
|
}
|
|
2044
2042
|
console.log(` ${c.dim}requesting a verification token…${c.reset}`);
|
|
2045
2043
|
const start = await post('/verify/start', { instanceId: community.instanceId, githubUser: profile.githubUser || null });
|
|
2046
|
-
if (!start.json?.token)
|
|
2044
|
+
if (!start.json?.token) {
|
|
2045
|
+
return { ok: false, fatal: { label: `verify/start failed: ${start.json?.error || start.status}`, code: EX_SYS_ERROR } };
|
|
2046
|
+
}
|
|
2047
2047
|
const token = start.json.token;
|
|
2048
2048
|
|
|
2049
2049
|
const { publishGistFile } = await import('./gist.js');
|
|
@@ -2071,14 +2071,100 @@ async function profileVerify() {
|
|
|
2071
2071
|
if (who && profile.githubUser && who.toLowerCase() !== profile.githubUser.toLowerCase()) {
|
|
2072
2072
|
console.log(` ${c.dim}(your gist is owned by @${who}, so the profile now uses that account)${c.reset}`);
|
|
2073
2073
|
}
|
|
2074
|
-
|
|
2075
|
-
console.log(` ${c.yellow}!${c.reset} not confirmed: ${check.json?.error || check.status}`);
|
|
2076
|
-
console.log(` ${c.dim}↳ make sure the gist is public, then re-run ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
|
|
2074
|
+
return { ok: true, who };
|
|
2077
2075
|
}
|
|
2076
|
+
// Soft outcome (matches historical behavior): the message tells the user
|
|
2077
|
+
// how to finish, and the process still exits 0.
|
|
2078
|
+
console.log(` ${c.yellow}!${c.reset} not confirmed: ${check.json?.error || check.status}`);
|
|
2079
|
+
console.log(` ${c.dim}↳ make sure the gist is public, then re-run ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
|
|
2080
|
+
return { ok: false };
|
|
2078
2081
|
} catch (e) {
|
|
2079
|
-
return
|
|
2082
|
+
return { ok: false, fatal: {
|
|
2083
|
+
label: `verification failed: ${e.message}`,
|
|
2080
2084
|
hint: 'needs `gh` logged in or GH_TOKEN with gist scope', code: EX_SYS_ERROR,
|
|
2081
|
-
}
|
|
2085
|
+
} };
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// GitHub verification: ask the worker for a one-time token, publish it in a
|
|
2090
|
+
// public gist (reusing the gist helper), then have the worker confirm it.
|
|
2091
|
+
async function profileVerify() {
|
|
2092
|
+
const cfg = loadConfig();
|
|
2093
|
+
// No --github required up front: the worker treats it as a hint only and
|
|
2094
|
+
// takes the authoritative identity from whoever owns the proof gist —
|
|
2095
|
+
// and publishing that gist already requires gh auth, so the account is
|
|
2096
|
+
// known by the time it matters.
|
|
2097
|
+
if (!cfg.profile?.githubUser) {
|
|
2098
|
+
console.log(` ${c.dim}no --github set — your verified identity will be the account that owns the proof gist${c.reset}`);
|
|
2099
|
+
}
|
|
2100
|
+
const r = await gistVerifyDance(cfg);
|
|
2101
|
+
if (r.fatal) return fail(r.fatal.label, { hint: r.fatal.hint || '', code: r.fatal.code });
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
// ── Setup-time GitHub connect ────────────────────────────────────────────
|
|
2105
|
+
// One explicit y/N at the end of `setup`, asked at most once ever (the answer
|
|
2106
|
+
// is remembered either way, and `claude-rpc link` / `profile verify` stay
|
|
2107
|
+
// available whenever). Saying y publishes a verified PUBLIC profile — handle
|
|
2108
|
+
// defaulting to the GitHub login — because that is the only "connected" state
|
|
2109
|
+
// the worker has: there is deliberately no silent or private identity tier
|
|
2110
|
+
// (SECURITY.md documents this). Declining changes nothing.
|
|
2111
|
+
async function setupGhConnect() {
|
|
2112
|
+
const cfg = loadConfig();
|
|
2113
|
+
if (cfg.profile?.verified) return; // already connected
|
|
2114
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) return; // piped/CI setup — never block on a prompt
|
|
2115
|
+
if (!cfg.community?.instanceId) return; // no identity minted (dev tree) — nothing to verify
|
|
2116
|
+
if (readJson(CONFIG_PATH, {}).profile?.ghConnectAsked) return;
|
|
2117
|
+
|
|
2118
|
+
console.log('');
|
|
2119
|
+
console.log(` ${c.bold}connect GitHub?${c.reset} ${c.dim}optional — asked once, everything works without it${c.reset}`);
|
|
2120
|
+
console.log(` ${c.green}·${c.reset} verifies this install as your GitHub account ${c.dim}(public proof gist via the ${c.reset}gh${c.dim} CLI)${c.reset}`);
|
|
2121
|
+
console.log(` ${c.green}·${c.reset} publishes a ${c.bold}public${c.reset} profile at ${c.cyan}claude-rpc.com/u/<your-login>${c.reset} with the verified ✓`);
|
|
2122
|
+
console.log(` ${c.dim}totals only — tokens · sessions · hours · streak; never prompts, paths, or project names${c.reset}`);
|
|
2123
|
+
const answer = (await prompt(` connect? ${c.dim}[y/N]${c.reset} `)).trim();
|
|
2124
|
+
|
|
2125
|
+
// Remember that we asked before acting on the answer — setup never nags.
|
|
2126
|
+
const userCfg = readJson(CONFIG_PATH, {});
|
|
2127
|
+
userCfg.profile = { ...(userCfg.profile || {}), ghConnectAsked: true };
|
|
2128
|
+
writeUserConfig(userCfg);
|
|
2129
|
+
|
|
2130
|
+
if (!/^y(es)?$/i.test(answer)) {
|
|
2131
|
+
console.log(` ${c.dim}skipped — connect later with ${c.reset}${c.cyan}claude-rpc link${c.reset}${c.dim} or ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
const { ghLogin } = await import('./gist.js');
|
|
2136
|
+
const login = lb.normalizeGithubUser(ghLogin());
|
|
2137
|
+
if (!login) {
|
|
2138
|
+
console.log(` ${c.yellow}!${c.reset} no logged-in ${c.cyan}gh${c.reset} CLI found — two ways to finish:`);
|
|
2139
|
+
console.log(` ${c.dim}browser: log in at${c.reset} ${c.cyan}${LINK_PAGE}${c.reset} ${c.dim}and paste the${c.reset} ${c.cyan}claude-rpc link <code>${c.reset} ${c.dim}it shows${c.reset}`);
|
|
2140
|
+
console.log(` ${c.dim}terminal:${c.reset} ${c.cyan}gh auth login${c.reset} ${c.dim}then${c.reset} ${c.cyan}claude-rpc profile verify${c.reset}`);
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// Seed the local profile: handle defaults to the GitHub login (renameable
|
|
2145
|
+
// any time with `profile set --handle`), publishing on so the daemon keeps
|
|
2146
|
+
// the board row fresh from here out.
|
|
2147
|
+
const handle = lb.isValidHandle(userCfg.profile?.handle) ? userCfg.profile.handle : lb.normalizeHandle(login);
|
|
2148
|
+
if (!handle) {
|
|
2149
|
+
console.log(` ${c.yellow}!${c.reset} couldn't derive a handle from @${login} — run ${c.cyan}claude-rpc profile set --handle <you>${c.reset} then ${c.cyan}claude-rpc profile verify${c.reset}`);
|
|
2150
|
+
return;
|
|
2151
|
+
}
|
|
2152
|
+
userCfg.profile = { ...userCfg.profile, handle, githubUser: login, enabled: true };
|
|
2153
|
+
writeUserConfig(userCfg);
|
|
2154
|
+
console.log(` ${c.dim}connecting as ${c.reset}${c.cyan}@${login}${c.reset}${c.dim} — handle ${c.reset}${c.cyan}${handle}${c.reset}`);
|
|
2155
|
+
|
|
2156
|
+
// A fresh install has no aggregate yet; publish real totals, not zeros.
|
|
2157
|
+
if (!readAggregate()?.sessions) {
|
|
2158
|
+
console.log(` ${c.dim}first scan — counting your history…${c.reset}`);
|
|
2159
|
+
doScan(false);
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
const r = await gistVerifyDance(loadConfig());
|
|
2163
|
+
if (r.ok) {
|
|
2164
|
+
console.log(` ${c.green}✓${c.reset} you're live at ${c.cyan}https://claude-rpc.com/u/${encodeURIComponent(handle)}${c.reset}`);
|
|
2165
|
+
} else {
|
|
2166
|
+
if (r.fatal) console.log(` ${c.yellow}!${c.reset} ${r.fatal.label}`);
|
|
2167
|
+
console.log(` ${c.dim}↳ setup itself is done — retry with ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
|
|
2082
2168
|
}
|
|
2083
2169
|
}
|
|
2084
2170
|
|
|
@@ -2452,6 +2538,9 @@ process.on('unhandledRejection', (e) => {
|
|
|
2452
2538
|
} else if (argv.includes('--wrapped')) {
|
|
2453
2539
|
console.log(` ${c.yellow}!${c.reset} --wrapped needs a profile — pair it with --link <code>, or run \`claude-rpc wrapped --publish\` after setup`);
|
|
2454
2540
|
}
|
|
2541
|
+
// Optional GitHub connect — one explicit y/N, asked at most once ever.
|
|
2542
|
+
// The --link path above IS a connect, so it never double-asks.
|
|
2543
|
+
if (!linkCode) await setupGhConnect();
|
|
2455
2544
|
}
|
|
2456
2545
|
setupOutro(target, changed);
|
|
2457
2546
|
break;
|
package/src/gist.js
CHANGED
|
@@ -73,6 +73,16 @@ export function hasGh() {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// The login of the account `gh` is authed as, or null when gh is missing or
|
|
77
|
+
// logged out. `gh api user` needs auth, so a non-zero status covers both.
|
|
78
|
+
export function ghLogin() {
|
|
79
|
+
try {
|
|
80
|
+
const r = gh(['api', 'user', '--jq', '.login'], { encoding: 'utf8' });
|
|
81
|
+
if (r.status === 0) return (r.stdout || '').trim() || null;
|
|
82
|
+
} catch { /* same "not available" signals as hasGh */ }
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
function ghCreate(filePath, description, isPublic) {
|
|
77
87
|
const args = ['gist', 'create', filePath, '--desc', description];
|
|
78
88
|
if (isPublic) args.push('--public');
|