claude-friends 0.4.14 → 0.4.16

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/package.json +1 -1
  2. package/statusline.js +13 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-friends",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
4
4
  "description": "See who's online in Claude Code. Add friends, share status, nudge each other.",
5
5
  "type": "module",
6
6
  "bin": {
package/statusline.js CHANGED
@@ -84,11 +84,18 @@ if (data.transcript_path) {
84
84
  } catch {}
85
85
  }
86
86
 
87
- // 6. Cost
88
- if (data.cost?.total_cost_usd != null) {
89
- const cost = data.cost.total_cost_usd;
90
- const color = cost > 10 ? YELLOW : GREEN;
91
- segments.push(`${color}$${cost.toFixed(2)}${RESET}`);
87
+ // 6. Usage remaining (bar) — rate limits if available, else context window
88
+ const fiveHr = data.rate_limits?.five_hour;
89
+ const ctxUsed = data.context_window?.used_percentage;
90
+ const usedPct = fiveHr?.used_percentage ?? ctxUsed;
91
+ {
92
+ const remaining = usedPct != null ? Math.max(0, 100 - usedPct) : 100;
93
+ const label = fiveHr?.used_percentage != null ? "" : "ctx ";
94
+ const BAR_WIDTH = 8;
95
+ const filled = Math.round((remaining / 100) * BAR_WIDTH);
96
+ const bar = "█".repeat(filled) + "░".repeat(BAR_WIDTH - filled);
97
+ const color = remaining < 5 ? "\x1b[31m" : remaining < 20 ? YELLOW : GREEN;
98
+ segments.push(`${color}[${bar}] ${label}${remaining.toFixed(0)}%${RESET}`);
92
99
  }
93
100
 
94
101
  // 7. Streak
@@ -124,7 +131,7 @@ function formatNum(n) {
124
131
  function getFriendsOnline() {
125
132
  try {
126
133
  const cache = JSON.parse(readFileSync(join(homedir(), ".claude-friends-online.json"), "utf-8"));
127
- if (Date.now() - cache.timestamp > 30000) return { count: 0, names: [] };
134
+ if (Date.now() - cache.lastUpdate > 30000) return { count: 0, names: [] };
128
135
  return { count: cache.onlineCount || 0, names: cache.onlineNames || [] };
129
136
  } catch {
130
137
  return { count: 0, names: [] };