Skip to content

Fix search_code to search only indexed files#103

Open
heraque wants to merge 2 commits intoDeusData:mainfrom
heraque:heraque/fix-search-code-indexed-files
Open

Fix search_code to search only indexed files#103
heraque wants to merge 2 commits intoDeusData:mainfrom
heraque:heraque/fix-search-code-indexed-files

Conversation

@heraque
Copy link

@heraque heraque commented Mar 21, 2026

Closes #102

Summary

This PR fixes search_code so that it searches only files that are part of the indexed project, instead of recursively scanning the whole repository root.

The previous behavior could return matches from generated artifacts, non-indexed files, and binary outputs, which made the tool inconsistent with the indexed graph model.

What changed

  • replaced recursive shell-based workspace search with indexed-file-scoped search
  • search_code now:
    • loads indexed File nodes from the store
    • applies file_pattern against indexed paths
    • opens only indexed files
    • skips binary files
    • supports both substring and regex matching
  • removed dependence on recursive grep for this MCP tool path

Why this is correct

The rest of the MCP server is project-model-driven, so search_code should also reflect the indexed project state.

Searching only indexed files makes results:

  • deterministic
  • aligned with the graph
  • free from generated artifact pollution
  • more reliable for downstream agent behavior

Validation

Repository checks:

  • scripts/test.sh
  • scripts/lint.sh

Regression coverage added:

  • integration test ensures a matching file under build/ is ignored while the indexed source file is still returned

Scope

This PR intentionally keeps the change focused to search_code behavior only, without changing unrelated MCP tools.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search_code returns matches from non-indexed/generated files instead of only indexed source files

2 participants