Section 2.2Source:
server/src/parser/walker/repositoryWalker.tsRepository 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.tsThe 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
123456export 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.jsxIgnored 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647export 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.