Skip to content

Search

Hide offers powerful search capabilities to help agents navigate and explore projects efficiently. There are three main types of search available:

  1. Content Search
  2. File Search
  3. Symbol Search

Let's dive into each of these search types and see how you can leverage them in your projects.

Content search allows you to find specific text patterns within your project files. This is incredibly useful when you need to locate particular code snippets, comments, or any textual content across your entire project.

Basic Usage

To perform a content search:

curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=your_search_query"
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

files = hc.search_files(
    project_id=project.id, 
    query="your search query"
)

Advanced Options

Hide's content search supports different search types:

  • Default: Case-insensitive search
  • Exact: Case-sensitive, exact match search
  • Regex: Regular expression search

You can specify the search type using query parameters:

# Exact match
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=YourExactPhrase&exact"

# Regex search
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=Your.*Regex&regex"
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

files = hc.search_files(
    project_id=project.id, 
    query="YourExactPhrase", 
    exact=True
)

files = hc.search_files(
    project_id=project.id, 
    query="Your.*Regex", 
    regex=True
)

Additional Parameters

Hide's content search also supports additional parameters to refine your search:

  • showHidden: Include hidden files in the search
  • include: Specify patterns for files to include in the search
  • exclude: Specify patterns for files to exclude from the search

Here are some examples:

# Include hidden files in the search
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=your_query&showHidden"

# Include only .json and .txt files
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=your_query&include=*.json&include=*.txt"

# Exclude 'node_modules' in the root directory
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=your_query&exclude=/node_modules"

# Exclude 'node_modules' on all levels
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=your_query&exclude=**/node_modules"

# Combine multiple parameters
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=content&query=your_query&include=*.json&include=*.txt&exclude=**/node_modules&showHidden"
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

files = hc.search_files(
    project_id=project.id, 
    query="your_query", 
    show_hidden=True
)

files = hc.search_files(
    project_id=project.id, 
    query="your_query", 
    include=["*.json", "*.txt"]
)

files = hc.search_files(
    project_id=project.id, 
    query="your_query", 
    exclude=["/node_modules"]
)

files = hc.search_files(
    project_id=project.id, 
    query="your_query", 
    exclude=["**/node_modules"]
)

files = hc.search_files(
    project_id=project.id, 
    query="your_query", 
    include=["*.json", "*.txt"], 
    exclude=["**/node_modules"], 
    show_hidden=True
)

These additional parameters allow you to fine-tune your search to specific file types or directories, making it easier to find exactly what you're looking for in your project.

File search helps you find files within your project based on their names or paths. This is particularly useful when you're looking for specific files or want to filter files based on certain patterns.

Basic Usage

To search for files:

curl -X GET "http://localhost:8080/projects/{projectId}/files"
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

files = hc.list_files(
    project_id=project.id, 
)

Filtering Files

You can use include and exclude parameters to filter the search results:

# Search for files containing the word "test" in their path
curl -X GET "http://localhost:8080/projects/{projectId}/files?include=test"

# Search for all Python files
curl -X GET "http://localhost:8080/projects/{projectId}/files?include=*.py"

# Search for all files except for test files
curl -X GET "http://localhost:8080/projects/{projectId}/files?exclude=test_*.py"

# Combine include and exclude
curl -X GET "http://localhost:8080/projects/{projectId}/files?include=test&include=*.py&exclude=test_*.py"
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

files = hc.list_files(
    project_id=project.id, 
    include=["test"]
)

files = hc.list_files(
    project_id=project.id, 
    include=["*.py"]
)

files = hc.list_files(
    project_id=project.id, 
    exclude=["test_*.py"]
)

files = hc.list_files(
    project_id=project.id, 
    include=["test", "*.py"],
    exclude=["test_*.py"]
)

Symbol search allows you to find specific symbols (like functions, classes, or variables) within your project. This is extremely helpful when you're trying to locate specific code elements without knowing their exact file location.

Basic Usage

To search for symbols:

curl -X GET "http://localhost:8080/projects/{projectId}/symbols?type=symbol&query=your_symbol_name"
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

symbols = hc.search_symbols(
    project_id=project.id, 
    query="your_symbol_name"
)

Advanced Options

You can customize the symbol search with additional parameters:

  • limit: Specify the maximum number of results (default is 10, max is 100)
  • Include or exclude specific symbol types. By default, the search will exclude fields and variables.
# Limit results to 20
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=symbol&query=your_symbol_name&limit=20"

# Include only functions and classes (example, actual parameters may vary)
curl -X GET "http://localhost:8080/projects/{projectId}/search?type=symbol&query=your_symbol_name&include=function&include=class"
# Coming soon
import hide
from hide import model

hc = hide.Client()
project = hc.create_project(
    repository=model.Repository(url="https://github.com/your-username/your-repo")
)

symbols = hc.search_symbols(
    project_id=project.id, 
    query="your_symbol_name", 
    limit=20
)

symbols = hc.search_symbols(
    project_id=project.id, 
    query="your_symbol_name", 
    include=["function", "class"]
)

Tips for Effective Searching

  1. Use specific queries: The more specific your search query, the more accurate your results will be.
  2. Leverage regex: For complex search patterns, use regex in content search.
  3. Combine search types: Use file search to narrow down the scope, then use content search within those files.
  4. Utilize symbol search: When looking for specific code elements, symbol search can be faster than content search.

By leveraging these search capabilities, coding agents can efficiently navigate and analyze projects, enabling faster code comprehension, more accurate task execution, and enhanced decision-making in various development scenarios. This empowers AI-driven development tools to provide more intelligent and context-aware assistance throughout the software development lifecycle.