MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / walk

Function walk

projects/runtime-node/src/localFiles.ts:72–98  ·  view source on GitHub ↗
(root: string, options: { includeDirs?: boolean; showHidden?: boolean } = {})

Source from the content-addressed store, hash-verified

70}
71
72async function walk(root: string, options: { includeDirs?: boolean; showHidden?: boolean } = {}): Promise<Array<{ relativePath: string; fullPath: string; isDir: boolean }>> {
73 const result: Array<{ relativePath: string; fullPath: string; isDir: boolean }> = []
74 const queue = [root]
75
76 while (queue.length > 0 && result.length < MAX_WALK_ENTRIES) {
77 const dir = queue.shift()!
78 let entries: Array<{ name: string; isDirectory(): boolean }>
79 try {
80 entries = await fs.readdir(dir, { withFileTypes: true })
81 } catch {
82 continue
83 }
84
85 for (const entry of entries) {
86 if (!options.showHidden && entry.name.startsWith(".")) continue
87 const fullPath = path.join(dir, entry.name)
88 const relativePath = path.relative(root, fullPath)
89 const isDir = entry.isDirectory()
90 if (isDir && SKIP_DIRS.has(entry.name)) continue
91 if (!isDir || options.includeDirs) result.push({ relativePath, fullPath, isDir })
92 if (isDir) queue.push(fullPath)
93 if (result.length >= MAX_WALK_ENTRIES) break
94 }
95 }
96
97 return result
98}
99
100function rankMatch(pathname: string, query: string): number {
101 if (!query) return 0

Callers 2

fuzzySearchFunction · 0.70
searchContentFunction · 0.70

Calls 3

isDirectoryMethod · 0.80
hasMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected