Search & Navigation Commands

VritraAI provides powerful search capabilities that go beyond simple text matching. These commands help you find code, navigate your codebase, and track recent activity efficiently.

Regex Search

search_regex <pattern> [path]

Blazing-fast full-text regex search across files and directories. Searches through code files using regular expressions with syntax highlighting for matches.

Features:

  • Full regular expression support
  • Automatic code file detection (Python, JavaScript, TypeScript, Java, C/C++, Go, Rust, PHP, Ruby, Swift, Kotlin, HTML, CSS, Shell scripts)
  • Syntax highlighting for matched patterns
  • Shows file path, line number, and matched line
  • Limits output to 500 matches (shows count if more found)
  • Ignores binary files and common build/dependency directories

Parameters:

  • pattern - Regular expression pattern to search for
  • path - (Optional) Directory or file to search in. Defaults to current directory (.)

Examples:

# Search for function definitions
search_regex "def\s+\w+\(" src/

# Search for TODO comments
search_regex "TODO|FIXME|XXX" .

# Search for class definitions
search_regex "^class\s+\w+" .

# Search for import statements
search_regex "^import\s+\w+" src/

# Search in a specific file
search_regex "error|exception" app.py

Note: The regex pattern uses Python's re module syntax. Invalid regex patterns will show an error message.

Semantic Search

search_semantic <query> [path]

AI-powered semantic code search that understands the meaning of your query, not just literal text matches. Uses AI to analyze code context and find relevant code sections based on functionality and purpose.

Features:

  • Natural language queries (e.g., "authentication logic", "database connection setup")
  • AI-powered code understanding
  • Analyzes up to 12 code files with 600 characters per file
  • Provides structured results with file locations and explanations
  • Identifies relevant code sections, potential pitfalls, and related symbols
  • Requires AI to be enabled (API key configured)

Parameters:

  • query - Natural language description of what you're looking for
  • path - (Optional) Directory or file to search in. Defaults to current directory (.)

Examples:

# Find authentication code
search_semantic "user authentication and login logic" src/

# Find database connection code
search_semantic "database connection setup" .

# Find error handling patterns
search_semantic "error handling and exception catching" src/

# Find API endpoint definitions
search_semantic "REST API endpoints and routes" app/

# Search in specific directory
search_semantic "file upload functionality" handlers/

Requirement: This command requires AI to be enabled. Make sure you have configured an API key using apikey command.

How It Works:

The semantic search command:

  1. Collects code snippets from relevant files in the target directory
  2. Sends the query and code snippets to the AI
  3. AI analyzes the code and identifies relevant sections
  4. Returns structured results including:
    • Which files/snippets are most relevant (with reasons)
    • What the code does related to the query
    • Where to start reading or editing (file + line ranges)
    • Potential pitfalls or related symbols to inspect

Recent Activity

recent [files|cmds]

Show recent files and commands from the current session. Helps you track what you've been working on and quickly access recently modified files or executed commands.

Features:

  • Shows up to 20 most recent files modified in the session
  • Shows up to 20 most recent commands with timestamps
  • Can filter to show only files or only commands
  • Session-based tracking (resets when you exit VritraAI)

Parameters:

  • files - Show only recent files
  • cmds or commands - Show only recent commands
  • (no parameter) - Show both recent files and commands

Examples:

# Show both recent files and commands
recent

# Show only recent files
recent files

# Show only recent commands
recent cmds

# Alternative syntax for commands
recent commands

Output Format:

  • Recent files: Shows file paths that have been modified during the session
  • Recent commands: Shows commands with timestamps in [HH:MM:SS] format

Tip: Use recent files to quickly see what files you've been working on, and recent cmds to review your command history for the current session.

Comparison with Other Search Commands

VritraAI provides multiple search capabilities. Here's when to use each:

search_file

Pattern-based file name search. Use when you know the file name pattern but not the exact name.

Example: search_file "*.py" src/

search_regex

Fast text search with regex. Use when you know the exact text pattern you're looking for.

Example: search_regex "def\s+\w+\(" src/

search_semantic

AI-powered semantic search. Use when you know what functionality you need but not the exact code.

Example: search_semantic "authentication logic" src/

Best Practices

  • Use regex search for exact pattern matching when you know the syntax you're looking for
  • Use semantic search when you need to find code by functionality or purpose
  • Use recent to quickly access files and commands from your current work session
  • Combine searches - Use regex to narrow down files, then semantic search within those files
  • Limit search scope - Specify a path parameter to search in specific directories for faster results

💡 Pro Tip: For large codebases, use search_regex first to find candidate files, then use search_semantic within those files for deeper analysis.