AI-powered code search for the terminal and beyond.
Project description
Codebased
Find what you're looking for, not just what you typed.
Codebased is a command-line code search tool that helps you find what you're looking for, not just what you typed.
After making thousands of painstakingly crafted searches with regular expressions, path globbing, etc. using rg and GitHub Code Search on a ~1 million-line codebase, I decided there had to be a better way.
Codebased is the better way.
It's a game changer for medium-sized codebases (>10k lines), especially with multiple developers.
Here's why it's great:
- Finds entire functions, classes, and variables vs. single lines.
- Incrementally searches as you type, you might not need to type as much as you thought.
- Resilient to typos: mixing up a few characters or even a totally different word won't hurt.
- Opens the code in your favorite editor when you press enter.
Installation
Simply run:
pip install codebased
Configuration
When you run codebased
for the first time, it will create a configuration file at ~/.codebased/config.toml
.
You'll be prompted to enter your OpenAI API key if it's not set via the OPENAI_API_KEY
environment variable.
You can also choose the editor command.
Usage
Interactive mode
To open the interactive search interface, run:
codebased
The first time you run codebased
, it will create an index of your codebase.
The first index will take O(seconds) to build for medium-sized (>10k lines) codebases and O(minutes) for large codebases (>100k lines), but the index is cached for future runs.
Once the index is ready, you'll see a window open up with a search bar:
Once you start typing, you'll see a list of results appear:
- You can navigate them using the up/down arrow keys.
- A preview of the code for the selected result will be shown.
- You can press enter to open the selected result in your favorite editor. This really works. And it's awesome.
- Press Ctrl+C to exit.
Non-interactive mode
To make a single query, run:
codebased "What are you looking for?"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for codebased-0.4.22-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34853f124ef1395df6dc5e3026237c134420eefa0fb2261bd775e0c70b06b95c |
|
MD5 | 31b9a5da4cb5e40d3ffbb19c30e0e031 |
|
BLAKE2b-256 | 7e12d3016110393bac48bfb76fa5c390b8ebc150d8c8832d59d832741a7b0989 |