@wbern/cc-ping 1.6.0 → 1.7.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 +52 -33
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,27 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/color.ts
|
|
13
|
+
function isColorEnabled() {
|
|
14
|
+
if (process.env.NO_COLOR) return false;
|
|
15
|
+
if (process.env.FORCE_COLOR === "1") return true;
|
|
16
|
+
if (process.env.FORCE_COLOR === "0") return false;
|
|
17
|
+
return process.stdout.isTTY ?? false;
|
|
18
|
+
}
|
|
19
|
+
function wrap(code, text) {
|
|
20
|
+
return isColorEnabled() ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
21
|
+
}
|
|
22
|
+
var green, red, yellow, blue;
|
|
23
|
+
var init_color = __esm({
|
|
24
|
+
"src/color.ts"() {
|
|
25
|
+
"use strict";
|
|
26
|
+
green = (text) => wrap("32", text);
|
|
27
|
+
red = (text) => wrap("31", text);
|
|
28
|
+
yellow = (text) => wrap("33", text);
|
|
29
|
+
blue = (text) => wrap("34", text);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
12
33
|
// src/paths.ts
|
|
13
34
|
var paths_exports = {};
|
|
14
35
|
__export(paths_exports, {
|
|
@@ -186,27 +207,6 @@ var init_bell = __esm({
|
|
|
186
207
|
}
|
|
187
208
|
});
|
|
188
209
|
|
|
189
|
-
// src/color.ts
|
|
190
|
-
function isColorEnabled() {
|
|
191
|
-
if (process.env.NO_COLOR) return false;
|
|
192
|
-
if (process.env.FORCE_COLOR === "1") return true;
|
|
193
|
-
if (process.env.FORCE_COLOR === "0") return false;
|
|
194
|
-
return process.stdout.isTTY ?? false;
|
|
195
|
-
}
|
|
196
|
-
function wrap(code, text) {
|
|
197
|
-
return isColorEnabled() ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
198
|
-
}
|
|
199
|
-
var green, red, yellow, blue;
|
|
200
|
-
var init_color = __esm({
|
|
201
|
-
"src/color.ts"() {
|
|
202
|
-
"use strict";
|
|
203
|
-
green = (text) => wrap("32", text);
|
|
204
|
-
red = (text) => wrap("31", text);
|
|
205
|
-
yellow = (text) => wrap("33", text);
|
|
206
|
-
blue = (text) => wrap("34", text);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
210
|
// src/history.ts
|
|
211
211
|
import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4 } from "fs";
|
|
212
212
|
import { join as join5 } from "path";
|
|
@@ -1466,6 +1466,9 @@ function checkAccounts(accounts) {
|
|
|
1466
1466
|
return accounts.map((a) => checkAccount(a));
|
|
1467
1467
|
}
|
|
1468
1468
|
|
|
1469
|
+
// src/cli.ts
|
|
1470
|
+
init_color();
|
|
1471
|
+
|
|
1469
1472
|
// src/completions.ts
|
|
1470
1473
|
var COMMANDS = "ping scan add remove list status next-reset history suggest check completions moo daemon";
|
|
1471
1474
|
function bashCompletion() {
|
|
@@ -1740,10 +1743,20 @@ function colorizeStatus(windowStatus) {
|
|
|
1740
1743
|
}
|
|
1741
1744
|
}
|
|
1742
1745
|
function formatStatusLine(status) {
|
|
1743
|
-
const
|
|
1744
|
-
const reset = status.timeUntilReset !== null ? ` (resets in ${status.timeUntilReset})` : "";
|
|
1746
|
+
const lines = [];
|
|
1745
1747
|
const dup = status.duplicateOf ? ` [duplicate of ${status.duplicateOf}]` : "";
|
|
1746
|
-
|
|
1748
|
+
lines.push(
|
|
1749
|
+
` ${status.handle}: ${colorizeStatus(status.windowStatus)}${dup}`
|
|
1750
|
+
);
|
|
1751
|
+
const ping = status.lastPing === null ? "never" : status.lastPing.replace("T", " ").replace(/\.\d+Z$/, "Z");
|
|
1752
|
+
lines.push(` - last ping: ${ping}`);
|
|
1753
|
+
if (status.timeUntilReset !== null) {
|
|
1754
|
+
lines.push(` - resets in ${status.timeUntilReset}`);
|
|
1755
|
+
}
|
|
1756
|
+
if (status.deferUntilUtcHour !== void 0) {
|
|
1757
|
+
lines.push(` - scheduled ping at ${status.deferUntilUtcHour}:00 UTC`);
|
|
1758
|
+
}
|
|
1759
|
+
return lines.join("\n");
|
|
1747
1760
|
}
|
|
1748
1761
|
function getAccountStatuses(accounts, now = /* @__PURE__ */ new Date(), duplicates, deferredHandles) {
|
|
1749
1762
|
const dupLookup = /* @__PURE__ */ new Map();
|
|
@@ -1775,6 +1788,7 @@ function getAccountStatuses(accounts, now = /* @__PURE__ */ new Date(), duplicat
|
|
|
1775
1788
|
}
|
|
1776
1789
|
const window = getWindowReset(account.handle, now);
|
|
1777
1790
|
const isDeferred = !window && deferredHandles?.has(account.handle);
|
|
1791
|
+
const deferUntilUtcHour = isDeferred ? deferredHandles?.get(account.handle) : void 0;
|
|
1778
1792
|
return {
|
|
1779
1793
|
handle: account.handle,
|
|
1780
1794
|
configDir: account.configDir,
|
|
@@ -1783,7 +1797,8 @@ function getAccountStatuses(accounts, now = /* @__PURE__ */ new Date(), duplicat
|
|
|
1783
1797
|
timeUntilReset: window ? formatTimeRemaining(window.remainingMs) : null,
|
|
1784
1798
|
lastCostUsd,
|
|
1785
1799
|
lastTokens,
|
|
1786
|
-
duplicateOf
|
|
1800
|
+
duplicateOf,
|
|
1801
|
+
deferUntilUtcHour
|
|
1787
1802
|
};
|
|
1788
1803
|
});
|
|
1789
1804
|
}
|
|
@@ -1946,17 +1961,17 @@ function suggestAccount(accounts, now = /* @__PURE__ */ new Date()) {
|
|
|
1946
1961
|
|
|
1947
1962
|
// src/cli.ts
|
|
1948
1963
|
function getDeferredHandles() {
|
|
1949
|
-
const deferred = /* @__PURE__ */ new
|
|
1964
|
+
const deferred = /* @__PURE__ */ new Map();
|
|
1950
1965
|
const now = /* @__PURE__ */ new Date();
|
|
1951
1966
|
for (const account of listAccounts()) {
|
|
1952
1967
|
const schedule = readAccountSchedule(account.configDir);
|
|
1953
1968
|
if (schedule && shouldDefer(now, schedule.optimalPingHour).defer) {
|
|
1954
|
-
deferred.
|
|
1969
|
+
deferred.set(account.handle, schedule.optimalPingHour);
|
|
1955
1970
|
}
|
|
1956
1971
|
}
|
|
1957
1972
|
return deferred;
|
|
1958
1973
|
}
|
|
1959
|
-
var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.
|
|
1974
|
+
var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.7.0").option(
|
|
1960
1975
|
"--config <path>",
|
|
1961
1976
|
"Path to config directory (default: ~/.config/cc-ping, env: CC_PING_CONFIG)"
|
|
1962
1977
|
).hook("preAction", (thisCommand) => {
|
|
@@ -2183,7 +2198,7 @@ daemon.command("start").description("Start the daemon process").option(
|
|
|
2183
2198
|
bell: opts.bell,
|
|
2184
2199
|
notify: opts.notify,
|
|
2185
2200
|
smartSchedule,
|
|
2186
|
-
version: "1.
|
|
2201
|
+
version: "1.7.0"
|
|
2187
2202
|
});
|
|
2188
2203
|
if (!result.success) {
|
|
2189
2204
|
console.error(result.error);
|
|
@@ -2217,7 +2232,7 @@ daemon.command("stop").description("Stop the daemon process").action(async () =>
|
|
|
2217
2232
|
daemon.command("status").description("Show daemon status").option("--json", "Output as JSON", false).action(async (opts) => {
|
|
2218
2233
|
const { getServiceStatus: getServiceStatus2 } = await Promise.resolve().then(() => (init_service(), service_exports));
|
|
2219
2234
|
const svc = getServiceStatus2();
|
|
2220
|
-
const status = getDaemonStatus({ currentVersion: "1.
|
|
2235
|
+
const status = getDaemonStatus({ currentVersion: "1.7.0" });
|
|
2221
2236
|
if (opts.json) {
|
|
2222
2237
|
const serviceInfo = svc.installed ? {
|
|
2223
2238
|
service: {
|
|
@@ -2277,10 +2292,14 @@ daemon.command("status").description("Show daemon status").option("--json", "Out
|
|
|
2277
2292
|
}
|
|
2278
2293
|
if (status.versionMismatch) {
|
|
2279
2294
|
console.log(
|
|
2280
|
-
|
|
2295
|
+
yellow(
|
|
2296
|
+
` Warning: daemon is running v${status.daemonVersion} but v${"1.7.0"} is installed.`
|
|
2297
|
+
)
|
|
2281
2298
|
);
|
|
2282
2299
|
console.log(
|
|
2283
|
-
|
|
2300
|
+
yellow(
|
|
2301
|
+
" Restart to pick up the new version: cc-ping daemon stop && cc-ping daemon start"
|
|
2302
|
+
)
|
|
2284
2303
|
);
|
|
2285
2304
|
}
|
|
2286
2305
|
console.log("");
|
|
@@ -2340,7 +2359,7 @@ daemon.command("_run", { hidden: true }).option("--interval-ms <ms>", "Ping inte
|
|
|
2340
2359
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2341
2360
|
intervalMs,
|
|
2342
2361
|
configDir: resolveConfigDir2(),
|
|
2343
|
-
version: "1.
|
|
2362
|
+
version: "1.7.0"
|
|
2344
2363
|
});
|
|
2345
2364
|
}
|
|
2346
2365
|
await runDaemonWithDefaults(intervalMs, {
|