MCPcopy
hub / github.com/codeaashu/claude-code / getProjectFiles

Function getProjectFiles

src/hooks/fileSuggestions.ts:459–516  ·  view source on GitHub ↗

* Gets project files using git ls-files (fast) or ripgrep (fallback)

(
  abortSignal: AbortSignal,
  respectGitignore: boolean,
)

Source from the content-addressed store, hash-verified

457 * Gets project files using git ls-files (fast) or ripgrep (fallback)
458 */
459async function getProjectFiles(
460 abortSignal: AbortSignal,
461 respectGitignore: boolean,
462): Promise<string[]> {
463 logForDebugging(
464 `[FileIndex] getProjectFiles called, respectGitignore=${respectGitignore}`,
465 )
466
467 // Try git ls-files first (much faster for git repos)
468 const gitFiles = await getFilesUsingGit(abortSignal, respectGitignore)
469 if (gitFiles !== null) {
470 logForDebugging(
471 `[FileIndex] using git ls-files result (${gitFiles.length} files)`,
472 )
473 return gitFiles
474 }
475
476 // Fall back to ripgrep
477 logForDebugging(
478 `[FileIndex] git ls-files returned null, falling back to ripgrep`,
479 )
480 const startTime = Date.now()
481 const rgArgs = [
482 '--files',
483 '--follow',
484 '--hidden',
485 '--glob',
486 '!.git/',
487 '--glob',
488 '!.svn/',
489 '--glob',
490 '!.hg/',
491 '--glob',
492 '!.bzr/',
493 '--glob',
494 '!.jj/',
495 '--glob',
496 '!.sl/',
497 ]
498 if (!respectGitignore) {
499 rgArgs.push('--no-ignore-vcs')
500 }
501
502 const files = await ripGrep(rgArgs, '.', abortSignal)
503 const relativePaths = files.map(f => path.relative(getCwd(), f))
504
505 const duration = Date.now() - startTime
506 logForDebugging(
507 `[FileIndex] ripgrep: ${relativePaths.length} files in ${duration}ms`,
508 )
509
510 logEvent('tengu_file_suggestions_ripgrep', {
511 file_count: relativePaths.length,
512 duration_ms: duration,
513 })
514
515 return relativePaths
516}

Callers 1

getPathsForSuggestionsFunction · 0.85

Calls 6

logForDebuggingFunction · 0.85
getFilesUsingGitFunction · 0.85
ripGrepFunction · 0.85
getCwdFunction · 0.85
logEventFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected