fix: respect .gitignore when scanning codebases#8
Merged
EduardPetraeus merged 2 commits intomainfrom Mar 7, 2026
Merged
Conversation
Use `git ls-files --cached --others --exclude-standard` to get the set of repo-relevant files instead of scanning the entire filesystem. Falls back to hardcoded exclude dirs for non-git repos. Fixes false positives caused by scanning venv/node_modules with non-standard names (e.g. .venv-ai) that weren't in the hardcoded list: - Entry points no longer point to third-party packages in venvs - Monorepo detection no longer triggered by venv pyproject.toml files - Naming conventions and code quality metrics reflect actual project code - Directory tree excludes gitignored directories Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nsistency
- Use `git ls-files -z` with NUL-delimited output for robust parsing
- Fixes CRLF line-ending bug that would silently drop files on Windows
- Remove hardcoded `.startswith(".")` guard from directory tree level-1,
letting `_is_path_gitignored()` decide consistently at both levels
- Move subprocess import to module level in test file
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git ls-files --cached --others --exclude-standard -zas the source of truth for which files belong to a codebase_FALLBACK_EXCLUDE_DIRS) for non-git reposBefore (scanning .venv-ai/ on HealthReporting)
dotenv/cli.py,dotenv/main.py(third-party garbage)After (git-aware)
api/server.py,mcp/server.py(correct)Changes
analyzers/base.py— new_get_git_files(),_is_path_gitignored(), git-aware_collect_files()analyzers/code_structure.py—_build_directory_tree()uses_is_path_gitignored()analyzers/pattern_detector.py—_detect_architecture_patterns()uses_collect_files()instead of raw rglobTest plan
Generated with Claude Code