Metadata-Version: 2.1
Name: codebased
Version: 0.4.18
Summary: AI-powered code search for the terminal.
Home-page: https://github.com/codebased-sh/codebased
Author: Max Conradt
Author-email: mhconradt@protonmail.com
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: chardet (>=5.2.0,<6.0.0)
Requires-Dist: colorama (>=0.4.6,<0.5.0)
Requires-Dist: faiss-cpu (>=1.8.0.post1,<2.0.0)
Requires-Dist: openai (>=1.42.0,<2.0.0)
Requires-Dist: textual (>=0.79.1,<0.80.0)
Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
Requires-Dist: toml (>=0.10.2,<0.11.0)
Requires-Dist: tree-sitter (>=0.22.3,<0.23.0)
Requires-Dist: tree-sitter-c (>=0.21,<0.22)
Requires-Dist: tree-sitter-c-sharp (>=0.21,<0.22)
Requires-Dist: tree-sitter-cpp (>=0.21,<0.22)
Requires-Dist: tree-sitter-go (>=0.21,<0.22)
Requires-Dist: tree-sitter-java (>=0.21,<0.22)
Requires-Dist: tree-sitter-javascript (>=0.21,<0.22)
Requires-Dist: tree-sitter-php (>=0.22,<0.23)
Requires-Dist: tree-sitter-python (>=0.23,<0.24)
Requires-Dist: tree-sitter-ruby (>=0.21,<0.22)
Requires-Dist: tree-sitter-rust (>=0.21,<0.22)
Requires-Dist: tree-sitter-typescript (>=0.21,<0.22)
Requires-Dist: typer (>=0.12.5,<0.13.0)
Requires-Dist: watchdog (>=5.0.0,<6.0.0)
Project-URL: Repository, https://github.com/codebased-sh/codebased
Description-Content-Type: text/markdown

# 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](https://github.com/BurntSushi/ripgrep)
and [GitHub Code Search](https://github.com/features/code-search) on a [~1 million-line codebase](https://chalk.ai/), 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:

```shell
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:

```shell
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:

![Empty Search Bar](https://github.com/codebased-sh/codebased/blob/5c3f4845d54a392503bf0f0f5c9af1b1cd471ed2/assets/empty_search.png?raw=true)

Once you start typing, you'll see a list of results appear:

![Search Bar with Results](https://github.com/codebased-sh/codebased/blob/5c3f4845d54a392503bf0f0f5c9af1b1cd471ed2/assets/search.png?raw=true)

- 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.

![Open Editor](https://github.com/codebased-sh/codebased/blob/5c3f4845d54a392503bf0f0f5c9af1b1cd471ed2/assets/editor.png?raw=true)

### Non-interactive mode

To make a single query, run:

```shell
codebased "What are you looking for?"
```
