@wbern/cc-ping 1.1.0 → 1.2.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.
Files changed (2) hide show
  1. package/dist/cli.js +20 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1566,17 +1566,13 @@ function showDefault(log = console.log, now = /* @__PURE__ */ new Date()) {
1566
1566
  if (needsPing.length > 0) {
1567
1567
  log("");
1568
1568
  log("Suggested next steps:");
1569
- const handles = needsPing.map((s) => s.handle).join(" ");
1570
- if (needsPing.length < statuses.length) {
1571
- log(` cc-ping ping ${handles} Ping accounts that need it`);
1572
- } else {
1573
- log(" cc-ping ping Ping all accounts");
1574
- }
1569
+ log(" cc-ping ping Ping accounts that need it");
1575
1570
  log(" cc-ping daemon start Auto-ping on a schedule");
1576
1571
  }
1577
1572
  }
1578
1573
 
1579
1574
  // src/filter-accounts.ts
1575
+ init_state();
1580
1576
  function filterAccounts(accounts, handles) {
1581
1577
  if (handles.length === 0) return accounts;
1582
1578
  const unknown = handles.filter((h) => !accounts.some((a) => a.handle === h));
@@ -1586,6 +1582,9 @@ function filterAccounts(accounts, handles) {
1586
1582
  const set = new Set(handles);
1587
1583
  return accounts.filter((a) => set.has(a.handle));
1588
1584
  }
1585
+ function filterNeedsPing(accounts, now = /* @__PURE__ */ new Date()) {
1586
+ return accounts.filter((a) => !getWindowReset(a.handle, now));
1587
+ }
1589
1588
  function filterByGroup(accounts, group) {
1590
1589
  if (!group) return accounts;
1591
1590
  const filtered = accounts.filter((a) => a.group === group);
@@ -1690,7 +1689,7 @@ function suggestAccount(accounts, now = /* @__PURE__ */ new Date()) {
1690
1689
  }
1691
1690
 
1692
1691
  // src/cli.ts
1693
- var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.1.0").option(
1692
+ var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.2.0").option(
1694
1693
  "--config <path>",
1695
1694
  "Path to config directory (default: ~/.config/cc-ping, env: CC_PING_CONFIG)"
1696
1695
  ).hook("preAction", (thisCommand) => {
@@ -1701,7 +1700,10 @@ var program = new Command().name("cc-ping").description("Ping Claude Code sessio
1701
1700
  }).action(() => {
1702
1701
  showDefault();
1703
1702
  });
1704
- program.command("ping").description("Ping configured accounts to start quota windows").argument("[handles...]", "Specific account handles to ping (default: all)").option("--parallel", "Ping all accounts in parallel", false).option("-q, --quiet", "Suppress all output except errors (for cron)", false).option("--json", "Output results as JSON", false).option("-g, --group <group>", "Ping only accounts in this group").option("--bell", "Ring terminal bell on ping failure", false).option("--notify", "Send desktop notification on ping failure", false).option(
1703
+ program.command("ping").description("Ping configured accounts to start quota windows").argument(
1704
+ "[handles...]",
1705
+ "Specific handles to ping (default: accounts that need it)"
1706
+ ).option("--parallel", "Ping all accounts in parallel", false).option("-q, --quiet", "Suppress all output except errors (for cron)", false).option("--json", "Output results as JSON", false).option("-g, --group <group>", "Ping only accounts in this group").option("--bell", "Ring terminal bell on ping failure", false).option("--notify", "Send desktop notification on ping failure", false).option(
1705
1707
  "--stagger <minutes|auto>",
1706
1708
  "Delay between account pings (minutes or 'auto')"
1707
1709
  ).action(async (handles, opts) => {
@@ -1712,10 +1714,13 @@ program.command("ping").description("Ping configured accounts to start quota win
1712
1714
  );
1713
1715
  process.exit(1);
1714
1716
  }
1715
- const targets = filterAccounts(
1716
- filterByGroup(accounts, opts.group),
1717
- handles
1718
- );
1717
+ const grouped = filterByGroup(accounts, opts.group);
1718
+ const selected = handles.length > 0 ? filterAccounts(grouped, handles) : grouped;
1719
+ const targets = handles.length > 0 ? selected : filterNeedsPing(selected);
1720
+ if (targets.length === 0) {
1721
+ console.log("All accounts have active windows. Nothing to ping.");
1722
+ process.exit(0);
1723
+ }
1719
1724
  const staggerMs = opts.stagger ? parseStagger(opts.stagger, targets.length) : void 0;
1720
1725
  const exitCode = await runPing(targets, {
1721
1726
  parallel: opts.parallel,
@@ -1902,7 +1907,7 @@ daemon.command("start").description("Start the daemon process").option(
1902
1907
  const svc = getServiceStatus2();
1903
1908
  if (!svc.installed) {
1904
1909
  console.log(
1905
- "Hint: won't survive a reboot. Use `daemon install` for a persistent service."
1910
+ "Hint: won't survive a reboot. Use `cc-ping daemon install` for a persistent service."
1906
1911
  );
1907
1912
  }
1908
1913
  printAccountTable();
@@ -1918,7 +1923,7 @@ daemon.command("stop").description("Stop the daemon process").action(async () =>
1918
1923
  const svc = getServiceStatus2();
1919
1924
  if (svc.installed) {
1920
1925
  console.log(
1921
- "Note: system service is installed. The daemon may restart. Use `daemon uninstall` to fully remove."
1926
+ "Note: system service is installed. The daemon may restart. Use `cc-ping daemon uninstall` to fully remove."
1922
1927
  );
1923
1928
  }
1924
1929
  });
@@ -1994,7 +1999,7 @@ daemon.command("install").description("Install daemon as a system service (launc
1994
1999
  }
1995
2000
  console.log(`Service installed: ${result.servicePath}`);
1996
2001
  console.log(
1997
- "The daemon will start automatically on login. Use `daemon uninstall` to remove."
2002
+ "The daemon will start automatically on login. Use `cc-ping daemon uninstall` to remove."
1998
2003
  );
1999
2004
  });
2000
2005
  daemon.command("uninstall").description("Remove daemon system service").action(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wbern/cc-ping",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Ping Claude Code sessions to trigger quota windows early across multiple accounts",
5
5
  "type": "module",
6
6
  "bin": {