fix(core): only load .gitignore and .contextignore from codebase root#372
Open
povilasjurcys wants to merge 1 commit into
Open
fix(core): only load .gitignore and .contextignore from codebase root#372povilasjurcys wants to merge 1 commit into
povilasjurcys wants to merge 1 commit into
Conversation
Previously findIgnoreFiles loaded every file matching `.*ignore` in the codebase root, including tool-specific files like `.prettierignore`, `.dockerignore`, and `.eslintignore`. Their lines were merged into the indexer's flat exclude list with no per-file semantics and no support for `!` negations. This silently broke indexing for any project using prettier's standard allowlist idiom (a bare `*` followed by `!path` re-includes), because `*` was converted to regex `^.*$` and matched every relative path. The walker then returned 0 files, the indexer reported 100% completion, and the Milvus collection ended up empty — with no error surfaced to the user. Narrow discovery to `.gitignore` and `.contextignore` only. Projects that need extra patterns specifically for the indexer can put them in `.contextignore`. Update file-inclusion-rules docs and add regression tests.
ValdemarKobelis
approved these changes
May 22, 2026
Author
|
@zc277584121 it's been a while now. What do you think about this change? |
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.
Fixes #222 and very likely #195, #145 too.
TL;DR;
When I run indexing, I get response that indexing succeeded but no files where actually indexed. This happened for me because claude-context was looking at .prettierignore which has nothing to do with the claude-context not to mention that it parsed incorrectly. This PR tries to solve the issue by explicitly listing which ignore files we should look at.
Technicalities
Previously
findIgnoreFilesloaded every.<name>ignorefile in the codebase root —.prettierignore,.dockerignore,.eslintignore,.cursorignore, etc. — and concatenated their lines into the indexer's flat exclude list. The loader has no per-file semantics and no support for!negations.Tool-specific files often use the prettier-style allowlist idiom (a bare
*followed by!pathre-includes). With the existing flat loader, the bare*is converted to regex^.*$and matches every relative path. The walker returns 0 files, the indexer reports 100% completion, and the Milvus collection ends up empty — no error surfaced to the user. This is the symptom #222 describes from the user side ("Claude-context automatically ignores files which have the key information for agents to look for").This PR narrows the discovery to
.gitignoreand.contextignoreonly. Tool-specific ignore files are intentionally skipped because their semantics are tool-defined and not reliably interpretable as a flat exclude list. Projects that need extra patterns specifically for the indexer can put them in.contextignore(already documented).A previous attempt to fix this more broadly (#293, closed) replaced the custom matcher with the
ignorenpm package to support!negations and gitignore semantics across the board. This PR is deliberately narrower: no new dependency, no behavior change for.gitignoreusers, only the surface area where the bug fires.Changes
packages/core/src/context.ts:findIgnoreFilesnow matches a fixed allowlist (.gitignore,.contextignore) instead of every.*ignorefile.packages/core/src/context.ignore-patterns.test.ts: regression tests —.prettierignoreno longer poisons the pattern set, and.contextignorecontinues to load.docs/dive-deep/file-inclusion-rules.md: replaces the "any .xxxignore" section with the narrowed rule and rationale.Test plan
pnpm --filter @zilliz/claude-context-core test— 21/21 passpnpm build— all packages compile clean