Gitignore negation patterns cause all files to be excluded from index
What happened?
When initializing AiDex on a repository with a .gitignore file containing negation patterns (e.g., !.vscode/settings.json), all files are incorrectly excluded from the index.
After running aidex init, the database is created but contains 0 files. When using the MCP tool, it reports "Files removed: [total file count] (now excluded)" indicating all indexed files were purged.
The readGitignore() function in src/commands/init.ts does not filter out negation patterns. When these patterns are passed to minimatch, they are misinterpreted as positive exclusion patterns, causing all files to be excluded.
For example, a .gitignore containing:
.vscode/* !.vscode/settings.json The !.vscode/settings.json pattern is processed and transformed, then passed to minimatch which interprets the ! as "exclude everything except this", effectively excluding all files.
What did you expect?
I expected AiDex to correctly ignore negation patterns from .gitignore and only use positive exclusion patterns. The index should contain all non-excluded files in the repository.
Steps to reproduce
Create a repository with a .gitignore file containing negation patterns:
.vscode/* !.vscode/settings.json Run aidex init --project . --db .aidex/index.db
Query the database - it will be empty or show 0 files indexed
Alternatively, use the MCP tool aidex_init and observe the output showing all files removed
Environment
AiDex version: 1.10.1 Node.js version: 20.x OS: macOS (also reproducible on other platforms)
Error output / logs
See PR #1
Thanks for the report! This was actually already fixed in a prior release — the readGitignore() function in src/commands/init.ts already filters out negation patterns (!...) since v1.12.x:
.filter(line => line && !line.startsWith('#') && !line.startsWith('!'))
If you're still seeing this issue, please make sure you're on the latest version (npm update -g aidex-mcp). Closing this as already resolved.