PitchHut logo
codespelunker
A CLI tool that ranks code search results by relevance and structure.
Pitch

codespelunker provides a command-line interface for searching code with precise relevance ranking. Unlike typical search tools, it understands code structure without requiring indexing, enabling efficient searches that target exact implementations, comments, and more. Simplify your code exploration while enhancing accuracy.

Description

cs (codespelunker) is a powerful command-line interface (CLI) code search tool designed to provide smart results without the need for indexing. This innovative tool understands code structure and ranks search results based on relevance, addressing shortcomings typically found in standard text search tools.

Key Features

  • Relevance-Based Search: Unlike conventional search tools that treat code as plain text, cs analyzes code syntax on-the-fly. This allows it to rank matches by their significance, prioritizing logical implementations over comments and string instances.

  • Rapid Searching: Access fast and efficient search capabilities, capable of sifting through entire codebases without pre-built indices.

  • Contextual Filtering: Utilize structural filtering to reduce false positives in search results. You can focus on matches found within code, comments, or string literals with ease.

    cs "database" --only-code        # Only matches in code
    cs "FIXME" --only-comments       # Only matches in comments
    cs "error" --only-strings        # Matches within string literals
    cs "handleRequest" --only-declarations  # Find definitions
    cs "handleRequest" --only-usages        # Find all call sites
    
  • Complexity Gravity: This unique feature allows the tool to rank search results based on cyclomatic complexity, ensuring that more complex implementations are surfaced more prominently during searches.

    cs "login" --gravity=brain       # Emphasizes files with complex logic
    cs "login" --gravity=low         # Promotes simpler configuration files
    
  • Multiple Interfaces: Access the tool via console output, a built-in text user interface (TUI), or an HTTP server, enhancing usability across different environments.

    cs      # Enter TUI mode
    cs -d   # Start the HTTP server on port 8080
    

Usage Example

cs enables flexible search with boolean logic for creative queries. Searches can be combined using AND, OR, and NOT, and can filter results for specificity, enabling nuanced exploration of codebases:

cs (cat OR dog) AND NOT fish         # Complex queries combining multiple terms
cs "func main" path:cmd              # Find main functions under specific directories
cs "Copyright" --dedup               # Collapse identical copyright notices

Conclusion

cs offers a sophisticated and efficient solution for code searching that stands out due to its ability to understand code structure, provide relevant results, and operate without the overhead of maintaining an index. This makes it indispensable for developers aiming to streamline their workflow and improve productivity.

0 comments

No comments yet.

Sign in to be the first to comment.