Skip to content

fix(core): only load .gitignore and .contextignore from codebase root#372

Open
povilasjurcys wants to merge 1 commit into
zilliztech:masterfrom
povilasjurcys:fix/narrow-ignore-file-discovery
Open

fix(core): only load .gitignore and .contextignore from codebase root#372
povilasjurcys wants to merge 1 commit into
zilliztech:masterfrom
povilasjurcys:fix/narrow-ignore-file-discovery

Conversation

@povilasjurcys

@povilasjurcys povilasjurcys commented May 6, 2026

Copy link
Copy Markdown

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 findIgnoreFiles loaded every .<name>ignore file 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 !path re-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 .gitignore and .contextignore only. 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 ignore npm package to support ! negations and gitignore semantics across the board. This PR is deliberately narrower: no new dependency, no behavior change for .gitignore users, only the surface area where the bug fires.

Changes

  • packages/core/src/context.ts: findIgnoreFiles now matches a fixed allowlist (.gitignore, .contextignore) instead of every .*ignore file.
  • packages/core/src/context.ignore-patterns.test.ts: regression tests — .prettierignore no longer poisons the pattern set, and .contextignore continues 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 pass
  • pnpm build — all packages compile clean

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.
@povilasjurcys

Copy link
Copy Markdown
Author

@zc277584121 it's been a while now. What do you think about this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore some ignore files :)

2 participants