Skip to content

fix: use FNV-1a hash for Node-based Claude installs (Windows npm)#8

Merged
cpaczek merged 1 commit into
cpaczek:mainfrom
joshpocock:fix/windows-node-fnv1a
Apr 2, 2026
Merged

fix: use FNV-1a hash for Node-based Claude installs (Windows npm)#8
cpaczek merged 1 commit into
cpaczek:mainfrom
joshpocock:fix/windows-node-fnv1a

Conversation

@joshpocock

Copy link
Copy Markdown
Contributor

Summary

  • On Windows npm installs, Claude Code runs via node cli.js (not Bun). The companion hash function has a runtime branch — Bun.hash (wyhash) under Bun, FNV-1a under Node. The finder was always using Bun.hash, so salts it found produced the wrong pet when Claude actually ran under Node.
  • This fix auto-detects .js/.mjs binaries as Node runtime and uses FNV-1a for salt brute-forcing
  • Bun is no longer required for Node-based installs

Changes

  • patcher.mjs: Added isNodeRuntime() detection
  • finder-worker.mjs: Added --fnv1a flag to use FNV-1a instead of Bun.hash
  • finder.mjs: Detects Node runtime, passes --fnv1a, runs worker under Node instead of Bun
  • generation.mjs: Added useNodeHash option to hashString() and roll()
  • preflight.mjs: Bun check is now skipped for Node-based installs
  • tui.mjs: Passes runtime detection through to finder and generation

Test plan

  • Verified on Windows npm install (cli.js) — FNV-1a salt produces correct pet
  • isNodeRuntime() correctly identifies .js and .mjs files
  • roll() with useNodeHash: true matches Claude Code's actual output under Node
  • Verify compiled binary installs (Linux/macOS) still use Bun.hash as before

🤖 Generated with Claude Code

Claude Code's companion hash function has a runtime branch:
- Under Bun: uses Bun.hash (wyhash)
- Under Node: uses FNV-1a

On Windows npm installs, Claude Code runs via `node cli.js`, not Bun.
The finder was always using Bun.hash to brute-force salts, producing
salts that give the wrong pet when Claude actually runs under Node.

This fix:
- Detects if the Claude binary is a .js file (Node runtime)
- Uses FNV-1a in the finder worker when targeting Node installs
- Runs the worker under Node (not Bun) for FNV-1a mode
- Makes Bun optional for Node-based installs
- Passes useNodeHash through generation.mjs and tui.mjs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cpaczek

cpaczek commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Ah okay, I think i'm going to remove bun a dependency and just try to do the hasing all in node I was just lazy and wanted to reuse bun hash but it seems like they don't always use that? Thank you for this tho its very helpful. planning on tackling this tonight

@cpaczek cpaczek merged commit cd2ec38 into cpaczek:main Apr 2, 2026
cpaczek added a commit that referenced this pull request Apr 2, 2026
perf: multi-worker parallelism + early-exit (merges #11 with #8 and #10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants