File tree Expand file tree Collapse file tree
packages/opencode/src/tool Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { Tool } from "./tool"
33import * as path from "path"
44import DESCRIPTION from "./ls.txt"
55import { Instance } from "../project/instance"
6+ import { Ripgrep } from "../file/ripgrep"
67
78export const IGNORE_PATTERNS = [
89 "node_modules/" ,
@@ -42,15 +43,8 @@ export const ListTool = Tool.define("list", {
4243 async execute ( params ) {
4344 const searchPath = path . resolve ( Instance . directory , params . path || "." )
4445
45- const glob = new Bun . Glob ( "**/*" )
46- const files = [ ]
47-
48- for await ( const file of glob . scan ( { cwd : searchPath , dot : true } ) ) {
49- if ( IGNORE_PATTERNS . some ( ( p ) => file . includes ( p ) ) ) continue
50- if ( params . ignore ?. some ( ( pattern ) => new Bun . Glob ( pattern ) . match ( file ) ) ) continue
51- files . push ( file )
52- if ( files . length >= LIMIT ) break
53- }
46+ const ignoreGlobs = IGNORE_PATTERNS . map ( ( p ) => `!${ p } *` ) . concat ( params . ignore ?. map ( ( p ) => `!${ p } ` ) || [ ] )
47+ const files = await Ripgrep . files ( { cwd : searchPath , glob : ignoreGlobs , limit : LIMIT } )
5448
5549 // Build directory structure
5650 const dirs = new Set < string > ( )
You can’t perform that action at this time.
0 commit comments