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

Function fuzzySearch

projects/runtime-node/src/localFiles.ts:216–231  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

214 },
215
216 async fuzzySearch(params) {
217 const record = asRecord(params)
218 const dir = stringValue(record, "dir")
219 const query = typeof record.query === "string" ? record.query : ""
220 const limit = positiveInt(record.limit, DEFAULT_SEARCH_LIMIT)
221 const items = await walk(dir, { includeDirs: boolValue(record.matchDirs) })
222 const ranked = items
223 .map((item) => ({ ...item, rank: rankMatch(item.relativePath, query) }))
224 .filter((item) => Number.isFinite(item.rank))
225 .sort((a, b) => a.rank - b.rank || a.relativePath.localeCompare(b.relativePath))
226 return {
227 results: ranked.slice(0, limit).map((item) => item.relativePath),
228 truncated: ranked.length > limit || items.length >= MAX_WALK_ENTRIES,
229 source: "fs",
230 }
231 },
232
233 async searchContent(params) {
234 const record = asRecord(params)

Callers

nothing calls this directly

Calls 6

positiveIntFunction · 0.85
boolValueFunction · 0.85
rankMatchFunction · 0.85
asRecordFunction · 0.70
stringValueFunction · 0.70
walkFunction · 0.70

Tested by

no test coverage detected