Skip to main content

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

FeatureDescriptionProtocol
Content searchSearch text or regex patterns across file contents.REST API
Fuzzy file searchQuick file finder by name (like Cmd+P in your editor).REST API
Streaming searchReal-time search results via Server-Sent Events.SSE
File watcherReal-time file change notifications.WebSocket

Search for text or regex patterns across all files in your workspace. Results include line numbers, column positions, and configurable context lines.

API: POST /api/search

Full search with all options via JSON body:

Parameters

FieldTypeDefaultDescription
querystringrequiredSearch pattern (text or regex).
pathstring.Directory to search (relative to workspace root).
is_regexbooleanfalseTreat query as a regular expression.
case_sensitivebooleanfalseEnable case-sensitive matching.
whole_wordbooleanfalseMatch whole words only.
include_globstringOnly search files matching this glob pattern.
exclude_globstringSkip files matching this glob pattern.
max_resultsnumber1000Maximum total matches to return.
context_linesnumber0Number of lines to include before and after each match.
max_file_sizenumber1048576Skip files larger than this size (in bytes).

Response

Search via query parameters for simple lookups:
ParameterAliasesDescription
qquerySearch pattern.
pathDirectory to search.
regexis_regexEnable regex mode.
casecase_sensitiveCase-sensitive search.
wordwhole_wordWhole word matching.
includeinclude_globInclude glob pattern.
excludeexclude_globExclude glob pattern.
maxmax_resultsMax results.
contextcontext_linesContext lines.

For large workspaces, use the streaming endpoint to receive results in real-time via Server-Sent Events (SSE):
Results arrive as they’re found:

Find files quickly by name using fuzzy matching — the same experience as Cmd+P / Ctrl+P in your editor.

API: GET /api/files/fuzzy

ParameterDescriptionDefault
q or queryFuzzy search query.
typesComma-separated file extensions to filter.All types
maxMaximum 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:
  1. Character matching — all query characters must appear in order in the filename.
  2. Consecutive bonus — higher score for consecutive character matches.
  3. Word boundary bonus — higher score for matches at word boundaries (/, _, -, ., camelCase).
  4. Prefix bonus — higher score for matches at the start of the filename.
  5. Exact match bonus — highest score for exact matches.
  6. Length penalty — shorter filenames score higher.
QueryMatchesWhy
main.gomain.goExact match (highest score)
mainmain.goPrefix match
mgmain.goCharacter matching
srvtsserver.tsWord boundary + character matching
btnButton.tsxWord 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

TypeDescription
createA file or directory was created.
writeA file’s content was modified.
removeA file or directory was deleted.
renameA file or directory was renamed.
chmodFile permissions were changed.

Event format

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

MethodEndpointDescription
GET/api/watcherWatcher info and configuration.
GET/api/watcher/statusConnection 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

PatternMatches
*.pyAll Python files
*.{ts,tsx}TypeScript and TSX files
test_*.pyPython test files starting with test_
src/**/*.goAll Go files under src/

Editor SDK integration

If you’re building a custom editor integration, use the Search SDK client:

Performance tips

  1. Use glob filters — always specify include_glob when you know the file type.
  2. Limit results — set a reasonable max_results for UI responsiveness.
  3. Use streaming for large searches — the SSE endpoint returns results as they’re found.
  4. Debounce user input — wait 100–200ms before sending search requests when building a search UI.
  5. Leverage the cache — fuzzy file search results are cached and respond in milliseconds.
  6. Connect the watcher once — reuse a single WebSocket connection for file change events.