codebase-ash-0.1.0 is not a library.
Codebase - Semantic Code Search Tool
A fast, offline semantic code search tool powered by tree-sitter that lets you search for code patterns using natural language queries.
Features
- Natural Language Queries: Search using plain English like "find functions", "show structs", "find enums"
- Semantic Search: Find code by what it does, not just by pattern matching (use
-iflag) - Multi-Language Support: Rust, Python, JavaScript, TypeScript, C, and C++
- Ranked Results: Relevance scoring for semantic searches
- Context Lines: View surrounding code with the
--contextoption - Syntax-Aware: Uses tree-sitter for accurate parsing, not just text matching
- Fast: Recursively scans directories and filters by file extension
- Colored Output: Beautiful terminal output with syntax highlighting
Installation
Option 1: Install from crates.io (Recommended)
This installs the codebase command globally on your system.
Option 2: Build from Source
The binary will be at target/release/codebase.exe (Windows) or target/release/codebase (Linux/Mac).
To install globally:
Option 3: Download Pre-built Binary
Download the latest release for your platform from GitHub Releases:
- Windows:
codebase-x86_64-pc-windows-msvc.zip - macOS:
codebase-x86_64-apple-darwin.tar.gz - Linux:
codebase-x86_64-unknown-linux-gnu.tar.gz
Extract and add to your PATH.
Usage
Basic Search (Pattern Mode)
# Find all functions in current directory
# Find structs in a specific directory
# Search only Rust files
# Search multiple file types
Semantic Search (Implementation Mode)
# Find functions that parse files (ranked by relevance)
# Show why each function matched
# Search for specific functionality across languages
Semantic mode (-i flag) searches by what the code does, not just patterns:
- Extracts function names and bodies
- Scores matches based on keyword relevance
- Ranks results by score (highest first)
- Shows match reasons in verbose mode
Context Lines
# Show 2 lines of context before and after each match
# Short form
Supported Query Patterns
Rust
- Functions: "find functions", "find fn", "find methods"
- Structs: "find structs"
- Enums: "find enums"
- Traits: "find traits", "find interface"
- Implementations: "find impl"
- Constants: "find const"
- Imports: "find import", "find use"
Python
- Functions: "find functions", "find def"
- Classes: "find classes"
- Decorators: "find decorators"
- Imports: "find imports"
JavaScript
- Functions: "find functions"
- Arrow Functions: "find arrow"
- Classes: "find classes"
- Variables: "find var", "find let", "find const"
- Imports/Exports: "find import", "find export"
TypeScript
- Functions: "find functions"
- Classes: "find classes"
- Interfaces: "find interface"
- Type Aliases: "find type"
- Enums: "find enum"
- Imports/Exports: "find import", "find export"
C/C++
- Functions: "find functions"
- Structs: "find structs"
- Classes (C++): "find classes"
- Enums: "find enums"
- Typedefs (C): "find typedef"
- Namespaces (C++): "find namespace"
- Templates (C++): "find template"
Examples
# Find all Rust implementations with context
# Find all TypeScript interfaces
Command Line Options
<QUERY>: Natural language query (required)-p, --path <PATH>: Path to search (default: current directory)-e, --ext <EXT>: Filter by file extensions (e.g., "rs,py,js")-C, --context <N>: Show N lines of context around matches-v, --verbose: Show verbose output including parse errors-h, --help: Show help information
How It Works
- File Walking: Recursively scans the specified directory
- Language Detection: Identifies language from file extension
- Tree-sitter Parsing: Parses files into Abstract Syntax Trees (AST)
- Pattern Matching: Maps your natural language query to tree-sitter queries
- Results: Displays matches with file paths, line numbers, and optional context
Supported Languages & Extensions
| Language | Extensions |
|---|---|
| Rust | .rs |
| Python | .py |
| JavaScript | .js, .jsx |
| TypeScript | .ts, .tsx |
| C | .c, .h |
| C++ | .cpp, .hpp, .cc, .cxx, .hh |
License
This project uses tree-sitter and various tree-sitter language parsers.