|
3 | 3 | Codebased is the most powerful code search tool that runs on your computer.
|
4 | 4 |
|
5 | 5 | Here's why it's great:
|
| 6 | + |
6 | 7 | - Search, simplified: Combines semantic and full-text search to find what you're looking for, not just what you typed.
|
7 | 8 | - Search code, not just text: Searches for complete code structures, not just lines of text, in 11 languages.
|
8 | 9 | - Ignores uninteresting files: Respects your `.gitignore` file(s) and ignores hidden directories.
|
9 | 10 | - Instant editing: Selecting a search result opens your favorite editor at the correct file and line number.
|
10 | 11 | - Fast: Indexes your code in seconds, searches in milliseconds, and updates in real-time as you edit your code.
|
11 | 12 | - Open-source, runs locally: No code is stored on remote servers.
|
12 | 13 |
|
13 |
| -## Table of Contents |
| 14 | +## Getting Started |
| 15 | + |
| 16 | +The fastest way to install Codebased is with [pipx](https://github.com/pypa/pipx?tab=readme-ov-file#install-pipx): |
| 17 | + |
| 18 | +```shell |
| 19 | +pipx install codebased |
| 20 | +``` |
| 21 | + |
| 22 | +Verify the installation by running: |
| 23 | + |
| 24 | +```shell |
| 25 | +codebased --version |
| 26 | +``` |
| 27 | + |
| 28 | +If this fails, please double-check your pipx installation. |
| 29 | + |
| 30 | +Next, run the following command in a Git repository to start searching: |
| 31 | + |
| 32 | +```shell |
| 33 | +codebased search |
| 34 | +``` |
| 35 | + |
| 36 | +The first time you run Codebased, it will create a configuration file at `~/.codebased/config.toml`. |
| 37 | +It will prompt you for an OpenAI key, you can access a testing key on the [Discord](https://discord.gg/cQrQCAKZ). |
| 38 | + |
| 39 | +Once this is finished, `codebased` will create an index of your codebase, stored in `.codebased` at the root of your |
| 40 | +repository. |
| 41 | +This takes seconds for most projects, but can take a few minutes for large projects. |
| 42 | +Most of the time is spent creating embeddings using the OpenAI API. |
| 43 | + |
| 44 | +Once the index is created, a terminal UI will open with a search bar. |
| 45 | +At this point, you can start typing a search query and results will appear as you type. |
| 46 | + |
| 47 | +- You can use the arrow keys and the mouse to navigate the results. |
| 48 | +- A preview of the selected result is displayed. |
| 49 | +- Pressing enter on the highlighted result opens the file in your editor at the correct line number. |
| 50 | +- Pressing escape returns to the search bar. |
| 51 | +- As you edit your code, the index will be updated in real-time, and future searches will reflect your changes. |
| 52 | + |
| 53 | +Codebased will run `stat` on all non-ignored files in your repository, which can take a few seconds, but after that |
| 54 | +will listen for filesystem events, so it's recommended to use the TUI. |
| 55 | + |
| 56 | +# Development |
| 57 | + |
| 58 | +If you'd like to contribute, bug fixes are welcome, as well as anything in the list |
| 59 | +of [issues](https://github.com/codebased-sh/codebased/issues). |
| 60 | + |
| 61 | +Especially welcome is support for your favorite language, as long as: |
| 62 | + |
| 63 | +1. There's a tree-sitter grammar for it. |
| 64 | +2. There are Python bindings for it maintained by the excellent [amaanq](https://pypi.org/user/amaanq/). |
| 65 | + |
| 66 | +Also, if there's anything ripgrep does that Codebased doesn't, feel free to file an issue / PR. |
| 67 | + |
| 68 | +Clone the repository: |
| 69 | + |
| 70 | +```shell |
| 71 | +git clone https://github.com/codebased-sh/codebased.git |
| 72 | +``` |
| 73 | + |
| 74 | +Install the project's dependencies (requires [poetry](https://python-poetry.org), using a virtual environment is |
| 75 | +recommended): |
| 76 | + |
| 77 | +```shell |
| 78 | +poetry install |
| 79 | +``` |
| 80 | + |
| 81 | +Run the tests (some tests require an `OPENAI_API_KEY` environment variable, usage is de minimis): |
14 | 82 |
|
15 |
| -- [Appendix](#appendix) |
16 |
| - - [Languages](#languages) |
| 83 | +```shell |
| 84 | +poetry run pytest |
| 85 | +``` |
17 | 86 |
|
18 | 87 | # Appendix
|
19 | 88 |
|
|
0 commit comments