|
| 1 | +--- |
| 2 | +title: "Introducing Multi-Haystack Roles: Local + Global Code Search" |
| 3 | +date: 2026-02-16 |
| 4 | +author: Terraphim Team |
| 5 | +tags: [release, features, grepapp, haystack] |
| 6 | +--- |
| 7 | + |
| 8 | +# Introducing Multi-Haystack Roles: Local + Global Code Search |
| 9 | + |
| 10 | +Today we're excited to announce a significant enhancement to Terraphim's engineer roles: **multi-haystack support**. FrontEnd Engineers and Python Engineers now have access to both local code search (via Ripgrep) and global GitHub search (via GrepApp) in a single query. |
| 11 | + |
| 12 | +## The Problem: Siloed Search |
| 13 | + |
| 14 | +Traditionally, developers face a frustrating choice when searching for code: |
| 15 | + |
| 16 | +1. **Search locally** - Fast, but limited to your own codebase |
| 17 | +2. **Search GitHub** - Broad, but requires leaving your workflow |
| 18 | + |
| 19 | +When you're stuck on "how do I use this library?" or "what's the idiomatic way to solve this?", you need both: your local context for project-specific code, and global examples from the broader community. |
| 20 | + |
| 21 | +## The Solution: Dual Haystacks |
| 22 | + |
| 23 | +Starting with Terraphim v1.8.1, select engineer roles now come with **dual haystacks**: |
| 24 | + |
| 25 | +### FrontEnd Engineer |
| 26 | +- **Haystack 1**: Local Ripgrep search (`~/projects` or custom path) |
| 27 | +- **Haystack 2**: GrepApp global search (filtered to JavaScript) |
| 28 | + |
| 29 | +### Python Engineer |
| 30 | +- **Haystack 1**: Local Ripgrep search (`~/projects` or custom path) |
| 31 | +- **Haystack 2**: GrepApp global search (filtered to Python) |
| 32 | + |
| 33 | +### Rust Engineer v2 (already available) |
| 34 | +- **Haystack 1**: QueryRs (docs.rs search) |
| 35 | +- **Haystack 2**: Local Ripgrep search |
| 36 | + |
| 37 | +## How It Works |
| 38 | + |
| 39 | +When you search as a FrontEnd or Python Engineer, Terraphim queries both sources simultaneously: |
| 40 | + |
| 41 | +``` |
| 42 | +Your Query: "how to use useEffect" |
| 43 | + ↓ |
| 44 | +┌─────────────────┐ ┌──────────────────┐ |
| 45 | +│ Local Ripgrep │ │ GrepApp │ |
| 46 | +│ (your code) │ │ (GitHub repos) │ |
| 47 | +└────────┬────────┘ └────────┬─────────┘ |
| 48 | + │ │ |
| 49 | + └───────────┬───────────┘ |
| 50 | + ↓ |
| 51 | + Combined Results |
| 52 | + (ranked by relevance) |
| 53 | +``` |
| 54 | + |
| 55 | +The results are merged and ranked according to your role's relevance function: |
| 56 | +- **FrontEnd Engineer**: BM25Plus ranking |
| 57 | +- **Python Engineer**: BM25F field-weighted ranking |
| 58 | + |
| 59 | +This means you get the best of both worlds: your project's specific implementations AND real-world examples from popular repositories. |
| 60 | + |
| 61 | +## Real-World Use Cases |
| 62 | + |
| 63 | +### Learning a New Library |
| 64 | + |
| 65 | +You're trying to use `react-query` for the first time. A single search shows: |
| 66 | +- How you've used it elsewhere in your codebase (local) |
| 67 | +- How Facebook uses it in their production apps (global) |
| 68 | + |
| 69 | +### Debugging Common Patterns |
| 70 | + |
| 71 | +You're debugging a Python asyncio issue. Your search returns: |
| 72 | +- Your current implementation (local) |
| 73 | +- How aiohttp, FastAPI, and Django handle similar patterns (global) |
| 74 | + |
| 75 | +### Discovering Idioms |
| 76 | + |
| 77 | +You want to know the "Pythonic" way to do something. Instead of reading docs, you can see: |
| 78 | +- How the standard library implements it |
| 79 | +- How popular open-source projects handle similar cases |
| 80 | + |
| 81 | +## Technical Implementation |
| 82 | + |
| 83 | +Under the hood, this uses our existing GrepApp integration: |
| 84 | + |
| 85 | +```rust |
| 86 | +Haystack { |
| 87 | + location: "https://grep.app".to_string(), |
| 88 | + service: ServiceType::GrepApp, |
| 89 | + read_only: true, |
| 90 | + fetch_content: false, |
| 91 | + extra_parameters: { |
| 92 | + let mut params = HashMap::new(); |
| 93 | + params.insert("language".to_string(), "python".to_string()); |
| 94 | + params |
| 95 | + }, |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +The `extra_parameters` field allows language-specific filtering: |
| 100 | +- FrontEnd Engineer: `language=javascript` |
| 101 | +- Python Engineer: `language=python` |
| 102 | + |
| 103 | +GrepApp returns structured results from millions of GitHub repositories, complete with: |
| 104 | +- Repository name and file path |
| 105 | +- Code snippet with context |
| 106 | +- Direct link to view on GitHub |
| 107 | +- Branch information |
| 108 | + |
| 109 | +## Graceful Degradation |
| 110 | + |
| 111 | +We know network availability isn't guaranteed. If GrepApp is unreachable: |
| 112 | +- Local search continues working normally |
| 113 | +- No errors or interruptions |
| 114 | +- You still get your project-specific results |
| 115 | + |
| 116 | +This follows our philosophy: **local-first, enhance with global**. |
| 117 | + |
| 118 | +## What's Next |
| 119 | + |
| 120 | +This is just the beginning. We're planning: |
| 121 | + |
| 122 | +1. **More roles with dual haystacks**: |
| 123 | + - Go Engineer (GrepApp + local) |
| 124 | + - TypeScript-specific role |
| 125 | + - Language-agnostic search role |
| 126 | + |
| 127 | +2. **Configurable filters**: |
| 128 | + - Filter by specific repositories |
| 129 | + - Filter by file paths |
| 130 | + - Filter by popularity/stars |
| 131 | + |
| 132 | +3. **Enhanced ranking**: |
| 133 | + - Boost results from starred repositories |
| 134 | + - Learn from your click patterns |
| 135 | + - Personalized ranking per engineer |
| 136 | + |
| 137 | +## Try It Now |
| 138 | + |
| 139 | +If you're already using Terraphim v1.8.1+, you can try the new roles immediately: |
| 140 | + |
| 141 | +```bash |
| 142 | +# Switch to FrontEnd Engineer (with dual haystack) |
| 143 | +terraphim-agent onboard --role frontend-engineer |
| 144 | + |
| 145 | +# Switch to Python Engineer (with dual haystack) |
| 146 | +terraphim-agent onboard --role python-engineer |
| 147 | + |
| 148 | +# Search as usual - both local and global results appear |
| 149 | +terraphim-agent search "async def" |
| 150 | +``` |
| 151 | + |
| 152 | +## The Bigger Picture |
| 153 | + |
| 154 | +Multi-haystack roles represent a fundamental shift in how we think about code search: |
| 155 | + |
| 156 | +**Old model**: One haystack per role, choose your scope |
| 157 | +**New model**: Multiple haystacks per role, get comprehensive results |
| 158 | + |
| 159 | +This aligns with how developers actually work: they don't want to choose between "my code" and "the world's code" - they want both, intelligently combined. |
| 160 | + |
| 161 | +As we expand this pattern to more roles and add more haystack types (MCP servers, Atomic Data, AI assistants), Terraphim becomes not just a search tool, but a **knowledge synthesis engine** for developers. |
| 162 | + |
| 163 | +## Feedback Welcome |
| 164 | + |
| 165 | +Have ideas for other haystack combinations? Want to see this pattern applied to other roles? Let us know: |
| 166 | + |
| 167 | +- GitHub Issues: [github.com/terraphim/terraphim-ai/issues](https://github.com/terraphim/terraphim-ai/issues) |
| 168 | +- Discussions: [github.com/terraphim/terraphim-ai/discussions](https://github.com/terraphim/terraphim-ai/discussions) |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +**Related Reading:** |
| 173 | +- [Terraphim v1.8.1: Native Hook Support](/blog/2026-02-16-native-hook-support) |
| 174 | +- [Introducing Multi-Haystack Roles](/docs/guides/multi-haystack-roles) |
| 175 | +- [GrepApp Integration Deep Dive](/docs/integrations/grepapp) |
| 176 | + |
| 177 | +*Terraphim: Search your world.* |
0 commit comments