Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/quiet-ripgrep-packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kilocode/cli": patch
"kilo-code": patch
---

Use an installed ripgrep binary for codebase search in packaged Kilo builds.
13 changes: 12 additions & 1 deletion packages/opencode/script/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bun

import { $ } from "bun"
import type { BunPlugin } from "bun" // kilocode_change
import fs from "fs"
import os from "os" // kilocode_change
import path from "path"
Expand Down Expand Up @@ -31,6 +32,16 @@ const baselineFlag = process.argv.includes("--baseline")
const skipInstall = process.argv.includes("--skip-install")
const sourcemapsFlag = process.argv.includes("--sourcemaps")
const plugin = createSolidTransformPlugin()
// kilocode_change start - packaged CLIs have no node_modules tree for Morph's optional platform package
const morphRipgrepPlugin: BunPlugin = {
name: "kilocode-morph-ripgrep",
setup(build) {
build.onResolve({ filter: /^@vscode\/ripgrep$/ }, () => ({
path: path.join(dir, "src/kilocode/morph-ripgrep.ts"),
}))
},
}
// kilocode_change end

// kilocode_change start - codebase indexing
async function copyTreeSitterWasms(outputDir: string) {
Expand Down Expand Up @@ -267,7 +278,7 @@ for (const item of targets) {
await Bun.build({
conditions: ["bun", "node"], // kilocode_change - port anomalyco/opencode#30873; current form from #31566
tsconfig: "./tsconfig.json",
plugins: [plugin],
plugins: [plugin, morphRipgrepPlugin], // kilocode_change - use Morph's system-rg fallback in packaged CLIs
// kilocode_change start - skip sourcemaps for release builds (each .js.map adds ~50 MB per target → ~600 MB total)
sourcemap: Script.release ? "none" : "external",
external: ["node-gyp", ...LanceDBRuntime.external],
Expand Down
8 changes: 8 additions & 0 deletions packages/opencode/src/kilocode/morph-ripgrep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import path from "path"
import { Global } from "@opencode-ai/core/global"
import { which } from "@opencode-ai/core/util/which"

// Morph's local provider imports this path directly, but compiled Kilo binaries
// do not ship its optional @vscode/ripgrep platform package. Prefer a system
// binary and otherwise point it at the location managed by Kilo's ripgrep layer.
export const rgPath = which("rg") ?? path.join(Global.Path.bin, process.platform === "win32" ? "rg.exe" : "rg")
Comment thread
Hardik180704 marked this conversation as resolved.
Resolved
Loading