summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-09-02 10:40:20 -0500
committerGitHub <[email protected]>2025-09-02 10:40:20 -0500
commitd6350a7fa61702ac2aa74357e901d59f2c4ee1c7 (patch)
treecbfeaa391f3497bc463c205d415454f413fd5443
parentae8313883259ccc160999a50b29e1f356b91faaa (diff)
downloadopencode-d6350a7fa61702ac2aa74357e901d59f2c4ee1c7.tar.gz
opencode-d6350a7fa61702ac2aa74357e901d59f2c4ee1c7.zip
tweak: update ls tool to use rg (#2367)
-rw-r--r--packages/opencode/src/tool/ls.ts12
1 files changed, 3 insertions, 9 deletions
diff --git a/packages/opencode/src/tool/ls.ts b/packages/opencode/src/tool/ls.ts
index 00dbcbd3f..5a8173ef8 100644
--- a/packages/opencode/src/tool/ls.ts
+++ b/packages/opencode/src/tool/ls.ts
@@ -3,6 +3,7 @@ import { Tool } from "./tool"
import * as path from "path"
import DESCRIPTION from "./ls.txt"
import { Instance } from "../project/instance"
+import { Ripgrep } from "../file/ripgrep"
export const IGNORE_PATTERNS = [
"node_modules/",
@@ -42,15 +43,8 @@ export const ListTool = Tool.define("list", {
async execute(params) {
const searchPath = path.resolve(Instance.directory, params.path || ".")
- const glob = new Bun.Glob("**/*")
- const files = []
-
- for await (const file of glob.scan({ cwd: searchPath, dot: true })) {
- if (IGNORE_PATTERNS.some((p) => file.includes(p))) continue
- if (params.ignore?.some((pattern) => new Bun.Glob(pattern).match(file))) continue
- files.push(file)
- if (files.length >= LIMIT) break
- }
+ const ignoreGlobs = IGNORE_PATTERNS.map((p) => `!${p}*`).concat(params.ignore?.map((p) => `!${p}`) || [])
+ const files = await Ripgrep.files({ cwd: searchPath, glob: ignoreGlobs, limit: LIMIT })
// Build directory structure
const dirs = new Set<string>()