MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getProjectFiles

Function getProjectFiles

source code/hooks/fileSuggestions.ts:461–518  ·  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

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

Callers 1

getPathsForSuggestionsFunction · 0.85

Calls 5

logForDebuggingFunction · 0.85
getFilesUsingGitFunction · 0.85
ripGrepFunction · 0.85
getCwdFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected