fix(grep): probe OpenCode cache-backed bin for auto-downloaded rg (#3805)

Upstream OpenCode's Global.Path.bin resolves to ~/.cache/opencode/bin
(XDG cache), where its ripgrep auto-installer and many LSP servers land.
OMO's getOpenCodeBundledRg only checked the data-dir variant
(~/.local/share/opencode/bin), so when OpenCode had already downloaded
rg into its cache directory OMO would skip it and either redownload via
its own fallback installer or fall back to system grep.

Probe the cache-backed bin path first so OMO reuses tools OpenCode has
already installed.
This commit is contained in:
Yeachan-Heo
2026-05-24 01:23:57 +09:00
committed by YeonGyu-Kim
parent c0a6c667e6
commit 6c691a1afa
2 changed files with 61 additions and 1 deletions
+5 -1
View File
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process"
import { existsSync } from "node:fs"
import { dirname, join } from "node:path"
import { downloadAndInstallRipgrep, getInstalledRipgrepPath } from "../tools/grep/downloader"
import { getDataDir } from "./data-path"
import { getDataDir, getOpenCodeCacheDir } from "./data-path"
import { log } from "./logger"
import { PUBLISHED_PACKAGE_NAME } from "./plugin-identity"
@@ -48,6 +48,10 @@ function getOpenCodeBundledRg(): string | null {
const rgName = isWindows ? "rg.exe" : "rg"
const candidates = [
// #3805: Upstream OpenCode's Global.Path.bin is cache-backed (~/.cache/opencode/bin),
// and its auto-downloaded ripgrep + LSP binaries live there. Probe it first so OMO
// reuses tools OpenCode already installed instead of triggering a duplicate download.
join(getOpenCodeCacheDir(), "bin", rgName),
join(getDataDir(), "opencode", "bin", rgName),
join(execDir, rgName),
join(execDir, "bin", rgName),