gnaw's AI-powered search capabilities enable semantic code understanding and natural language queries.
gnaw uses vector embeddings to understand the semantic meaning of code:
The Hierarchical Navigable Small World (HNSW) algorithm provides:
Transform natural language into precise code searches:
# Find authentication-related code
gnaw agent ask "authentication functions"
# Find error handling patterns
gnaw agent ask "error handling" --type rs
# Search for database operations
gnaw agent ask "database queries" --dir src/db
gnaw understands code semantics beyond text matching:
Search for specific functionality:
gnaw agent ask "user authentication"
gnaw agent ask "database connection handling"
gnaw agent ask "error logging functions"
Find coding patterns:
gnaw agent ask "async/await patterns"
gnaw agent ask "error handling with try/catch"
gnaw agent ask "API endpoint definitions"
Search within specific contexts:
gnaw agent ask "authentication" --dir src/auth
gnaw agent ask "database queries" --type rs
gnaw agent ask "API routes" --type js
# Build index for current directory
gnaw agent index build
# Build index for specific directory
gnaw agent index build --target-dir /path/to/code
# Update existing index
gnaw agent index update
# Check index status and statistics
gnaw agent index status
AI search results include rich context:
Query: authentication functions
→ src/auth.rs (score: 0.95)
Lines 15-25
• Function definition matches query
• Contains authentication keywords
• High semantic similarity
pub fn authenticate_user(token: &str) -> Result<User, AuthError> {
// Authentication logic here
}
--type and --dir flags to narrow results