@wbern/cc-ping 1.1.0 → 1.3.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 +30 -19
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1164,6 +1164,7 @@ var init_service = __esm({
1164
1164
  });
1165
1165
 
1166
1166
  // src/cli.ts
1167
+ import { basename } from "path";
1167
1168
  import { Command } from "commander";
1168
1169
 
1169
1170
  // src/check.ts
@@ -1242,7 +1243,7 @@ function bashCompletion() {
1242
1243
  fi
1243
1244
  ;;
1244
1245
  add)
1245
- COMPREPLY=( $(compgen -W "--group" -- "\${cur}") )
1246
+ COMPREPLY=( $(compgen -W "--name --group" -- "\${cur}") )
1246
1247
  ;;
1247
1248
  list|history|status|next-reset|check)
1248
1249
  COMPREPLY=( $(compgen -W "--json" -- "\${cur}") )
@@ -1321,7 +1322,7 @@ _cc_ping() {
1321
1322
  _arguments '--json[JSON output]'
1322
1323
  ;;
1323
1324
  add)
1324
- _arguments '--group[Assign group]:group:'
1325
+ _arguments '--name[Override handle]:name:' '--group[Assign group]:group:'
1325
1326
  ;;
1326
1327
  daemon)
1327
1328
  local -a subcmds
@@ -1389,6 +1390,7 @@ complete -c cc-ping -n "__fish_seen_subcommand_from ping" -l stagger -r -d "Dela
1389
1390
  complete -c cc-ping -n "__fish_seen_subcommand_from ping" -a "(cc-ping list 2>/dev/null | string replace -r ' *(.*) ->.*' '$1')"
1390
1391
 
1391
1392
  complete -c cc-ping -n "__fish_seen_subcommand_from list history status next-reset check" -l json -d "JSON output"
1393
+ complete -c cc-ping -n "__fish_seen_subcommand_from add" -s n -l name -r -d "Override handle"
1392
1394
  complete -c cc-ping -n "__fish_seen_subcommand_from add" -s g -l group -r -d "Assign group"
1393
1395
  complete -c cc-ping -n "__fish_seen_subcommand_from completions" -a "bash zsh fish"
1394
1396
 
@@ -1554,7 +1556,7 @@ function showDefault(log = console.log, now = /* @__PURE__ */ new Date()) {
1554
1556
  log("No accounts configured.");
1555
1557
  log("\nGet started:");
1556
1558
  log(" cc-ping scan Auto-discover accounts");
1557
- log(" cc-ping add <h> <d> Add an account manually");
1559
+ log(" cc-ping add <dir> Add an account manually");
1558
1560
  return;
1559
1561
  }
1560
1562
  const dupes = findDuplicates(accounts);
@@ -1566,17 +1568,13 @@ function showDefault(log = console.log, now = /* @__PURE__ */ new Date()) {
1566
1568
  if (needsPing.length > 0) {
1567
1569
  log("");
1568
1570
  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
- }
1571
+ log(" cc-ping ping Ping accounts that need it");
1575
1572
  log(" cc-ping daemon start Auto-ping on a schedule");
1576
1573
  }
1577
1574
  }
1578
1575
 
1579
1576
  // src/filter-accounts.ts
