@wbern/cc-ping 1.9.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/dist/cli.js +47 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1772,12 +1772,31 @@ function colorizeStatus(windowStatus) {
|
|
|
1772
1772
|
return yellow(windowStatus);
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
1775
|
-
function
|
|
1775
|
+
function censorHandle(handle) {
|
|
1776
|
+
const atIdx = handle.indexOf("@");
|
|
1777
|
+
if (atIdx !== -1) {
|
|
1778
|
+
const local = handle.slice(0, atIdx);
|
|
1779
|
+
const domain = handle.slice(atIdx + 1);
|
|
1780
|
+
return censorPart(local) + "@" + censorDomain(domain);
|
|
1781
|
+
}
|
|
1782
|
+
return censorDomain(handle);
|
|
1783
|
+
}
|
|
1784
|
+
function censorPart(part) {
|
|
1785
|
+
if (part.length <= 1) return part;
|
|
1786
|
+
return part[0] + "*".repeat(part.length - 1);
|
|
1787
|
+
}
|
|
1788
|
+
function censorDomain(domain) {
|
|
1789
|
+
const lastDot = domain.lastIndexOf(".");
|
|
1790
|
+
if (lastDot === -1) return censorPart(domain);
|
|
1791
|
+
const name = domain.slice(0, lastDot);
|
|
1792
|
+
const tld = domain.slice(lastDot);
|
|
1793
|
+
return censorPart(name) + tld;
|
|
1794
|
+
}
|
|
1795
|
+
function formatStatusLine(status, options) {
|
|
1776
1796
|
const lines = [];
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
);
|
|
1797
|
+
const handle = options?.censor ? censorHandle(status.handle) : status.handle;
|
|
1798
|
+
const dup = status.duplicateOf ? ` [duplicate of ${options?.censor ? censorHandle(status.duplicateOf) : status.duplicateOf}]` : "";
|
|
1799
|
+
lines.push(` ${handle}: ${colorizeStatus(status.windowStatus)}${dup}`);
|
|
1781
1800
|
const ping = status.lastPing === null ? "never" : status.lastPing.replace("T", " ").replace(/\.\d+Z$/, "Z");
|
|
1782
1801
|
lines.push(` - last ping: ${ping}`);
|
|
1783
1802
|
if (status.timeUntilReset !== null) {
|
|
@@ -1832,7 +1851,7 @@ function getAccountStatuses(accounts, now = /* @__PURE__ */ new Date(), duplicat
|
|
|
1832
1851
|
};
|
|
1833
1852
|
});
|
|
1834
1853
|
}
|
|
1835
|
-
function printAccountTable(log = console.log, now = /* @__PURE__ */ new Date(), deferredHandles) {
|
|
1854
|
+
function printAccountTable(log = console.log, now = /* @__PURE__ */ new Date(), deferredHandles, options) {
|
|
1836
1855
|
const accounts = listAccounts();
|
|
1837
1856
|
if (accounts.length === 0) {
|
|
1838
1857
|
log("No accounts configured");
|
|
@@ -1841,12 +1860,12 @@ function printAccountTable(log = console.log, now = /* @__PURE__ */ new Date(),
|
|
|
1841
1860
|
const dupes = findDuplicates(accounts);
|
|
1842
1861
|
const statuses = getAccountStatuses(accounts, now, dupes, deferredHandles);
|
|
1843
1862
|
for (const s of statuses) {
|
|
1844
|
-
log(formatStatusLine(s));
|
|
1863
|
+
log(formatStatusLine(s, options));
|
|
1845
1864
|
}
|
|
1846
1865
|
}
|
|
1847
1866
|
|
|
1848
1867
|
// src/default-command.ts
|
|
1849
|
-
function showDefault(log = console.log, now = /* @__PURE__ */ new Date(), deferredHandles) {
|
|
1868
|
+
function showDefault(log = console.log, now = /* @__PURE__ */ new Date(), deferredHandles, options) {
|
|
1850
1869
|
const accounts = listAccounts();
|
|
1851
1870
|
if (accounts.length === 0) {
|
|
1852
1871
|
log("No accounts configured.");
|
|
@@ -1858,7 +1877,7 @@ function showDefault(log = console.log, now = /* @__PURE__ */ new Date(), deferr
|
|
|
1858
1877
|
const dupes = findDuplicates(accounts);
|
|
1859
1878
|
const statuses = getAccountStatuses(accounts, now, dupes, deferredHandles);
|
|
1860
1879
|
for (const s of statuses) {
|
|
1861
|
-
log(formatStatusLine(s));
|
|
1880
|
+
log(formatStatusLine(s, options));
|
|
1862
1881
|
}
|
|
1863
1882
|
const needsPing = statuses.filter((s) => s.windowStatus !== "active");
|
|
1864
1883
|
if (needsPing.length > 0) {
|
|
@@ -2001,16 +2020,19 @@ function getDeferredHandles() {
|
|
|
2001
2020
|
}
|
|
2002
2021
|
return deferred;
|
|
2003
2022
|
}
|
|
2004
|
-
var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.
|
|
2023
|
+
var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.10.0").option(
|
|
2005
2024
|
"--config <path>",
|
|
2006
2025
|
"Path to config directory (default: ~/.config/cc-ping, env: CC_PING_CONFIG)"
|
|
2007
|
-
).hook("preAction", (thisCommand) => {
|
|
2026
|
+
).option("--censor", "Mask account handles in output (for screenshots)").hook("preAction", (thisCommand) => {
|
|
2008
2027
|
const opts = thisCommand.opts();
|
|
2009
2028
|
if (opts.config) {
|
|
2010
2029
|
setConfigDir(opts.config);
|
|
2011
2030
|
}
|
|
2012
2031
|
}).action(() => {
|
|
2013
|
-
|
|
2032
|
+
const opts = program.opts();
|
|
2033
|
+
showDefault(console.log, /* @__PURE__ */ new Date(), getDeferredHandles(), {
|
|
2034
|
+
censor: opts.censor
|
|
2035
|
+
});
|
|
2014
2036
|
});
|
|
2015
2037
|
program.command("ping").description("Ping configured accounts to start quota windows").argument(
|
|
2016
2038
|
"[handles...]",
|
|
@@ -2137,7 +2159,9 @@ program.command("status").description("Show status of all accounts with window i
|
|
|
2137
2159
|
console.log(JSON.stringify(statuses, null, 2));
|
|
2138
2160
|
return;
|
|
2139
2161
|
}
|
|
2140
|
-
printAccountTable(console.log, /* @__PURE__ */ new Date(), deferred
|
|
2162
|
+
printAccountTable(console.log, /* @__PURE__ */ new Date(), deferred, {
|
|
2163
|
+
censor: program.opts().censor
|
|
2164
|
+
});
|
|
2141
2165
|
});
|
|
2142
2166
|
program.command("next-reset").description("Show which account has its quota window resetting soonest").option("--json", "Output as JSON", false).action((opts) => {
|
|
2143
2167
|
const accounts = listAccounts();
|
|
@@ -2228,7 +2252,7 @@ daemon.command("start").description("Start the daemon process").option(
|
|
|
2228
2252
|
bell: opts.bell,
|
|
2229
2253
|
notify: opts.notify,
|
|
2230
2254
|
smartSchedule,
|
|
2231
|
-
version: "1.
|
|
2255
|
+
version: "1.10.0"
|
|
2232
2256
|
});
|
|
2233
2257
|
if (!result.success) {
|
|
2234
2258
|
console.error(result.error);
|
|
@@ -2242,7 +2266,9 @@ daemon.command("start").description("Start the daemon process").option(
|
|
|
2242
2266
|
"Hint: won't survive a reboot. Use `cc-ping daemon install` for a persistent service."
|
|
2243
2267
|
);
|
|
2244
2268
|
}
|
|
2245
|
-
printAccountTable(console.log, /* @__PURE__ */ new Date(), getDeferredHandles()
|
|
2269
|
+
printAccountTable(console.log, /* @__PURE__ */ new Date(), getDeferredHandles(), {
|
|
2270
|
+
censor: program.opts().censor
|
|
2271
|
+
});
|
|
2246
2272
|
});
|
|
2247
2273
|
daemon.command("stop").description("Stop the daemon process").action(async () => {
|
|
2248
2274
|
const result = await stopDaemon();
|
|
@@ -2262,7 +2288,7 @@ daemon.command("stop").description("Stop the daemon process").action(async () =>
|
|
|
2262
2288
|
daemon.command("status").description("Show daemon status").option("--json", "Output as JSON", false).action(async (opts) => {
|
|
2263
2289
|
const { getServiceStatus: getServiceStatus2 } = await Promise.resolve().then(() => (init_service(), service_exports));
|
|
2264
2290
|
const svc = getServiceStatus2();
|
|
2265
|
-
const status = getDaemonStatus({ currentVersion: "1.
|
|
2291
|
+
const status = getDaemonStatus({ currentVersion: "1.10.0" });
|
|
2266
2292
|
if (opts.json) {
|
|
2267
2293
|
const serviceInfo = svc.installed ? {
|
|
2268
2294
|
service: {
|
|
@@ -2323,7 +2349,7 @@ daemon.command("status").description("Show daemon status").option("--json", "Out
|
|
|
2323
2349
|
if (status.versionMismatch) {
|
|
2324
2350
|
console.log(
|
|
2325
2351
|
yellow(
|
|
2326
|
-
` Warning: daemon is running v${status.daemonVersion} but v${"1.
|
|
2352
|
+
` Warning: daemon is running v${status.daemonVersion} but v${"1.10.0"} is installed.`
|
|
2327
2353
|
)
|
|
2328
2354
|
);
|
|
2329
2355
|
console.log(
|
|
@@ -2333,7 +2359,9 @@ daemon.command("status").description("Show daemon status").option("--json", "Out
|
|
|
2333
2359
|
);
|
|
2334
2360
|
}
|
|
2335
2361
|
console.log("");
|
|
2336
|
-
printAccountTable(console.log, /* @__PURE__ */ new Date(), getDeferredHandles()
|
|
2362
|
+
printAccountTable(console.log, /* @__PURE__ */ new Date(), getDeferredHandles(), {
|
|
2363
|
+
censor: program.opts().censor
|
|
2364
|
+
});
|
|
2337
2365
|
});
|
|
2338
2366
|
daemon.command("install").description("Install daemon as a system service (launchd/systemd)").option(
|
|
2339
2367
|
"--interval <minutes>",
|
|
@@ -2389,7 +2417,7 @@ daemon.command("_run", { hidden: true }).option("--interval-ms <ms>", "Ping inte
|
|
|
2389
2417
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2390
2418
|
intervalMs,
|
|
2391
2419
|
configDir: resolveConfigDir2(),
|
|
2392
|
-
version: "1.
|
|
2420
|
+
version: "1.10.0"
|
|
2393
2421
|
});
|
|
2394
2422
|
}
|
|
2395
2423
|
await runDaemonWithDefaults(intervalMs, {
|