feat: add exclude_paths to file index configuration#33
Merged
SUSTAPLE117 merged 2 commits intomainfrom Mar 26, 2026
Merged
Conversation
Introduces file_index.exclude_paths in bagel.yaml so users can opt
entire directory trees out of the file index walk:
file_index:
exclude_paths:
- ~/projects
- ~/.cache
- ~ / $HOME / %USERPROFILE% are expanded (same logic as base_dirs)
- Paths are normalized with filepath.Clean/filepath.FromSlash so
trailing separators and Windows paths work correctly
- Empty/whitespace entries in the list are silently ignored
- walkDirectory() returns early when currentDir matches an excluded path
(exact match or child prefix)
- ExcludePaths is threaded through cache.LoadInput, cache.SaveInput,
cacheKeyInput, and cache.Metadata so that changing the list correctly
invalidates stale cache entries; cache SchemaVersion bumped to 4
Adds TestBuildIndex_WithExcludePaths to verify excluded directories are
not indexed while sibling directories still are.
There was a problem hiding this comment.
Pull request overview
Adds support for excluding entire directory trees from the file index walk via file_index.exclude_paths in bagel.yaml, and ensures cache entries are invalidated when the exclusion list changes.
Changes:
- Add
ExcludePathsto file index configuration and plumb it through collector → fileindex build and cache load/save. - Implement directory-skip logic during the walk based on exact/prefix matches of excluded paths (with expansion/normalization).
- Extend cache metadata/keying to incorporate
ExcludePaths, and add a test covering excluded directories.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/models/config.go | Adds exclude_paths to FileIndexConfig YAML/mapstructure model. |
| pkg/fileindex/fileindex.go | Normalizes excludes and skips excluded directories during traversal. |
| pkg/fileindex/fileindex_test.go | Adds test verifying excluded directories are not indexed. |
| pkg/collector/collector.go | Passes config ExcludePaths into index build and cache operations. |
| pkg/cache/cache.go | Includes ExcludePaths in cache schema/metadata and cache-key computation. |
| CLA_SIGNATURES.md | Adds a CLA signature entry and fixes formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- TrimSpace before expandHomeDir so entries like ' ~/repos ' expand the ~ prefix correctly instead of being passed through unexpanded - Replace HasPrefix child-path check with filepath.Rel so that excluding a root or volume-root path (e.g. '/') correctly excludes all descendants without the '//'-prefix false-negative - Add normalizeExcludePaths helper to cache package (TrimSpace, skip empty, expandPath, filepath.Clean/FromSlash) and use it in Load, Save, and computeCacheKey so cache keys and metadata are stable and consistent with BuildIndex normalization
SUSTAPLE117
approved these changes
Mar 26, 2026
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
Adds
file_index.exclude_pathstobagel.yamlso users can opt entire directory trees out of the file index walk:This is useful on machines with large project trees (e.g. many
node_modulescopies or git worktrees) where the default unlimited walk produces millions of files and makes the index build slow.Changes
pkg/models/config.go— addExcludePaths []stringtoFileIndexConfigpkg/fileindex/fileindex.go— expand/normalize exclude paths at build time;walkDirectory()returns early whencurrentDirmatches an excluded path (exact match or child prefix); empty/whitespace entries are ignored; paths normalized withfilepath.Clean/filepath.FromSlashpkg/collector/collector.go— passExcludePathsfrom config intoBuildIndexInput,cache.LoadInput, andcache.SaveInputpkg/cache/cache.go— includeExcludePathsin cache key andMetadataso changing the list invalidates stale cache entries;SchemaVersionbumped to 4Tests
TestBuildIndex_WithExcludePaths— verifies that files inside an excluded directory are not indexed while files in a sibling directory still are.