CodeGraph/docs
Section 2.2

Repository Discovery

The filesystem scanner that recursively walks repository directories, filters build artifacts and hidden folders, and categorizes code files and configuration manifests.

Source: server/src/parser/walker/repositoryWalker.ts

The Walker Function

The repository walker is the entry point of disk I/O. It scans the repository tree synchronously usingfs.readdirSync(currentPath, { withFileTypes: true }) to obtain directory entries (fs.Dirent) without incurring secondary fs.stat() system calls.

server/src/parser/models/RepositoryFiles.ts
1
2
3
4
5
6
export interface RepositoryFiles { sourceFiles: string[]; // .ts, .tsx, .js, .jsx packageJsonFiles: string[]; // All package.json files tsconfigJsonFiles: string[]; // All tsconfig.json files jsconfigJsonFiles: string[]; // All jsconfig.json files }

Filter Rules & Invariants

Allowed Source Extensions

Strictly restricted to JS/TS source code compatible with the Babel parser plugin configuration:

.ts.tsx.js.jsx

Ignored Directories

O(1) Set lookup skipping generated builds, dependencies, coverage reports, and dot directories:

node_modules.git.nextdistbuildcoverage.turboout.*

Traversal Implementation

server/src/parser/walker/repositoryWalker.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
export function getRepositoryFiles(dirPath: string): RepositoryFiles { const targetDir = dirPath; const sourceFiles: string[] = []; const packageJsonFiles: string[] = []; const tsconfigJsonFiles: string[] = []; const jsconfigJsonFiles: string[] = []; if (!fs.existsSync(targetDir)) throw new NotFoundError('Repository directory not found'); function walk(currentPath: string) { const entries = fs.readdirSync(currentPath, { withFileTypes: true }); for (const entry of entries) { const fullPath = path.join(currentPath, entry.name); if (entry.isDirectory()) { // Ignore dot-directories (.vscode, .github) and build artifacts if (IGNORED_DIRS.has(entry.name) || entry.name.startsWith('.')) continue; walk(fullPath); continue; } if (!entry.isFile()) continue; if (entry.name === 'package.json') { packageJsonFiles.push(fullPath); continue; } if (entry.name === 'tsconfig.json') { tsconfigJsonFiles.push(fullPath); continue; } if (entry.name === 'jsconfig.json') { jsconfigJsonFiles.push(fullPath); continue; } const ext = path.extname(entry.name).toLowerCase(); if (ALLOWED_EXTENSIONS.has(ext)) { sourceFiles.push(fullPath); } } } walk(targetDir); return { sourceFiles, packageJsonFiles, tsconfigJsonFiles, jsconfigJsonFiles }; }
Zero Source Files Safeguard
If sourceFiles.length === 0 after traversal, the parser immediately throws aNoSupportedFileError rather than proceeding with an empty run.