MCPcopy Create free account
hub / github.com/arctic-cli/interface / search

Function search

packages/arctic/src/file/index.ts:315–325  ·  view source on GitHub ↗
(input: { query: string; limit?: number; dirs?: boolean })

Source from the content-addressed store, hash-verified

313 }
314
315 export async function search(input: { query: string; limit?: number; dirs?: boolean }) {
316 log.info("search", { query: input.query })
317 const limit = input.limit ?? 100
318 const result = await state().then((x) => x.files())
319 if (!input.query)
320 return input.dirs !== false ? result.dirs.toSorted().slice(0, limit) : result.files.slice(0, limit)
321 const items = input.dirs !== false ? [...result.files, ...result.dirs] : result.files
322 const sorted = fuzzysort.go(input.query, items, { limit: limit }).map((r) => r.target)
323 log.info("search", { query: input.query, results: sorted.length })
324 return sorted
325 }
326}

Callers

nothing calls this directly

Calls 2

stateFunction · 0.85
filesMethod · 0.45

Tested by

no test coverage detected