claude-rpc 1.8.0 → 1.10.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 -2
- package/SECURITY.md +18 -13
- package/package.json +1 -1
- package/src/cli.js +175 -167
- package/src/commands.js +0 -2
- package/src/community.js +50 -4
- package/src/daemon.js +120 -30
- package/src/doctor.js +23 -1
- package/src/ensure-daemon.js +155 -8
- package/src/feature-usage.js +78 -0
- package/src/install.js +38 -2
- package/src/paths.js +9 -0
- package/src/server/settings.js +9 -16
- package/src/tui.js +3 -2
- package/src/updater.js +119 -8
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -205,7 +205,7 @@ claude-rpc community on # explicit consent flow (upgraders / re-enable
|
|
|
205
205
|
claude-rpc community report # one-shot manual flush (testing)
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
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. Every worker route — path, params, response — is documented in [`docs/WORKER-API.md`](docs/WORKER-API.md).
|
|
208
|
+
Each report sends only: a `sessionsDelta`, a `tokensDelta`, the claude-rpc version, OS family (`linux`/`darwin`/`win32`), how it was installed (npm / npx / brew / exe), how its last auto-update went, the names of claude-rpc commands you used in the last 7 days, 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. Every worker route — path, params, response — is documented in [`docs/WORKER-API.md`](docs/WORKER-API.md).
|
|
209
209
|
|
|
210
210
|
For a complete account of the sensitive things claude-rpc does — startup persistence, hook injection, every outbound request, and the exact telemetry payload — see [`SECURITY.md`](SECURITY.md). It's also the reference for supply-chain scanner findings (Socket.dev et al.): the flagged persistence and hook-injection behaviors are inherent to the tool and documented there.
|
|
211
211
|
|
|
@@ -338,7 +338,6 @@ It's a thin bootstrapper — on the first session it just runs `npx claude-rpc@l
|
|
|
338
338
|
| `pause [30m\|2h\|off\|status]` | Hide the card everywhere for a while (default 1h) |
|
|
339
339
|
| **Online** | |
|
|
340
340
|
| `profile` | Opt-in public leaderboard profile: `status` \| `set` \| `on` \| `off` \| `publish` \| `verify` |
|
|
341
|
-
| `squad` | Private mini-leaderboards with friends: `status` \| `create <name>` \| `join <code>` \| `leave [id]` |
|
|
342
341
|
| `link [code]` | One profile across machines: `link` mints a code on your verified machine, `link <code>` claims it on the new one |
|
|
343
342
|
| `community` | Anonymous community totals, on by default for fresh installs: `status` \| `off` \| `on` \| `report` |
|
|
344
343
|
| **Daemon** | |
|
package/SECURITY.md
CHANGED
|
@@ -138,7 +138,7 @@ described under **Scope** below.
|
|
|
138
138
|
## 3. Outbound network
|
|
139
139
|
|
|
140
140
|
There are seven distinct network behaviors: community totals (3a), gist
|
|
141
|
-
publishing (3b),
|
|
141
|
+
publishing (3b), web login & the public profile (3c), subscription-usage polling (3d),
|
|
142
142
|
the cosmetic GIF assets (3e), the opt-in status webhook (3f), and the
|
|
143
143
|
CLI auto-update check (3h). Each is independently optional. The separate
|
|
144
144
|
desktop dashboard app, if installed, additionally auto-updates itself (3g).
|
|
@@ -159,12 +159,23 @@ The **complete** payload (see `buildPayload`, enforced by the Worker's
|
|
|
159
159
|
"instanceId": "<random UUID v4>",
|
|
160
160
|
"sessionsDelta": 3,
|
|
161
161
|
"tokensDelta": 142000,
|
|
162
|
-
"version": "
|
|
162
|
+
"version": "1.10.0",
|
|
163
163
|
"osFamily": "win32",
|
|
164
|
+
"install": "packaged",
|
|
165
|
+
"upd": "ok",
|
|
166
|
+
"feat": ["settings", "status", "tui"],
|
|
164
167
|
"ts": 1716500000000
|
|
165
168
|
}
|
|
166
169
|
```
|
|
167
170
|
|
|
171
|
+
The last three (1.10+, `usageFacts` in `src/community.js`, allowlisted by the
|
|
172
|
+
Worker's `usageFields`) say how this copy was installed (`npm-global` / `npx` /
|
|
173
|
+
`brew` / `packaged` / `dev`), how its last auto-update went (`ok` / `off` /
|
|
174
|
+
`manual` / `perm` / `failed` / `pending` / `unknown`), and the **names** of
|
|
175
|
+
claude-rpc commands used on this machine in the last 7 days. Never arguments,
|
|
176
|
+
counts, or timestamps. The local record is `feature-usage.json` in the state
|
|
177
|
+
directory (command name → last-used time).
|
|
178
|
+
|
|
168
179
|
What is **not** sent, ever: prompts, responses, file paths, file contents,
|
|
169
180
|
project/repo names, models, cost figures, usernames, hostnames, IP (beyond what
|
|
170
181
|
any HTTP request inherently exposes to Cloudflare's edge), or absolute counter
|
|
@@ -178,7 +189,7 @@ values — only forward deltas since the last accepted report.
|
|
|
178
189
|
The trade-off is disclosed here, in the README, and at install time.
|
|
179
190
|
- **Auditable:** for these reports the Worker persists only one
|
|
180
191
|
`total:counters` value (the two running sums, `{sessions, tokens}`), a
|
|
181
|
-
30-day `seen:<instanceId>` active-install marker (`{ts, version, osFamily}`,
|
|
192
|
+
30-day `seen:<instanceId>` active-install marker (`{ts, version, osFamily, install, upd, feat}`,
|
|
182
193
|
refreshed at most daily), and rate-limit keys that expire within a minute.
|
|
183
194
|
The source is in this repo.
|
|
184
195
|
|
|
@@ -190,13 +201,9 @@ Publishes a badge SVG to *your own* GitHub gist via the `gh` CLI or a
|
|
|
190
201
|
`gist.github.com`. Never runs unattended, never on install, never from the
|
|
191
202
|
daemon.
|
|
192
203
|
|
|
193
|
-
### 3c.
|
|
204
|
+
### 3c. Web login & public profile — opt-in
|
|
194
205
|
|
|
195
|
-
**Source:** `worker/src/index.js` (+ `worker/src/auth.js`), `
|
|
196
|
-
(`squad` command), `site/squad.html`. Squads are private mini-leaderboards
|
|
197
|
-
that regroup stats you **already publish** via the opt-in profile — joining
|
|
198
|
-
one sends nothing new from your machine; the worker derives weekly standings
|
|
199
|
-
from the same clamped lifetime totals the public board uses.
|
|
206
|
+
**Source:** `worker/src/index.js` (+ `worker/src/auth.js`), `site/link.html`.
|
|
200
207
|
|
|
201
208
|
"Log in with GitHub" on the website is plain OAuth (no scopes — public
|
|
202
209
|
identity only; we never see email or repos). Sessions are stateless signed
|
|
@@ -204,9 +211,7 @@ tokens holding **only your public GitHub login**, stored in your browser's
|
|
|
204
211
|
localStorage and expiring after 7 days. The browser never receives an
|
|
205
212
|
`instanceId` — that remains the CLI's local credential; the worker resolves
|
|
206
213
|
GitHub login → profile via the link your own gist verification created.
|
|
207
|
-
Worker-side storage adds: `gh:<login>` → profile link
|
|
208
|
-
records, and weekly baseline snapshots (auto-expiring). Leaving your last
|
|
209
|
-
squad deletes its record.
|
|
214
|
+
Worker-side storage adds: `gh:<login>` → profile link.
|
|
210
215
|
|
|
211
216
|
When the opt-in public profile is enabled (`profile on` + a handle), the daemon
|
|
212
217
|
also POSTs to `<endpoint>/profile` on the same 30-minute timer. Unlike the
|
|
@@ -469,7 +474,7 @@ aggregates; it never writes there.
|
|
|
469
474
|
|
|
470
475
|
None of these files is uploaded. What leaves your machine is exactly what §3
|
|
471
476
|
lists: the anonymous counters (3a, on by default); the public profile, its
|
|
472
|
-
per-day heatmap series
|
|
477
|
+
per-day heatmap series and Wrapped (3c — opt-in); gist badges (3b) and
|
|
473
478
|
the status webhook (3f), only when you set them up; and for the usage poll
|
|
474
479
|
(3d) your own Claude Code OAuth token, sent only to `api.anthropic.com`.
|
|
475
480
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -5,11 +5,12 @@ import './safe-stdio.js';
|
|
|
5
5
|
import { readFileSync, writeFileSync, existsSync, watchFile, unlinkSync } from 'node:fs';
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
import { basename, join } from 'node:path';
|
|
8
|
-
import { DAEMON_SCRIPT, STATE_PATH, STATE_DIR, LOG_PATH, AGGREGATE_PATH, CONFIG_PATH, USER_CONFIG_DIR, IS_PACKAGED, IS_NPX, EXE_PATH } from './paths.js';
|
|
8
|
+
import { DAEMON_SCRIPT, STATE_PATH, STATE_DIR, LOG_PATH, AGGREGATE_PATH, CONFIG_PATH, USER_CONFIG_DIR, IS_PACKAGED, IS_NPX, EXE_PATH, ROOT } from './paths.js';
|
|
9
9
|
import { VERSION } from './version.js';
|
|
10
10
|
import { c, fail, tailLines, heat, sparkline, fmtDelta, topPercentile, EX_USER_ERROR, EX_BAD_STATE, EX_SYS_ERROR } from './ui.js';
|
|
11
11
|
import * as lb from './leaderboard.js';
|
|
12
12
|
import { writeFileAtomic } from './atomic-rename.js';
|
|
13
|
+
import { stampFeature } from './feature-usage.js';
|
|
13
14
|
|
|
14
15
|
// ── Lazy-loaded module graph ─────────────────────────────────────────────────
|
|
15
16
|
// Only the static imports above (all cheap) load up front, so --version,
|
|
@@ -21,13 +22,14 @@ import { writeFileAtomic } from './atomic-rename.js';
|
|
|
21
22
|
// node:crypto, node:readline, node:child_process) are imported inside that
|
|
22
23
|
// command's handler, like doctor.js/card.js/mcp.js always were.
|
|
23
24
|
let readActiveState, statePathFor, loadConfig, hasUserConfig, spawnDaemonDetached, daemonAlive;
|
|
25
|
+
let stopDaemonAndWait, markStopped, clearStopped, isStopped, readDaemonInfo, shouldReplaceDaemon;
|
|
24
26
|
let buildVars, fillTemplate, humanProject, humanTool, applyIdle, framePasses, fmtNum, fmtHours;
|
|
25
27
|
let scan, readAggregate, findLiveSessions, dayKey, weekKey;
|
|
26
28
|
let fmtCost;
|
|
27
29
|
let readUsageCache, fetchUsage, writeUsageCache, fmtResetTime, fmtResetDay;
|
|
28
30
|
|
|
29
31
|
async function loadDaemonCtl() {
|
|
30
|
-
({ spawnDaemonDetached, daemonAlive } = await import('./ensure-daemon.js'));
|
|
32
|
+
({ spawnDaemonDetached, daemonAlive, stopDaemonAndWait, markStopped, clearStopped, isStopped, readDaemonInfo, shouldReplaceDaemon } = await import('./ensure-daemon.js'));
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
// Idempotent — repeat imports resolve from the module cache.
|
|
@@ -91,7 +93,19 @@ function splitEqArgs(argv) {
|
|
|
91
93
|
return out;
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
// " · v1.8.0 (update installed — restarting)" when the running daemon is not
|
|
97
|
+
// this copy's version, so a stale daemon is visible instead of silent.
|
|
98
|
+
function daemonVersionNote(pid) {
|
|
99
|
+
const info = readDaemonInfo();
|
|
100
|
+
if (!info || info.pid !== pid) return `${c.dim} · version unknown (pre-1.9 daemon — claude-rpc restart)${c.reset}`;
|
|
101
|
+
if (info.version === VERSION) return '';
|
|
102
|
+
return `${c.yellow} · running v${info.version}, installed v${VERSION} — claude-rpc restart${c.reset}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// An explicit start always clears a previous `stop` (the marker every launcher
|
|
106
|
+
// honors), so `start` after `stop` behaves the way it reads.
|
|
94
107
|
function startDaemon({ quiet = false } = {}) {
|
|
108
|
+
clearStopped();
|
|
95
109
|
const pid = daemonAlive();
|
|
96
110
|
if (pid) {
|
|
97
111
|
if (!quiet) console.log(` ${c.yellow}!${c.reset} ${'daemon running'.padEnd(16)}${c.dim}already up (pid ${pid}) · bounce it with ${c.reset}${c.cyan}claude-rpc restart${c.reset}`);
|
|
@@ -130,41 +144,40 @@ async function confirmDaemonUp({ timeoutMs = 3000, intervalMs = 100 } = {}) {
|
|
|
130
144
|
}
|
|
131
145
|
}
|
|
132
146
|
|
|
133
|
-
|
|
147
|
+
// `stop` is durable: the marker keeps the SessionStart hook, the login
|
|
148
|
+
// autostart and any straggler daemon from bringing it back until `start`.
|
|
149
|
+
// Waits for the process to actually exit (hard-kill after 3s) instead of
|
|
150
|
+
// reporting success for a signal that may not have landed.
|
|
151
|
+
async function stopDaemon({ quiet = false } = {}) {
|
|
152
|
+
markStopped();
|
|
134
153
|
const pid = daemonAlive();
|
|
135
|
-
if (!pid) {
|
|
136
|
-
|
|
137
|
-
process.kill(pid, 'SIGTERM');
|
|
138
|
-
if (!quiet) console.log(` ${c.green}✓${c.reset} ${'daemon stopping'.padEnd(16)}${c.dim}sent SIGTERM to pid ${pid}${c.reset}`);
|
|
154
|
+
if (!pid) {
|
|
155
|
+
if (!quiet) console.log(` ${c.cyan}·${c.reset} ${'daemon stopped'.padEnd(16)}${c.dim}wasn't running · stays off until ${c.reset}${c.cyan}claude-rpc start${c.reset}`);
|
|
139
156
|
return true;
|
|
140
|
-
} catch (e) {
|
|
141
|
-
if (!quiet) console.log(` ${c.red}✗${c.reset} ${'stop failed'.padEnd(16)}${c.dim}${e.message}${c.reset}`);
|
|
142
|
-
return false;
|
|
143
157
|
}
|
|
158
|
+
const ok = await stopDaemonAndWait();
|
|
159
|
+
if (quiet) return ok;
|
|
160
|
+
if (ok) console.log(` ${c.green}✓${c.reset} ${'daemon stopped'.padEnd(16)}${c.dim}pid ${pid} · stays off until ${c.reset}${c.cyan}claude-rpc start${c.reset}`);
|
|
161
|
+
else console.log(` ${c.red}✗${c.reset} ${'stop failed'.padEnd(16)}${c.dim}pid ${pid} is still running — it will exit at its next check (≤30s)${c.reset}`);
|
|
162
|
+
return ok;
|
|
144
163
|
}
|
|
145
164
|
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
function restartDaemon() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
setTimeout(tick, 50);
|
|
165
|
-
};
|
|
166
|
-
setTimeout(tick, 50);
|
|
167
|
-
});
|
|
165
|
+
// Stop (and wait for) the running daemon, then start a fresh one. Resolves
|
|
166
|
+
// once the replacement has been spawned (true) or couldn't be (false).
|
|
167
|
+
async function restartDaemon() {
|
|
168
|
+
clearStopped();
|
|
169
|
+
await stopDaemonAndWait();
|
|
170
|
+
return startDaemon();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// After an update the running daemon still executes the OLD code. setup (and
|
|
174
|
+
// the desktop app's post-update setup) replaces a daemon older than this copy,
|
|
175
|
+
// or one too old to report its version.
|
|
176
|
+
async function replaceOutdatedDaemon() {
|
|
177
|
+
const pid = daemonAlive();
|
|
178
|
+
if (!pid || !shouldReplaceDaemon({ info: readDaemonInfo(), pid, version: VERSION })) return false;
|
|
179
|
+
await stopDaemonAndWait();
|
|
180
|
+
return true;
|
|
168
181
|
}
|
|
169
182
|
|
|
170
183
|
// ── Box drawing — auto-widens to fit longest line ────────────────────────────
|
|
@@ -422,7 +435,8 @@ async function showStatus() {
|
|
|
422
435
|
console.log('');
|
|
423
436
|
|
|
424
437
|
box('daemon', [
|
|
425
|
-
pair('status', pid ? `${c.green}● running${c.reset} pid ${pid}
|
|
438
|
+
pair('status', pid ? `${c.green}● running${c.reset} pid ${pid}${daemonVersionNote(pid)}`
|
|
439
|
+
: isStopped() ? `${c.yellow}○ stopped${c.reset} ${c.dim}(claude-rpc start to resume)${c.reset}` : `${c.red}○ not running${c.reset}`, ''),
|
|
426
440
|
pair('client', config.clientId || '—'),
|
|
427
441
|
pair('config', shortPath(CONFIG_PATH), c.gray),
|
|
428
442
|
// The file behind the session shown below (hooks write one per session),
|
|
@@ -1393,16 +1407,22 @@ async function doExport(argv) {
|
|
|
1393
1407
|
emit(payload, out, { note: `${payload.length} bytes, ${csv ? 'CSV' : 'JSON'}` });
|
|
1394
1408
|
}
|
|
1395
1409
|
|
|
1396
|
-
// ──
|
|
1410
|
+
// ── Link (one profile across machines) ───────────────────────────────────
|
|
1397
1411
|
//
|
|
1398
|
-
//
|
|
1399
|
-
//
|
|
1400
|
-
//
|
|
1401
|
-
//
|
|
1402
|
-
//
|
|
1403
|
-
//
|
|
1404
|
-
|
|
1405
|
-
|
|
1412
|
+
// Two-sided by design — one verb owns the whole story:
|
|
1413
|
+
// claude-rpc link on your MAIN (verified) machine → mints a
|
|
1414
|
+
// one-time code, no browser needed
|
|
1415
|
+
// claude-rpc link <code> on the NEW machine → claims it, merging this
|
|
1416
|
+
// install into the same leaderboard identity
|
|
1417
|
+
// The browser fallback lives at claude-rpc.com/link (log in with
|
|
1418
|
+
// GitHub → same code) for when the other machine isn't handy. Claiming
|
|
1419
|
+
// verifies the profile (✓).
|
|
1420
|
+
|
|
1421
|
+
const LINK_PAGE = 'https://claude-rpc.com/link';
|
|
1422
|
+
|
|
1423
|
+
// Authenticated worker calls for this machine: the community instanceId is
|
|
1424
|
+
// the credential (the browser path uses a GitHub session instead).
|
|
1425
|
+
function identityAuth() {
|
|
1406
1426
|
const cfg = loadConfig();
|
|
1407
1427
|
const endpoint = (cfg.community?.endpoint || '').replace(/\/+$/, '');
|
|
1408
1428
|
const instanceId = cfg.community?.instanceId;
|
|
@@ -1413,7 +1433,7 @@ function squadAuth() {
|
|
|
1413
1433
|
});
|
|
1414
1434
|
}
|
|
1415
1435
|
if (!instanceId) {
|
|
1416
|
-
fail('
|
|
1436
|
+
fail('linking needs an identity', {
|
|
1417
1437
|
hint: 'run `claude-rpc profile set --handle <name> && claude-rpc profile on` first',
|
|
1418
1438
|
code: EX_BAD_STATE,
|
|
1419
1439
|
});
|
|
@@ -1423,7 +1443,7 @@ function squadAuth() {
|
|
|
1423
1443
|
try {
|
|
1424
1444
|
res = await fetch(endpoint + path, { ...init, signal: AbortSignal.timeout(10_000) });
|
|
1425
1445
|
} catch (e) {
|
|
1426
|
-
return fail(`couldn't reach
|
|
1446
|
+
return fail(`couldn't reach claude-rpc.com: ${e.message}`, {
|
|
1427
1447
|
hint: 'check your connection and retry — this never blocks Claude Code',
|
|
1428
1448
|
code: EX_SYS_ERROR,
|
|
1429
1449
|
});
|
|
@@ -1438,111 +1458,6 @@ function squadAuth() {
|
|
|
1438
1458
|
return { cfg, endpoint, instanceId, post, get: call };
|
|
1439
1459
|
}
|
|
1440
1460
|
|
|
1441
|
-
function squadPageUrl(id) { return `https://claude-rpc.com/squad/${id}`; }
|
|
1442
|
-
|
|
1443
|
-
function printSquadInvite(squad) {
|
|
1444
|
-
console.log('');
|
|
1445
|
-
console.log(` ${c.green}✓${c.reset} squad ${c.bold}${squad.name}${c.reset}`);
|
|
1446
|
-
console.log(` ${c.dim}invite code:${c.reset} ${c.cyan}${squad.code}${c.reset}`);
|
|
1447
|
-
console.log(` ${c.dim}standings: ${c.reset} ${c.cyan}${squadPageUrl(squad.id)}${c.reset}`);
|
|
1448
|
-
console.log('');
|
|
1449
|
-
console.log(` ${c.dim}send your crew this:${c.reset}`);
|
|
1450
|
-
console.log(` join my Claude Code squad "${squad.name}" — npx claude-rpc@latest setup, then:`);
|
|
1451
|
-
console.log(` ${c.cyan}claude-rpc squad join ${squad.code}${c.reset} ${c.dim}(or join in the browser: ${squadPageUrl(squad.id)})${c.reset}`);
|
|
1452
|
-
console.log('');
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
async function squadStatus({ post, get }) {
|
|
1456
|
-
const mine = await post('/squads/mine', {});
|
|
1457
|
-
if (!mine.json?.squads) return fail(`could not load squads: ${mine.json?.error || mine.status}`, { code: EX_SYS_ERROR });
|
|
1458
|
-
if (!mine.json.squads.length) {
|
|
1459
|
-
console.log('');
|
|
1460
|
-
console.log(` ${c.dim}no squads yet — start one:${c.reset} ${c.cyan}claude-rpc squad create "the night shift"${c.reset}`);
|
|
1461
|
-
console.log('');
|
|
1462
|
-
return;
|
|
1463
|
-
}
|
|
1464
|
-
for (const s of mine.json.squads) {
|
|
1465
|
-
const r = await get(`/squad?id=${encodeURIComponent(s.id)}`);
|
|
1466
|
-
const standings = r.json?.standings || [];
|
|
1467
|
-
const lines = standings.map((row) => {
|
|
1468
|
-
const who = `${row.displayName || '@' + row.handle}${row.verified ? ' ✓' : ''}${row.owner ? ` ${c.dim}(owner)${c.reset}` : ''}`;
|
|
1469
|
-
return `${c.bold}#${row.rank}${c.reset} ${who.padEnd(28)} ${c.cyan}${fmtNum(row.weekTokens)}${c.reset} ${c.dim}this week${c.reset} · ${fmtNum(row.tokens)} ${c.dim}lifetime${c.reset}`;
|
|
1470
|
-
});
|
|
1471
|
-
lines.push('');
|
|
1472
|
-
lines.push(`${c.dim}week ${r.json?.squad?.week || ''} · invite ${c.reset}${c.cyan}${s.code}${c.reset}${c.dim} · ${squadPageUrl(s.id)}${c.reset}`);
|
|
1473
|
-
box(`${s.name} (${s.members})`, lines, 70);
|
|
1474
|
-
console.log('');
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
async function doSquadCmd(argv) {
|
|
1479
|
-
const sub = (argv[0] || 'status').toLowerCase();
|
|
1480
|
-
const ctx = squadAuth();
|
|
1481
|
-
if (sub === 'status' || sub === '') return squadStatus(ctx);
|
|
1482
|
-
if (sub === 'create') {
|
|
1483
|
-
const name = argv.slice(1).join(' ').trim();
|
|
1484
|
-
if (!name) {
|
|
1485
|
-
return fail('usage: claude-rpc squad create <name>',
|
|
1486
|
-
{ hint: 'example: claude-rpc squad create "the night shift"', code: EX_USER_ERROR });
|
|
1487
|
-
}
|
|
1488
|
-
const r = await ctx.post('/squad/create', { name });
|
|
1489
|
-
if (r.status !== 200) return fail(`create failed: ${r.json?.error || r.status}`, { code: EX_SYS_ERROR });
|
|
1490
|
-
return printSquadInvite(r.json.squad);
|
|
1491
|
-
}
|
|
1492
|
-
if (sub === 'join') {
|
|
1493
|
-
const code = (argv[1] || '').trim();
|
|
1494
|
-
if (!code) {
|
|
1495
|
-
return fail('usage: claude-rpc squad join SQ-XXXXXX',
|
|
1496
|
-
{ hint: 'the invite code comes from whoever created the squad (`claude-rpc squad create`)', code: EX_USER_ERROR });
|
|
1497
|
-
}
|
|
1498
|
-
const r = await ctx.post('/squad/join', { code });
|
|
1499
|
-
if (r.status !== 200) {
|
|
1500
|
-
return fail(`join failed: ${r.json?.error || r.status}`,
|
|
1501
|
-
{ hint: 'double-check the invite code with whoever created the squad', code: EX_SYS_ERROR });
|
|
1502
|
-
}
|
|
1503
|
-
const s = r.json.squad;
|
|
1504
|
-
console.log(` ${c.green}✓${c.reset} ${s.alreadyMember ? 'already in' : 'joined'} ${c.bold}${s.name}${c.reset} ${c.dim}(${s.members} member${s.members === 1 ? '' : 's'})${c.reset}`);
|
|
1505
|
-
console.log(` ${c.dim}standings: ${squadPageUrl(s.id)} — or run ${c.reset}${c.cyan}claude-rpc squad${c.reset}`);
|
|
1506
|
-
return;
|
|
1507
|
-
}
|
|
1508
|
-
if (sub === 'leave') {
|
|
1509
|
-
const mine = await ctx.post('/squads/mine', {});
|
|
1510
|
-
const squads = mine.json?.squads || [];
|
|
1511
|
-
if (!squads.length) return fail('you are not in any squads', { code: EX_BAD_STATE });
|
|
1512
|
-
let target = null;
|
|
1513
|
-
const wanted = (argv[1] || '').toLowerCase();
|
|
1514
|
-
if (wanted) target = squads.find((s) => s.id === wanted || s.name.toLowerCase() === wanted);
|
|
1515
|
-
else if (squads.length === 1) target = squads[0];
|
|
1516
|
-
if (!target) {
|
|
1517
|
-
return fail(squads.length > 1 && !wanted ? 'you are in several squads — name one' : `no squad matching "${argv[1]}"`, {
|
|
1518
|
-
hint: `claude-rpc squad leave <id|name> — yours: ${squads.map((s) => `${s.name} (${s.id})`).join(', ')}`,
|
|
1519
|
-
code: EX_USER_ERROR,
|
|
1520
|
-
});
|
|
1521
|
-
}
|
|
1522
|
-
const r = await ctx.post('/squad/leave', { squadId: target.id });
|
|
1523
|
-
if (r.status !== 200) return fail(`leave failed: ${r.json?.error || r.status}`, { code: EX_SYS_ERROR });
|
|
1524
|
-
console.log(` ${c.green}✓${c.reset} left ${c.bold}${target.name}${c.reset}${r.json.dissolved ? ` ${c.dim}(last member — squad dissolved)${c.reset}` : ''}`);
|
|
1525
|
-
return;
|
|
1526
|
-
}
|
|
1527
|
-
fail(`unknown squad subcommand: ${sub}`, {
|
|
1528
|
-
hint: 'try: squad [status|create <name>|join <code>|leave [id]]',
|
|
1529
|
-
code: EX_USER_ERROR,
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
// ── Link (one profile across machines) ───────────────────────────────────
|
|
1534
|
-
//
|
|
1535
|
-
// Two-sided by design — one verb owns the whole story:
|
|
1536
|
-
// claude-rpc link on your MAIN (verified) machine → mints a
|
|
1537
|
-
// one-time code, no browser needed
|
|
1538
|
-
// claude-rpc link <code> on the NEW machine → claims it, merging this
|
|
1539
|
-
// install into the same leaderboard identity
|
|
1540
|
-
// The browser fallback lives at claude-rpc.com/link (log in with
|
|
1541
|
-
// GitHub → same code) for when the other machine isn't handy. Claiming
|
|
1542
|
-
// verifies the profile (✓) and unlocks managing squads from the browser.
|
|
1543
|
-
|
|
1544
|
-
const LINK_PAGE = 'https://claude-rpc.com/link';
|
|
1545
|
-
|
|
1546
1461
|
// Mint side: this machine asks the worker for a code. The worker only obliges
|
|
1547
1462
|
// when this install's canonical profile is verified — the ✓ a claim grants
|
|
1548
1463
|
// has to root in an already-proven identity.
|
|
@@ -1570,7 +1485,7 @@ async function linkMint(ctx) {
|
|
|
1570
1485
|
}
|
|
1571
1486
|
|
|
1572
1487
|
async function doLink(argv) {
|
|
1573
|
-
const ctx =
|
|
1488
|
+
const ctx = identityAuth();
|
|
1574
1489
|
const code = (argv[0] || '').trim();
|
|
1575
1490
|
if (!code) return linkMint(ctx);
|
|
1576
1491
|
// Make sure the profile row exists server-side before claiming — same
|
|
@@ -1600,7 +1515,7 @@ async function doLink(argv) {
|
|
|
1600
1515
|
...(prevProfile.enabled === undefined ? { enabled: true } : {}),
|
|
1601
1516
|
};
|
|
1602
1517
|
writeUserConfig(userCfg);
|
|
1603
|
-
console.log(` ${c.green}✓${c.reset} linked as ${c.cyan}@${r.json.githubUser}${c.reset} — profile verified
|
|
1518
|
+
console.log(` ${c.green}✓${c.reset} linked as ${c.cyan}@${r.json.githubUser}${c.reset} — profile verified`);
|
|
1604
1519
|
if (r.json.created) {
|
|
1605
1520
|
console.log(` ${c.green}✓${c.reset} board profile created — handle ${c.cyan}@${r.json.handle}${c.reset} ${c.dim}(rename any time: claude-rpc profile set --handle <you>)${c.reset}`);
|
|
1606
1521
|
}
|
|
@@ -1779,8 +1694,9 @@ function profileNextStep() {
|
|
|
1779
1694
|
}
|
|
1780
1695
|
}
|
|
1781
1696
|
|
|
1782
|
-
function profileStatus() {
|
|
1697
|
+
async function profileStatus() {
|
|
1783
1698
|
const p = (loadConfig().profile) || {};
|
|
1699
|
+
const { readProfileResult } = await import('./community.js');
|
|
1784
1700
|
const handleOk = lb.isValidHandle(p.handle);
|
|
1785
1701
|
const boardUrl = handleOk ? `https://claude-rpc.com/u/${encodeURIComponent(p.handle)}` : '';
|
|
1786
1702
|
|
|
@@ -1791,8 +1707,22 @@ function profileStatus() {
|
|
|
1791
1707
|
const githubLine = p.githubUser
|
|
1792
1708
|
? `${p.githubUser}${p.verified ? ` ${c.green}✓ verified${c.reset}` : ` ${c.dim}(unverified)${c.reset}`}`
|
|
1793
1709
|
: `${c.dim}—${c.reset}`;
|
|
1710
|
+
const last = readProfileResult();
|
|
1711
|
+
const ago = (t) => {
|
|
1712
|
+
const m = Math.round((Date.now() - t) / 60_000);
|
|
1713
|
+
return m < 60 ? `${m}m ago` : m < 2880 ? `${Math.round(m / 60)}h ago` : `${Math.round(m / 1440)}d ago`;
|
|
1714
|
+
};
|
|
1715
|
+
const lastLines = [];
|
|
1716
|
+
if (p.enabled && last) {
|
|
1717
|
+
if (last.ok === false) {
|
|
1718
|
+
lastLines.push(pair('last', `${c.red}✗ refused ${ago(last.failedAt)}${c.reset} ${c.dim}${last.reason}${last.error ? ` · ${last.error}` : ''}${c.reset}`, ''));
|
|
1719
|
+
} else if (last.at) {
|
|
1720
|
+
lastLines.push(pair('last', `${c.green}✓${c.reset} ${c.dim}published ${ago(last.at)}${c.reset}`, ''));
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1794
1723
|
box('profile', [
|
|
1795
1724
|
pair('state', p.enabled ? `${c.green}● publishing${c.reset}` : `${c.dim}○ off${c.reset}`, ''),
|
|
1725
|
+
...lastLines,
|
|
1796
1726
|
pair('handle', handleOk ? `${c.cyan}${p.handle}${c.reset}` : `${c.dim}(unset)${c.reset}`, ''),
|
|
1797
1727
|
pair('name', p.displayName || `${c.dim}—${c.reset}`, ''),
|
|
1798
1728
|
pair('github', githubLine, ''),
|
|
@@ -1803,6 +1733,15 @@ function profileStatus() {
|
|
|
1803
1733
|
// Setup checklist — same shape every time, so the user always sees where
|
|
1804
1734
|
// they are and the exact next command. This is the screen the daemon's
|
|
1805
1735
|
// breadcrumbs point back to.
|
|
1736
|
+
if (p.enabled && last?.ok === false) {
|
|
1737
|
+
const hint = publishFailHint(last);
|
|
1738
|
+
for (const h of [].concat(hint)) console.log(` ${c.yellow}!${c.reset} ${c.dim}${h}${c.reset}`);
|
|
1739
|
+
console.log('');
|
|
1740
|
+
}
|
|
1741
|
+
if (p.enabled && last?.site) {
|
|
1742
|
+
for (const line of siteBreakdown(last)) console.log(` ${line}`);
|
|
1743
|
+
console.log('');
|
|
1744
|
+
}
|
|
1806
1745
|
const steps = profileSteps(p);
|
|
1807
1746
|
if (steps.every((s) => s.done)) {
|
|
1808
1747
|
console.log(` ${c.green}✓${c.reset} all set — you're live at ${c.cyan}${boardUrl}${c.reset}`);
|
|
@@ -1912,16 +1851,51 @@ async function profilePublish() {
|
|
|
1912
1851
|
hint: 'claude-rpc profile set --handle <name> && claude-rpc profile on', code: EX_BAD_STATE,
|
|
1913
1852
|
});
|
|
1914
1853
|
}
|
|
1915
|
-
const { flushProfile } = await import('./community.js');
|
|
1854
|
+
const { flushProfile, recordProfileResult } = await import('./community.js');
|
|
1916
1855
|
console.log(` ${c.dim}publishing @${cfg.profile.handle} to the board…${c.reset}`);
|
|
1917
1856
|
const r = await flushProfile(cfg);
|
|
1857
|
+
recordProfileResult(r);
|
|
1918
1858
|
if (r.ok) {
|
|
1919
1859
|
console.log(` ${c.green}✓${c.reset} published — see it at ${c.cyan}https://claude-rpc.com/u/${encodeURIComponent(cfg.profile.handle)}${c.reset}`);
|
|
1860
|
+
for (const line of siteBreakdown({ ok: true, at: Date.now(), totals: r.totals, site: r.site })) console.log(` ${line}`);
|
|
1920
1861
|
} else if (r.reason === 'rate-limited') {
|
|
1921
1862
|
console.log(` ${c.yellow}!${c.reset} rate-limited — already published in the last minute; the board has you`);
|
|
1922
1863
|
} else {
|
|
1923
|
-
return fail(`publish failed: ${r.reason}${r.error ? ' (' + r.error + ')' : ''}`, { code: EX_SYS_ERROR });
|
|
1864
|
+
return fail(`publish failed: ${r.reason}${r.error ? ' (' + r.error + ')' : ''}`, { hint: publishFailHint(r), code: EX_SYS_ERROR });
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// Why a publish was refused, in terms of what to do. A 409 is almost always a
|
|
1869
|
+
// second machine that was never linked: its local handle is the one its main
|
|
1870
|
+
// machine already owns, so every flush is refused and its usage never reaches
|
|
1871
|
+
// the board.
|
|
1872
|
+
function publishFailHint(r) {
|
|
1873
|
+
if (r.reason === 'http-409') {
|
|
1874
|
+
return ['this machine isn\'t linked to the identity that owns that handle',
|
|
1875
|
+
'run `claude-rpc link` on a linked machine, then `claude-rpc link <code>` here'];
|
|
1876
|
+
}
|
|
1877
|
+
if (r.reason === 'network') return 'no connection to the board — the daemon retries every 30 min';
|
|
1878
|
+
return 'run `claude-rpc doctor`';
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// Lines describing where the board's number comes from: this machine's share,
|
|
1882
|
+
// the identity total, and any linked machine that has stopped reporting.
|
|
1883
|
+
function siteBreakdown(rec) {
|
|
1884
|
+
const out = [];
|
|
1885
|
+
if (!rec?.site) return out;
|
|
1886
|
+
const ms = rec.site.machines;
|
|
1887
|
+
const n = Array.isArray(ms) ? ms.length : null;
|
|
1888
|
+
const mine = rec.totals?.tokens;
|
|
1889
|
+
out.push(`${c.dim}this machine ${fmtNum(mine || 0)} tokens · board total ${fmtNum(rec.site.tokens || 0)}${n && n > 1 ? ` across ${n} linked machines` : ''}${c.reset}`);
|
|
1890
|
+
if (n && n > 1) {
|
|
1891
|
+
const quietDays = 3;
|
|
1892
|
+
const stale = ms.filter((m) => !m.self && m.updatedAt && Date.now() - m.updatedAt > quietDays * 86_400_000);
|
|
1893
|
+
for (const m of stale) {
|
|
1894
|
+
const days = Math.round((Date.now() - m.updatedAt) / 86_400_000);
|
|
1895
|
+
out.push(`${c.yellow}!${c.reset} ${c.dim}a linked machine (${fmtNum(m.tokens)} tokens) hasn't published in ${days} days — run ${c.reset}${c.cyan}claude-rpc profile publish${c.reset}${c.dim} there; if its daemon is down, ${c.reset}${c.cyan}claude-rpc start${c.reset}`);
|
|
1896
|
+
}
|
|
1924
1897
|
}
|
|
1898
|
+
return out;
|
|
1925
1899
|
}
|
|
1926
1900
|
|
|
1927
1901
|
// The gist-verification dance shared by `profile verify` and setup's optional
|
|
@@ -2204,8 +2178,27 @@ async function doUpdate(argv) {
|
|
|
2204
2178
|
}
|
|
2205
2179
|
if (sub === 'status') {
|
|
2206
2180
|
const st = readUpdateState();
|
|
2181
|
+
const ago = (t) => {
|
|
2182
|
+
const m = Math.round((Date.now() - t) / 60_000);
|
|
2183
|
+
return m < 60 ? `${m}m ago` : m < 2880 ? `${Math.round(m / 60)}h ago` : `${Math.round(m / 1440)}d ago`;
|
|
2184
|
+
};
|
|
2207
2185
|
console.log(` ${c.cyan}·${c.reset} v${VERSION} · installed via ${kind} · auto-update ${auto && kind === 'npm-global' ? 'on' : kind === 'npm-global' ? 'off' : 'n/a'}`);
|
|
2208
|
-
|
|
2186
|
+
const { daemonAlive: alive, readDaemonInfo: info } = await import('./ensure-daemon.js');
|
|
2187
|
+
const pid = alive();
|
|
2188
|
+
const di = info();
|
|
2189
|
+
if (pid) {
|
|
2190
|
+
const dv = di && di.pid === pid ? di.version : null;
|
|
2191
|
+
if (!dv) console.log(` ${c.yellow}!${c.reset} ${c.dim}the running daemon predates version reporting — ${c.reset}${c.cyan}claude-rpc restart${c.reset}${c.dim} to run v${VERSION}${c.reset}`);
|
|
2192
|
+
else if (dv !== VERSION) console.log(` ${c.yellow}!${c.reset} ${c.dim}the running daemon is v${dv} — ${c.reset}${c.cyan}claude-rpc restart${c.reset}${c.dim} to run v${VERSION}${c.reset}`);
|
|
2193
|
+
}
|
|
2194
|
+
if (st.checkedAt) console.log(` ${c.dim}last check: ${ago(st.checkedAt)}${st.latest ? ` · latest v${st.latest}` : ' · registry unreachable'}${c.reset}`);
|
|
2195
|
+
else console.log(` ${c.dim}no check yet — the daemon checks 5 min after it starts, then every 6h${c.reset}`);
|
|
2196
|
+
if (st.latest && isNewer(st.latest, VERSION)) {
|
|
2197
|
+
const why = st.lastPlan?.latest === st.latest ? st.lastPlan.reason : null;
|
|
2198
|
+
console.log(` ${c.yellow}!${c.reset} v${st.latest} is out${why ? ` ${c.dim}(${why})${c.reset}` : ''} — ${c.cyan}${kind === 'npm-global' ? 'claude-rpc update now' : updateCommand(kind)}${c.reset}`);
|
|
2199
|
+
}
|
|
2200
|
+
if (st.failed) console.log(` ${c.red}✗${c.reset} ${c.dim}install of v${st.failed.version} failed ${ago(st.failed.at)}: ${String(st.failed.output || '').split('\n').pop().slice(0, 160)}${c.reset}`);
|
|
2201
|
+
if (st.updatedTo) console.log(` ${c.dim}last auto-update: ${st.updatedFrom} → ${st.updatedTo}${st.updatedAt ? ` (${ago(st.updatedAt)})` : ''}${c.reset}`);
|
|
2209
2202
|
return;
|
|
2210
2203
|
}
|
|
2211
2204
|
if (sub !== 'check' && sub !== 'now') {
|
|
@@ -2226,9 +2219,17 @@ async function doUpdate(argv) {
|
|
|
2226
2219
|
console.log(` ${c.dim}installing…${c.reset}`);
|
|
2227
2220
|
const res = await installVersion(latest);
|
|
2228
2221
|
if (!res.ok) fail('install failed', { hint: [res.output.slice(-300) || 'npm exited non-zero', `try: ${updateCommand(kind)}`], code: EX_BAD_STATE });
|
|
2222
|
+
const { installedVersion } = await import('./updater.js');
|
|
2223
|
+
if (installedVersion() !== latest) {
|
|
2224
|
+
fail(`npm finished, but this copy is still v${VERSION}`, {
|
|
2225
|
+
hint: [`npm installs its globals somewhere other than ${ROOT} (npm prefix / volta / pnpm)`, 'update with the tool that installed claude-rpc'],
|
|
2226
|
+
code: EX_BAD_STATE,
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
2229
|
writeUpdateState({ updatedFrom: VERSION, updatedTo: latest, updatedAt: Date.now(), failed: null });
|
|
2230
2230
|
console.log(` ${c.green}✓${c.reset} updated to v${latest}`);
|
|
2231
|
-
|
|
2231
|
+
// Restart a running daemon onto the new code; a stopped one stays stopped.
|
|
2232
|
+
if (daemonAlive()) await restartDaemon();
|
|
2232
2233
|
}
|
|
2233
2234
|
|
|
2234
2235
|
function tailLog() {
|
|
@@ -2286,6 +2287,7 @@ function overview() {
|
|
|
2286
2287
|
const vars = buildVars(state, cfg, aggregate);
|
|
2287
2288
|
const dot = pid
|
|
2288
2289
|
? `${c.green}●${c.reset} running ${c.dim}pid ${pid}${c.reset}`
|
|
2290
|
+
: isStopped() ? `${c.yellow}○${c.reset} ${c.dim}daemon stopped — ${c.reset}${c.cyan}claude-rpc start${c.reset}${c.dim} to resume${c.reset}`
|
|
2289
2291
|
: `${c.yellow}○${c.reset} ${c.dim}daemon not running${c.reset}`;
|
|
2290
2292
|
if (pid) {
|
|
2291
2293
|
console.log(` ${dot} ${c.gray}·${c.reset} ${c.bold}${vars.modelPretty}${c.reset} in ${c.bold}${vars.project}${c.reset} ${c.gray}·${c.reset} ${statusColor(vars.status)}${vars.statusVerbose}${c.reset}`);
|
|
@@ -2490,6 +2492,10 @@ process.on('unhandledRejection', (e) => {
|
|
|
2490
2492
|
}
|
|
2491
2493
|
if (['start', 'stop', 'restart'].includes(cmd)) await loadDaemonCtl();
|
|
2492
2494
|
else if (!FAST_PATHS.has(cmd)) await loadCore();
|
|
2495
|
+
// Coarse "used in the last 7 days" stamp for the anonymous report (see
|
|
2496
|
+
// feature-usage.js). Command name only; unlisted commands are ignored.
|
|
2497
|
+
if (cmd) stampFeature(cmd);
|
|
2498
|
+
if (process.env.CLAUDE_RPC_DESKTOP === '1') stampFeature('desktop');
|
|
2493
2499
|
switch (cmd) {
|
|
2494
2500
|
case '--version':
|
|
2495
2501
|
case '-V':
|
|
@@ -2517,7 +2523,13 @@ process.on('unhandledRejection', (e) => {
|
|
|
2517
2523
|
// immediately, instead of making the user run a separate `start`.
|
|
2518
2524
|
// Best-effort — a start hiccup must never make `setup` look failed.
|
|
2519
2525
|
try {
|
|
2520
|
-
|
|
2526
|
+
// `--auto` = the desktop app re-running setup after its own update:
|
|
2527
|
+
// it must not undo a `claude-rpc stop`. A person running setup means it.
|
|
2528
|
+
if (!args.includes('--auto')) clearStopped();
|
|
2529
|
+
if (!isStopped()) await replaceOutdatedDaemon();
|
|
2530
|
+
if (isStopped()) {
|
|
2531
|
+
console.log(` ${c.cyan}·${c.reset} ${'daemon stopped'.padEnd(16)}${c.dim}left off (you ran stop) · ${c.reset}${c.cyan}claude-rpc start${c.reset}${c.dim} to resume${c.reset}`);
|
|
2532
|
+
} else if (IS_NPX) {
|
|
2521
2533
|
// Our own tree is npm's throwaway _npx cache; launch from the global
|
|
2522
2534
|
// install setup just promoted to. The global copy must be resolved
|
|
2523
2535
|
// EXPLICITLY (npm root -g): inside an npx run, PATH has the _npx
|
|
@@ -2601,12 +2613,12 @@ process.on('unhandledRejection', (e) => {
|
|
|
2601
2613
|
if (!(await import('./install.js')).migrateConfig()) console.log(` ${c.green}✓${c.reset} config already current — nothing to migrate`);
|
|
2602
2614
|
break;
|
|
2603
2615
|
case 'start': if (startDaemon()) await confirmDaemonUp(); break;
|
|
2604
|
-
case 'stop': stopDaemon(); break;
|
|
2616
|
+
case 'stop': await stopDaemon(); break;
|
|
2605
2617
|
case 'restart': if (await restartDaemon()) await confirmDaemonUp(); break;
|
|
2606
2618
|
case 'status': {
|
|
2607
2619
|
const dumpFlag = args.some((a) => a === '--dump' || a === '-d');
|
|
2608
2620
|
if (dumpFlag || !process.stdout.isTTY) await showStatus();
|
|
2609
|
-
else (await import('./tui.js')).startTui();
|
|
2621
|
+
else { stampFeature('tui'); (await import('./tui.js')).startTui(); }
|
|
2610
2622
|
break;
|
|
2611
2623
|
}
|
|
2612
2624
|
case 'dump': await showStatus(); break;
|
|
@@ -2665,7 +2677,6 @@ process.on('unhandledRejection', (e) => {
|
|
|
2665
2677
|
case 'community': await doCommunity(args); break;
|
|
2666
2678
|
case 'update': await doUpdate(args); break;
|
|
2667
2679
|
case 'profile': await doProfile(args); break;
|
|
2668
|
-
case 'squad': await doSquadCmd(args); break;
|
|
2669
2680
|
case 'link': await doLink(args); break;
|
|
2670
2681
|
case 'doctor': {
|
|
2671
2682
|
const { runDoctor, fixPlan } = await import('./doctor.js');
|
|
@@ -2747,14 +2758,11 @@ process.on('unhandledRejection', (e) => {
|
|
|
2747
2758
|
} catch (e) {
|
|
2748
2759
|
console.warn(` ${c.yellow}!${c.reset} ${'refresh skipped'.padEnd(16)}${c.dim}${e.message}${c.reset}`);
|
|
2749
2760
|
}
|
|
2750
|
-
|
|
2761
|
+
// Wait for the old daemon to really exit (a fixed 700ms sleep let
|
|
2762
|
+
// startDaemon see it "still up" and no-op, leaving none running).
|
|
2763
|
+
await stopDaemonAndWait();
|
|
2751
2764
|
try { if (existsSync(STATE_PATH)) unlinkSync(STATE_PATH); } catch { /* state.json locked or already gone — next hook will recreate it */ }
|
|
2752
|
-
|
|
2753
|
-
// Brief wait for the OS to release the pid file before we spawn.
|
|
2754
|
-
setTimeout(() => startDaemon(), 700);
|
|
2755
|
-
} else {
|
|
2756
|
-
startDaemon();
|
|
2757
|
-
}
|
|
2765
|
+
startDaemon();
|
|
2758
2766
|
}
|
|
2759
2767
|
} else if (!cmd) {
|
|
2760
2768
|
// True no-args invocation in dev/npm mode → one-screen overview.
|