1577
+ init_state();
1580
1578
  function filterAccounts(accounts, handles) {
1581
1579
  if (handles.length === 0) return accounts;
1582
1580
  const unknown = handles.filter((h) => !accounts.some((a) => a.handle === h));
@@ -1586,6 +1584,9 @@ function filterAccounts(accounts, handles) {
1586
1584
  const set = new Set(handles);
1587
1585
  return accounts.filter((a) => set.has(a.handle));
1588
1586
  }
1587
+ function filterNeedsPing(accounts, now = /* @__PURE__ */ new Date()) {
1588
+ return accounts.filter((a) => !getWindowReset(a.handle, now));
1589
+ }
1589
1590
  function filterByGroup(accounts, group) {
1590
1591
  if (!group) return accounts;
1591
1592
  const filtered = accounts.filter((a) => a.group === group);
@@ -1690,7 +1691,7 @@ function suggestAccount(accounts, now = /* @__PURE__ */ new Date()) {
1690
1691
  }
1691
1692
 
1692
1693
  // 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(
1694
+ var program = new Command().name("cc-ping").description("Ping Claude Code sessions to trigger quota windows early").version("1.3.0").option(
1694
1695
  "--config <path>",
1695
1696
  "Path to config directory (default: ~/.config/cc-ping, env: CC_PING_CONFIG)"
1696
1697
  ).hook("preAction", (thisCommand) => {
@@ -1701,7 +1702,10 @@ var program = new Command().name("cc-ping").description("Ping Claude Code sessio
1701
1702
  }).action(() => {
1702
1703
  showDefault();
1703
1704
  });
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(
1705
+ program.command("ping").description("Ping configured accounts to start quota windows").argument(
1706
+ "[handles...]",
1707
+ "Specific handles to ping (default: accounts that need it)"
1708
+ ).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
1709
  "--stagger <minutes|auto>",
1706
1710
  "Delay between account pings (minutes or 'auto')"
1707
1711
  ).action(async (handles, opts) => {
@@ -1712,10 +1716,13 @@ program.command("ping").description("Ping configured accounts to start quota win
1712
1716
  );
1713
1717
  process.exit(1);
1714
1718
  }
1715
- const targets = filterAccounts(
1716
- filterByGroup(accounts, opts.group),
1717
- handles
1718
- );
1719
+ const grouped = filterByGroup(accounts, opts.group);
1720
+ const selected = handles.length > 0 ? filterAccounts(grouped, handles) : grouped;
1721
+ const targets = handles.length > 0 ? selected : filterNeedsPing(selected);
1722
+ if (targets.length === 0) {
1723
+ console.log("All accounts have active windows. Nothing to ping.");
1724
+ process.exit(0);
1725
+ }
1719
1726
  const staggerMs = opts.stagger ? parseStagger(opts.stagger, targets.length) : void 0;
1720
1727
  const exitCode = await runPing(targets, {
1721
1728
  parallel: opts.parallel,
@@ -1774,7 +1781,11 @@ program.command("scan").description("Auto-discover accounts from ~/.claude-accou
1774
1781
  }
1775
1782
  }
1776
1783
  });
1777
- program.command("add").description("Add an account manually").argument("<handle>", "Account handle/name").argument("<config-dir>", "Path to the CLAUDE_CONFIG_DIR for this account").option("-g, --group <group>", "Assign account to a group").action((handle, configDir, opts) => {
1784
+ program.command("add").description("Add an account manually").argument("<config-dir>", "Path to the CLAUDE_CONFIG_DIR for this account").option(
1785
+ "-n, --name <name>",
1786
+ "Override account handle (default: directory name)"
1787
+ ).option("-g, --group <group>", "Assign account to a group").action((configDir, opts) => {
1788
+ const handle = opts.name || basename(configDir);
1778
1789
  addAccount(handle, configDir, opts.group);
1779
1790
  const groupInfo = opts.group ? ` [${opts.group}]` : "";
1780
1791
  console.log(`Added: ${handle} -> ${configDir}${groupInfo}`);
@@ -1902,7 +1913,7 @@ daemon.command("start").description("Start the daemon process").option(
1902
1913
  const svc = getServiceStatus2();
1903
1914
  if (!svc.installed) {
1904
1915
  console.log(
1905
- "Hint: won't survive a reboot. Use `daemon install` for a persistent service."
1916
+ "Hint: won't survive a reboot. Use `cc-ping daemon install` for a persistent service."
1906
1917
  );
1907
1918
  }
1908
1919
  printAccountTable();
@@ -1918,7 +1929,7 @@ daemon.command("stop").description("Stop the daemon process").action(async () =>
1918
1929
  const svc = getServiceStatus2();
1919
1930
  if (svc.installed) {
1920
1931
  console.log(
1921
- "Note: system service is installed. The daemon may restart. Use `daemon uninstall` to fully remove."
1932
+ "Note: system service is installed. The daemon may restart. Use `cc-ping daemon uninstall` to fully remove."
1922
1933
  );
1923
1934
  }
1924
1935
  });
@@ -1994,7 +2005,7 @@ daemon.command("install").description("Install daemon as a system service (launc
1994
2005
  }
1995
2006
  console.log(`Service installed: ${result.servicePath}`);
1996
2007
  console.log(
1997
- "The daemon will start automatically on login. Use `daemon uninstall` to remove."
2008
+ "The daemon will start automatically on login. Use `cc-ping daemon uninstall` to remove."
1998
2009
  );
1999
2010
  });
2000
2011
  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.3.0",
4
4
  "description": "Ping Claude Code sessions to trigger quota windows early across multiple accounts",
5
5
  "type": "module",
6
6
  "bin": {