@wbern/cc-ping 0.1.0 → 1.1.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 +241 -0
- package/dist/cli.js +801 -355
- package/package.json +15 -13
package/README.md
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# @wbern/cc-ping
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@wbern/cc-ping)
|
|
4
|
+
[](https://www.npmjs.com/package/@wbern/cc-ping)
|
|
5
|
+
[](https://github.com/wbern/cc-ping/actions/workflows/ci.yml)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
**Ping Claude Code sessions to trigger quota windows early across multiple accounts.**
|
|
9
|
+
|
|
10
|
+
Claude Code has a 5-hour quota window that starts on your first message. If you rotate between accounts, your idle accounts sit there with full quota doing nothing. cc-ping pings them so their windows start ticking — when you need them, they've already reset.
|
|
11
|
+
|
|
12
|
+
Zero telemetry. No data is collected, sent, or phoned home. Everything stays in `~/.config/cc-ping/`. The only network activity is the `claude` CLI call itself, which is subject to Anthropic's normal Claude Code telemetry.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
[Claude Code](https://docs.anthropic.com/en/docs/claude-code) must be installed and on your PATH.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
claude --version # verify it's available
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick run (no install)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm dlx @wbern/cc-ping ping
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm add -g @wbern/cc-ping
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install -g @wbern/cc-ping # also works
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Setup
|
|
39
|
+
|
|
40
|
+
Discover accounts from `~/.claude-accounts/`, then verify they have valid credentials:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
cc-ping scan # auto-discover accounts
|
|
44
|
+
cc-ping check # verify credentials are valid
|
|
45
|
+
cc-ping list # show configured accounts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or add accounts manually:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cc-ping add my-account ~/.claude-accounts/my-account
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cc-ping ping # ping all accounts
|
|
58
|
+
cc-ping ping alice bob # ping specific accounts
|
|
59
|
+
cc-ping ping --parallel # ping all at once
|
|
60
|
+
cc-ping ping --notify # desktop notification on new windows
|
|
61
|
+
cc-ping ping --bell # terminal bell on failure
|
|
62
|
+
cc-ping ping --stagger 5s # wait 5s between each account
|
|
63
|
+
cc-ping status # show account status table
|
|
64
|
+
cc-ping suggest # which account should I use next?
|
|
65
|
+
cc-ping next-reset # when does the next window expire?
|
|
66
|
+
cc-ping daemon start --interval 300m # auto-ping every 5 hours
|
|
67
|
+
cc-ping history # recent ping results
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
### `cc-ping ping [handles...]`
|
|
73
|
+
|
|
74
|
+
Ping configured accounts to start their quota windows. Pings accounts sequentially by default.
|
|
75
|
+
|
|
76
|
+
| Flag | Default | Description |
|
|
77
|
+
|------|---------|-------------|
|
|
78
|
+
| `--parallel` | `false` | Ping all accounts simultaneously |
|
|
79
|
+
| `--stagger <duration>` | — | Wait between each account (e.g. `5s`, `1m`) |
|
|
80
|
+
| `--notify` | `false` | Desktop notification when new windows open |
|
|
81
|
+
| `--bell` | `false` | Terminal bell on failure |
|
|
82
|
+
| `--json` | `false` | Output results as JSON |
|
|
83
|
+
| `--quiet` | `false` | Suppress per-account output |
|
|
84
|
+
| `--group <name>` | — | Only ping accounts in this group |
|
|
85
|
+
| `--exclude <handles>` | — | Skip specific accounts |
|
|
86
|
+
|
|
87
|
+
### `cc-ping status`
|
|
88
|
+
|
|
89
|
+
Show all accounts with their quota window state — whether they have an active window, when it resets, and duplicate detection.
|
|
90
|
+
|
|
91
|
+
### `cc-ping suggest`
|
|
92
|
+
|
|
93
|
+
Recommend which account to use next based on quota window state. Prefers accounts that need pinging or whose windows are about to reset.
|
|
94
|
+
|
|
95
|
+
### `cc-ping next-reset`
|
|
96
|
+
|
|
97
|
+
Show which account has its quota window resetting soonest — useful for knowing when capacity frees up.
|
|
98
|
+
|
|
99
|
+
### `cc-ping scan`
|
|
100
|
+
|
|
101
|
+
Auto-discover accounts from `~/.claude-accounts/`. Each subdirectory with a `claude_user.json` is detected as an account. Duplicate identities (same `accountUuid` across directories) are flagged.
|
|
102
|
+
|
|
103
|
+
### `cc-ping check`
|
|
104
|
+
|
|
105
|
+
Verify that each configured account's config directory exists and has credentials.
|
|
106
|
+
|
|
107
|
+
### `cc-ping add <handle> <config-dir>`
|
|
108
|
+
|
|
109
|
+
Manually add an account by name and Claude Code config directory path.
|
|
110
|
+
|
|
111
|
+
### `cc-ping remove <handle>`
|
|
112
|
+
|
|
113
|
+
Remove an account from the configuration.
|
|
114
|
+
|
|
115
|
+
### `cc-ping list`
|
|
116
|
+
|
|
117
|
+
List all configured accounts with their config directory paths.
|
|
118
|
+
|
|
119
|
+
### `cc-ping history`
|
|
120
|
+
|
|
121
|
+
Show recent ping results — handle, success/failure, duration, cost.
|
|
122
|
+
|
|
123
|
+
### `cc-ping completions <shell>`
|
|
124
|
+
|
|
125
|
+
Generate shell completion scripts for `bash`, `zsh`, or `fish`.
|
|
126
|
+
|
|
127
|
+
### `cc-ping moo`
|
|
128
|
+
|
|
129
|
+
Send a test desktop notification to verify notifications work on your platform.
|
|
130
|
+
|
|
131
|
+
## Daemon
|
|
132
|
+
|
|
133
|
+
The daemon auto-pings on a schedule so you don't have to remember.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cc-ping daemon start --interval 300m # every 5 hours
|
|
137
|
+
cc-ping daemon status # check if running, next ping time
|
|
138
|
+
cc-ping daemon stop # graceful shutdown
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
| Flag | Default | Description |
|
|
142
|
+
|------|---------|-------------|
|
|
143
|
+
| `--interval <duration>` | `300m` | Time between ping cycles |
|
|
144
|
+
| `--notify` | `false` | Desktop notification when new windows open |
|
|
145
|
+
| `--bell` | `false` | Terminal bell on failure |
|
|
146
|
+
| `--quiet` | `true` | Suppress per-account output in logs |
|
|
147
|
+
|
|
148
|
+
The daemon is smart about what it pings:
|
|
149
|
+
|
|
150
|
+
- **Skips active windows** — accounts with a quota window still running are skipped to avoid wasting pings
|
|
151
|
+
- **Detects system sleep** — if the machine wakes from sleep and a ping cycle is overdue, the daemon notices and factors the delay into notifications
|
|
152
|
+
- **Singleton enforcement** — only one daemon runs at a time, verified by PID and process name
|
|
153
|
+
- **Graceful shutdown** — `daemon stop` writes a sentinel file and waits for a clean exit before force-killing
|
|
154
|
+
|
|
155
|
+
Logs are written to `~/.config/cc-ping/daemon.log`.
|
|
156
|
+
|
|
157
|
+
### System service (survive reboots)
|
|
158
|
+
|
|
159
|
+
`daemon start` runs as a detached process that won't survive a reboot. Use `daemon install` to register as a system service that starts automatically on login:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
cc-ping daemon install --interval 300m --notify # install and start
|
|
163
|
+
cc-ping daemon status # shows "System service: installed"
|
|
164
|
+
cc-ping daemon uninstall # remove service and stop
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
| Platform | Service manager | Service file |
|
|
168
|
+
|----------|----------------|--------------|
|
|
169
|
+
| macOS | launchd | `~/Library/LaunchAgents/com.cc-ping.daemon.plist` |
|
|
170
|
+
| Linux | systemd (user) | `~/.config/systemd/user/cc-ping-daemon.service` |
|
|
171
|
+
|
|
172
|
+
The service restarts the daemon on crash (but not on clean exit via `daemon stop`). No `sudo` required — both use user-level service managers.
|
|
173
|
+
|
|
174
|
+
**`daemon stop` vs `daemon uninstall`:** When a service is installed, `daemon stop` kills the process but the service manager may restart it on crash. Use `daemon uninstall` to fully remove the service, or `daemon stop` if you just need a temporary pause.
|
|
175
|
+
|
|
176
|
+
## Notifications
|
|
177
|
+
|
|
178
|
+
Desktop notifications work on macOS, Linux, and Windows:
|
|
179
|
+
|
|
180
|
+
| Platform | Mechanism |
|
|
181
|
+
|----------|-----------|
|
|
182
|
+
| macOS | `osascript` (AppleScript `display notification`) |
|
|
183
|
+
| Linux | `notify-send` |
|
|
184
|
+
| Windows | PowerShell `New-BurntToastNotification` |
|
|
185
|
+
|
|
186
|
+
Use `cc-ping moo` to verify notifications work on your system.
|
|
187
|
+
|
|
188
|
+
## Shell completions
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# bash
|
|
192
|
+
cc-ping completions bash >> ~/.bashrc
|
|
193
|
+
|
|
194
|
+
# zsh
|
|
195
|
+
cc-ping completions zsh >> ~/.zshrc
|
|
196
|
+
|
|
197
|
+
# fish
|
|
198
|
+
cc-ping completions fish > ~/.config/fish/completions/cc-ping.fish
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## How it works
|
|
202
|
+
|
|
203
|
+
Each ping spawns the `claude` CLI with a trivial arithmetic prompt:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
claude -p "Quick, take a guess: what is 2847 + 6192?" \
|
|
207
|
+
--output-format json \
|
|
208
|
+
--tools "" \
|
|
209
|
+
--max-turns 1
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The account is selected by setting `CLAUDE_CONFIG_DIR` to the account's config directory, so the `claude` CLI authenticates as that account.
|
|
213
|
+
|
|
214
|
+
Key design choices:
|
|
215
|
+
|
|
216
|
+
- **Arithmetic prompts** — random math questions minimize token usage (~150 input tokens, ~10 output). Templates and operands are randomized to avoid cache hits across pings.
|
|
217
|
+
- **Tools disabled** — `--tools ""` prevents the model from doing anything beyond answering the question.
|
|
218
|
+
- **Single turn** — `--max-turns 1` ensures one request-response cycle, no follow-ups.
|
|
219
|
+
- **30s timeout** — pings that take longer are killed.
|
|
220
|
+
- **Cost tracking** — each ping records its USD cost and token usage so you can audit spend.
|
|
221
|
+
|
|
222
|
+
After a successful ping, the account's last-ping timestamp is saved to `~/.config/cc-ping/state.json`. The 5-hour quota window is calculated from this timestamp — commands like `status`, `suggest`, and the daemon all use it to determine window state.
|
|
223
|
+
|
|
224
|
+
## Privacy
|
|
225
|
+
|
|
226
|
+
cc-ping sends **zero telemetry**. No analytics, no tracking, no phoning home.
|
|
227
|
+
|
|
228
|
+
All data stays local in `~/.config/cc-ping/`:
|
|
229
|
+
|
|
230
|
+
| File | Contents |
|
|
231
|
+
|------|----------|
|
|
232
|
+
| `config.json` | Account names and config directory paths |
|
|
233
|
+
| `state.json` | Last ping timestamp and cost metadata per account |
|
|
234
|
+
| `daemon.json` | Daemon PID, interval, start time |
|
|
235
|
+
| `daemon.log` | Daemon output log |
|
|
236
|
+
|
|
237
|
+
The only network activity is the `claude` CLI call itself, which communicates with Anthropic's API under their standard [terms](https://www.anthropic.com/terms) and [privacy policy](https://www.anthropic.com/privacy). cc-ping does not intercept, modify, or inspect this traffic beyond reading the JSON response for cost metadata.
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT
|