Search SDK
RBS includes a powerful search engine built into every branch server. Search file contents, find files by name, and receive real-time file change notifications — all through a consistent API accessible from your editor or custom tooling.
Overview
| Feature | Description | Protocol |
|---|
| Content search | Search text or regex patterns across file contents. | REST API |
| Fuzzy file search | Quick file finder by name (like Cmd+P in your editor). | REST API |
| Streaming search | Real-time search results via Server-Sent Events. | SSE |
| File watcher | Real-time file change notifications. | WebSocket |
Content search
Search for text or regex patterns across all files in your workspace. Results include line numbers, column positions, and configurable context lines.
Basic search
API: POST /api/search
Full search with all options via JSON body:
Parameters
| Field | Type | Default | Description |
|---|
query | string | required | Search pattern (text or regex). |
path | string | . | Directory to search (relative to workspace root). |
is_regex | boolean | false | Treat query as a regular expression. |
case_sensitive | boolean | false | Enable case-sensitive matching. |
whole_word | boolean | false | Match whole words only. |
include_glob | string | — | Only search files matching this glob pattern. |
exclude_glob | string | — | Skip files matching this glob pattern. |
max_results | number | 1000 | Maximum total matches to return. |
context_lines | number | 0 | Number of lines to include before and after each match. |
max_file_size | number | 1048576 | Skip files larger than this size (in bytes). |
Response
API: GET /api/search (quick search)
Search via query parameters for simple lookups:
| Parameter | Aliases | Description |
|---|
q | query | Search pattern. |
path | — | Directory to search. |
regex | is_regex | Enable regex mode. |
case | case_sensitive | Case-sensitive search. |
word | whole_word | Whole word matching. |
include | include_glob | Include glob pattern. |
exclude | exclude_glob | Exclude glob pattern. |
max | max_results | Max results. |
context | context_lines | Context lines. |
Streaming search
For large workspaces, use the streaming endpoint to receive results in real-time via Server-Sent Events (SSE):
Results arrive as they’re found:
Fuzzy file search
Find files quickly by name using fuzzy matching — the same experience as Cmd+P / Ctrl+P in your editor.
API: GET /api/files/fuzzy
| Parameter | Description | Default |
|---|
q or query | Fuzzy search query. | — |
types | Comma-separated file extensions to filter. | All types |
max | Maximum results. | 50 |
Response
An empty query returns recently modified files sorted by modification time — useful for “recent files” functionality.
How fuzzy matching works
The fuzzy matcher scores results based on:
- Character matching — all query characters must appear in order in the filename.
- Consecutive bonus — higher score for consecutive character matches.
- Word boundary bonus — higher score for matches at word boundaries (
/, _, -, ., camelCase).
- Prefix bonus — higher score for matches at the start of the filename.
- Exact match bonus — highest score for exact matches.
- Length penalty — shorter filenames score higher.
| Query | Matches | Why |
|---|
main.go | main.go | Exact match (highest score) |
main | main.go | Prefix match |
mg | main.go | Character matching |
srvts | server.ts | Word boundary + character matching |
btn | Button.tsx | Word boundary (camelCase) |
Refresh the file index
The file index refreshes automatically every 30 seconds. To force a refresh:
File watcher
Receive real-time notifications when files change in the workspace via WebSocket.
Connect
On connection, you’ll receive a confirmation message:
Event types
| Type | Description |
|---|
create | A file or directory was created. |
write | A file’s content was modified. |
remove | A file or directory was deleted. |
rename | A file or directory was renamed. |
chmod | File permissions were changed. |
For rename events, an additional old_path field is included:
Debouncing
File events are debounced (100ms) to prevent rapid-fire notifications when editors auto-save, build tools generate multiple files, or external tools batch-modify files.
REST endpoints
| Method | Endpoint | Description |
|---|
GET | /api/watcher | Watcher info and configuration. |
GET | /api/watcher/status | Connection status. |
Default ignored patterns
All search and watcher features automatically skip:
.git, .hg, .svn directories
node_modules, vendor, __pycache__
.venv, venv, .env
dist, build, target
.idea, .vscode, .rbs
- Binary files (images, executables, archives)
- Files matching
.gitignore patterns
Glob pattern examples
| Pattern | Matches |
|---|
*.py | All Python files |
*.{ts,tsx} | TypeScript and TSX files |
test_*.py | Python test files starting with test_ |
src/**/*.go | All Go files under src/ |
Editor SDK integration
If you’re building a custom editor integration, use the Search SDK client:
- Use glob filters — always specify
include_glob when you know the file type.
- Limit results — set a reasonable
max_results for UI responsiveness.
- Use streaming for large searches — the SSE endpoint returns results as they’re found.
- Debounce user input — wait 100–200ms before sending search requests when building a search UI.
- Leverage the cache — fuzzy file search results are cached and respond in milliseconds.
- Connect the watcher once — reuse a single WebSocket connection for file change events.