GrepApp Feature
Overview
The grepapp feature enables integration with grep.app, a search engine for code across GitHub repositories. This allows Terraphim AI to search through millions of open-source repositories as part of your knowledge graph.
Status
Available for: Local development only (not in published crates)
Feature Flag: --features grepapp
Dependency: haystack_grepapp (local path dependency)
Why Local Only?
The grepapp feature is not enabled by default in published crates because the haystack_grepapp dependency is not yet published to crates.io. This is intentional to allow active development while preparing for publication.
Enabling the Feature
For Development
To enable the grepapp feature during development:
# Build with grepapp enabled
# Run tests with grepapp
# Run the server with grepapp support
For Cargo Workspace
If you're building multiple workspace crates, add grepapp to your feature list:
Configuration
Once the feature is enabled, configure GrepApp as a haystack in your role configuration:
Configuration Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| location | string | Yes | Must be "https://grep.app" |
| service | string | Yes | Must be "GrepApp" |
| language | string | No | Filter by programming language (e.g., "Rust", "Python") |
| repo | string | No | Filter by GitHub repo (e.g., "tokio-rs/tokio") |
| path | string | No | Filter by file path (e.g., "src/") |
Usage Examples
Search for Code Across All Rust Repositories
Search in a Specific Repository
How It Works
- Search: Terraphim sends your search query to grep.app's API
- Filter: Results are filtered by language, repo, and path if specified
- Index: Matching code snippets are indexed with unique IDs
- Rank: Results are ranked using your configured relevance function
Document ID Format
GrepApp documents use the following ID format:
grepapp:{repo}:{branch}:{path}Example: grepapp:tokio-rs_tokio_master_tokio_src_task_spawn.rs
Duplicate Handling
When using GrepApp together with other haystacks (like QueryRs), you may see duplicate results from the same repository. See docs/duplicate-handling.md for details on how duplicates are managed.
Implementation Details
Code Location
- Indexer:
crates/terraphim_middleware/src/haystack/grep_app.rs - Feature Guard:
#[cfg(feature = "grepapp")] - Service Type:
ServiceType::GrepApp(interraphim_config)
API Integration
The feature uses the grepapp_haystack crate which provides:
GrepAppClient: HTTP client for grep.app APISearchParams: Query builder with filtersSearchResult: Parsed API responses
Error Handling
- Network failures: Return empty index (graceful degradation)
- Invalid parameters: Logged as warnings
- Missing feature: Logs clear warning if haystack configured but feature not enabled
Testing
Unit Tests
Run the GrepApp unit tests:
Tests include:
test_indexer_creation: Verifies indexer can be instantiatedtest_filter_extraction: Tests language/repo/path filter extractiontest_empty_filters: Tests empty string filter handling
Integration Tests
There are currently no live integration tests for GrepApp. The unit tests use mock haystacks to avoid making real API calls.
Troubleshooting
Feature Not Enabled
Symptom: Search logs show "GrepApp haystack support not enabled"
Solution: Build with --features grepapp
No Results Returned
Symptom: GrepApp haystack returns empty index
Possible Causes:
- Network connectivity issues
- grep.app API rate limiting
- No matches for your query with specified filters
Debug: Check logs for "GrepApp search failed" messages
Compilation Errors
Symptom: cannot find GrepAppHaystackIndexer
Solution: Ensure you're building with the grepapp feature enabled:
Future Work
crates.io Publication
To make grepapp available in published crates:
- Publish
haystack_grepappto crates.io - Update
Cargo.tomldependency from path to crates.io version - Document the feature in the main README
Integration Tests
Add live integration tests that:
- Make real API calls to grep.app
- Verify response parsing
- Test error handling with bad queries
Related Documentation
- Duplicate Handling - How GrepApp interacts with other haystacks
- Haystack Configuration - General haystack setup
- Service Types - All available haystack types
Changelog
2026-01-13
- Fixed: Re-enabled grepapp feature for local development
- Removed: Dead code guards for atomic feature
- Verified: Zero compiler warnings with grepapp enabled
Last Updated: 2026-01-13 Feature Status: β Available for local development Publication Status: π Pending (requires haystack_grepapp publication)