buddy-reroll 0.3.6 → 0.3.7

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/README.md CHANGED
@@ -12,16 +12,13 @@ Pick the perfect [Claude Code](https://docs.anthropic.com/en/docs/claude-code) `
12
12
 
13
13
  ```bash
14
14
  # Bun (recommended)
15
- bun install -g buddy-reroll
15
+ bunx buddy-reroll
16
16
 
17
17
  # npm
18
- npm install -g buddy-reroll
19
-
20
- # No install needed
21
18
  npx buddy-reroll
22
19
  ```
23
20
 
24
- Bun gives the speediest experience, but Node.js >= 20 works just as well.
21
+ Bun is faster, but Node.js >= 20 produces identical results — no Bun required.
25
22
 
26
23
  ## Usage
27
24
 
@@ -87,12 +84,12 @@ buddy-reroll --unhook # remove whenever you want
87
84
 
88
85
  ## How fast is it?
89
86
 
90
- buddy-reroll uses all your CPU cores (up to 8) to find the right companion. Bun is a bit faster because of its native hashing, but both runtimes produce identical results.
87
+ buddy-reroll uses all your CPU cores (up to 8) to find the right companion. Both runtimes use the same wyhash algorithm as Claude Code, so your buddy will always match `/buddy` exactly.
91
88
 
92
- | Runtime | Speed | Notes |
89
+ | Runtime | Speed | Hash |
93
90
  |---|---|---|
94
- | Bun | Faster | Recommended |
95
- | Node.js >= 20 | Slightly slower | Works great too |
91
+ | Bun | Faster (native `Bun.hash`) | wyhash |
92
+ | Node.js >= 20 | Slightly slower (pure JS) | wyhash |
96
93
 
97
94
  ## Requirements
98
95
 
package/lib/estimator.js CHANGED
@@ -16,28 +16,27 @@ export function estimateAttempts(target) {
16
16
  return Math.round(1 / probability);
17
17
  }
18
18
 
19
+ function formatTime(seconds) {
20
+ if (seconds < 60) return Math.round(seconds) + "s";
21
+ const minutes = Math.floor(seconds / 60);
22
+ const secs = Math.round(seconds % 60);
23
+ return minutes + "m " + secs + "s";
24
+ }
25
+
26
+ function formatRate(rate) {
27
+ if (rate >= 1_000_000) return (rate / 1_000_000).toFixed(1) + "M/s";
28
+ if (rate >= 1_000) return (rate / 1_000).toFixed(1) + "k/s";
29
+ return rate.toFixed(1) + "/s";
30
+ }
31
+
19
32
  export function formatProgress(attempts, elapsed, expected, workers) {
20
- const pct = Math.min(100, Math.round((attempts / expected) * 100));
21
- const rate = attempts / (elapsed / 1000);
22
-
23
- let rateStr;
24
- if (rate >= 1_000_000) {
25
- rateStr = (rate / 1_000_000).toFixed(1) + "M tries/s";
26
- } else if (rate >= 1_000) {
27
- rateStr = (rate / 1_000).toFixed(1) + "k tries/s";
28
- } else {
29
- rateStr = rate.toFixed(1) + " tries/s";
30
- }
33
+ const elapsedSec = elapsed / 1000;
34
+ const rate = attempts / elapsedSec;
31
35
 
32
- const remaining = Math.max(0, (expected - attempts) / rate);
33
- let etaStr;
34
- if (remaining < 60) {
35
- etaStr = Math.round(remaining) + "s";
36
- } else {
37
- const minutes = Math.floor(remaining / 60);
38
- const seconds = Math.round(remaining % 60);
39
- etaStr = minutes + "m " + seconds + "s";
36
+ if (attempts >= expected) {
37
+ return `Still searching... ${formatTime(elapsedSec)} | ${formatRate(rate)} | taking longer than usual`;
40
38
  }
41
39
 
42
- return `${pct}% | ${rateStr} | ~${etaStr} left | ${workers} cores`;
40
+ const remaining = (expected - attempts) / rate;
41
+ return `Searching... ${formatTime(elapsedSec)} | ${formatRate(rate)} | ~${formatTime(remaining)} left`;
43
42
  }
@@ -59,39 +59,41 @@ describe("estimateAttempts", () => {
59
59
  });
60
60
 
61
61
  describe("formatProgress", () => {
62
- it("formats progress with millions of salts per second", () => {
62
+ it("shows elapsed time and rate", () => {
63
63
  const result = formatProgress(5_000_000, 2000, 10_000_000, 8);
64
- expect(result).toContain("50%");
65
- expect(result).toContain("2.5M tries/s");
66
- expect(result).toContain("8 cores");
64
+ expect(result).toContain("Searching...");
65
+ expect(result).toContain("2s");
66
+ expect(result).toContain("2.5M/s");
67
67
  });
68
68
 
69
- it("formats progress with thousands of salts per second", () => {
69
+ it("shows ETA when under expected", () => {
70
70
  const result = formatProgress(50_000, 5000, 100_000, 4);
71
- expect(result).toContain("50%");
72
- expect(result).toContain("10.0k tries/s");
73
- expect(result).toContain("4 cores");
74
- });
75
-
76
- it("formats ETA in seconds", () => {
77
- const result = formatProgress(9_000_000, 1000, 10_000_000, 8);
71
+ expect(result).toContain("Searching...");
78
72
  expect(result).toContain("left");
79
- expect(result).toContain("s");
80
73
  });
81
74
 
82
75
  it("formats ETA in minutes and seconds", () => {
83
76
  const result = formatProgress(1_000_000, 1000, 100_000_000, 8);
84
77
  expect(result).toContain("m");
78
+ expect(result).toContain("left");
79
+ });
80
+
81
+ it("shows 'taking longer than usual' past expected", () => {
82
+ const result = formatProgress(10_000_000, 2000, 10_000_000, 8);
83
+ expect(result).toContain("Still searching...");
84
+ expect(result).toContain("taking longer than usual");
85
+ expect(result).not.toContain("left");
85
86
  });
86
87
 
87
- it("caps percentage at 100", () => {
88
- const result = formatProgress(10_000_000, 1000, 10_000_000, 8);
89
- expect(result).toContain("100%");
88
+ it("shows 'taking longer than usual' well past expected", () => {
89
+ const result = formatProgress(30_000_000, 6000, 10_000_000, 8);
90
+ expect(result).toContain("Still searching...");
91
+ expect(result).toContain("6s");
90
92
  });
91
93
 
92
- it("handles zero elapsed time gracefully", () => {
94
+ it("handles very small elapsed time", () => {
93
95
  const result = formatProgress(1_000_000, 1, 10_000_000, 8);
94
- expect(result).toContain("%");
95
- expect(result).toContain("tries/s");
96
+ expect(result).toContain("Searching...");
97
+ expect(result).toContain("/s");
96
98
  });
97
99
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buddy-reroll",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Reroll your Claude Code buddy companion to any species/rarity/eye/hat/shiny combo",
5
5
  "type": "module",
6
6
  "bin": {
package/ui-fallback.js CHANGED
@@ -155,11 +155,16 @@ export async function runInteractiveUI(opts) {
155
155
  let found;
156
156
  try {
157
157
  found = await bruteForce(userId, target, (attempts, elapsed, expected, workers) => {
158
- const pct = Math.min(100, Math.round((attempts / expected) * 100));
159
- const rate = attempts / (elapsed / 1000);
160
- const rateStr = rate >= 1e6 ? `${(rate / 1e6).toFixed(1)}M` : `${(rate / 1e3).toFixed(1)}k`;
161
- const eta = Math.max(0, (expected - attempts) / rate);
162
- process.stdout.write(`\r ${pct}% | ${rateStr} tries/s | ~${Math.round(eta)}s left | ${workers} cores`);
158
+ const elapsedSec = elapsed / 1000;
159
+ const rate = attempts / elapsedSec;
160
+ const rateStr = rate >= 1e6 ? `${(rate / 1e6).toFixed(1)}M/s` : `${(rate / 1e3).toFixed(1)}k/s`;
161
+ const fmtTime = (s) => s < 60 ? `${Math.round(s)}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
162
+ if (attempts >= expected) {
163
+ process.stdout.write(`\r Still searching... ${fmtTime(elapsedSec)} | ${rateStr} | taking longer than usual`);
164
+ } else {
165
+ const remaining = (expected - attempts) / rate;
166
+ process.stdout.write(`\r Searching... ${fmtTime(elapsedSec)} | ${rateStr} | ~${fmtTime(remaining)} left`);
167
+ }
163
168
  });
164
169
  } catch (err) {
165
170
  console.log(chalk.red(`\n✗ ${err.message}`));
package/ui.jsx CHANGED
@@ -213,11 +213,16 @@ function SearchStep({ userId, target, bruteForce, onFound, onFail, isActive }) {
213
213
  try {
214
214
  found = await bruteForce(userId, target, (attempts, elapsed, expected, workers) => {
215
215
  if (!ac.signal.aborted) {
216
- const pct = Math.min(100, Math.round((attempts / expected) * 100));
217
- const rate = attempts / (elapsed / 1000);
218
- const rateStr = rate >= 1e6 ? `${(rate / 1e6).toFixed(1)}M` : `${(rate / 1e3).toFixed(1)}k`;
219
- const eta = Math.max(0, (expected - attempts) / rate);
220
- setProgress(`${pct}% | ${rateStr} tries/s | ~${Math.round(eta)}s left | ${workers} cores`);
216
+ const elapsedSec = elapsed / 1000;
217
+ const rate = attempts / elapsedSec;
218
+ const rateStr = rate >= 1e6 ? `${(rate / 1e6).toFixed(1)}M/s` : `${(rate / 1e3).toFixed(1)}k/s`;
219
+ const fmtTime = (s) => s < 60 ? `${Math.round(s)}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
220
+ if (attempts >= expected) {
221
+ setProgress(`Still searching... ${fmtTime(elapsedSec)} | ${rateStr} | taking longer than usual`);
222
+ } else {
223
+ const remaining = (expected - attempts) / rate;
224
+ setProgress(`Searching... ${fmtTime(elapsedSec)} | ${rateStr} | ~${fmtTime(remaining)} left`);
225
+ }
221
226
  }
222
227
  }, ac.signal);
223
228
  } catch {