Skip to content

feat: bundle ripgrep into the Windows platform packages - #309

Merged
quickbeard merged 1 commit into
mainfrom
bundle-ripgrep-windows
Aug 24, 2026
Merged

quickbeard merged 1 commit into
mainfrom
bundle-ripgrep-windows

Conversation

@quickbeard

@quickbeard quickbeard commented Aug 24, 2026 •

Copy link
Copy Markdown
Owner

Why

On Windows fff is disabled, so file search and the @ mention popup depend entirely on ripgrep. When rg isn't already on the machine, the agent's runtime fallback downloads it from GitHub — exactly the host corporate networks block — so a bare npm i -g codev-code landed with silently empty file search. codevhub install already stages rg into the agent's cache, but direct npm installs had nothing.

What

  • script/build.ts — each win32 target now stages ripgrep at bin/rg.exe in its platform package, under a build-side RG_VERSION pin: "latest" (the default) resolves the newest GitHub release per build via the releases API; an exact version (e.g. "15.1.0") pins its release tag. The asset zip is extracted in-memory with @zip.js/zip.js (no unzip/powershell host dependency, so local builds work from macOS or Windows) and magic-byte-checked so a proxy block page (200 + HTML) can't be packed as a binary. One release lookup per build; x64 and x64-baseline share one download per arch. This pin is independent of binary.ts's VERSION, which governs only the runtime download fallback (the CoDev mirror hosts just that version and is not used at build time).
  • script/postinstall.mjs — best-effort copyRipgrep puts the bundled rg.exe next to the codev binary on both resolution paths (in the temp npm-install path before its cleanup deletes the package). It can never fail the install.
  • packages/core/src/ripgrep/binary.ts — on win32, resolution checks for rg.exe beside process.execPath (bun standalone executables report their own location) after PATH and before the cache and the network, so no download is needed at all.
  • DIVERGENCES.md rows for all three files updated; CHANGELOG entry under Install.

Non-Windows platforms are unchanged: nothing is bundled there and resolution is untouched (rg on PATH still wins everywhere). Package cost: ~2 MB gzipped on ~55 MB tarballs, win32 only. The GitHub-release win32 zips (built from the same bin/ dirs) gain rg.exe too.

Testing

  • bun typecheck clean in packages/core and packages/opencode; node --check on postinstall.mjs.
  • bun test test/ripgrep-binary.test.ts test/ripgrep.test.ts in packages/core: 5 pass.
  • Both pin modes exercised standalone against the live API: latest → 15.2.0, 15.1.0 → 15.1.0, each resolving both win32 arch assets; the download+zip.js extraction path verified end-to-end (arm64 → 3,859,456 bytes, x64 → 4,218,880 bytes, valid MZ executables).
  • Not exercised: a full release build (12 targets) — the next local release run covers the build.ts integration point (3 lines, gated on item.os === "win32"); check dist/opencode-windows-*/bin/rg.exe exists before publishing.

🤖 Generated with Claude Code

@quickbeard
quickbeard force-pushed the bundle-ripgrep-windows branch 2 times, most recently from 86ab1a8 to 07d61b0 Compare August 24, 2026 02:39
On Windows fff is disabled, so file search and the @ mention popup depend
entirely on ripgrep — and when rg isn't already on the machine, the agent's
runtime fallback downloads it from GitHub, exactly the host corporate
networks block. A bare `npm i -g codev-code` therefore landed with silently
empty file search. (codevhub install already papers over this by staging rg
into the agent's cache; direct npm installs had nothing.)

- build.ts stages ripgrep into each win32 platform package's bin/rg.exe
  under its own RG_VERSION pin: "latest" (the default) resolves the newest
  GitHub release per build via the releases API, an exact version pins its
  release tag. Asset zips are extracted in-memory with @zip.js/zip.js so
  builds work on any host platform, and magic-byte-checked against proxy
  block pages; x64/baseline share one download. Independent of binary.ts's
  pinned VERSION, which governs only the runtime download fallback.
- postinstall.mjs best-effort copies the bundled bin/rg.exe next to the
  codev binary on both resolution paths; it can never fail the install.
- RipgrepBinary.resolve (win32 only) checks for rg.exe beside
  process.execPath after PATH and before the cache and the network.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@quickbeard
quickbeard force-pushed the bundle-ripgrep-windows branch from 07d61b0 to 6c8ddbb Compare August 24, 2026 02:43
@quickbeard
quickbeard merged commit ac9a86e into main Aug 24, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the bundle-ripgrep-windows branch August 24, 2026 02:48
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.

1 participant