code-wombat

searchable index of your local source code
git clone git://git.ma300k.de/code-wombat
code-wombat - searchable index of your local source code

1) Introduction
2) Installation
3) Usage
4) Emacs
5) Bug Reports
6) License


------------------------------------------------------------------------
Introduction

code-wombat creates an index over the source code in your git
repositories. The index can be searched using natural language.

It uses LLM embeddings to find code snippets matching your
description. The embeddings are created using ollama (see
https://ollama.com/ ).


------------------------------------------------------------------------
Installation

Install code-wombat with pip:

$ pip install .


------------------------------------------------------------------------
Usage

Add the repos you want to index to code-wombat:

$ cwb add-repo everarch git://git.ma300k.de/everarch

You can also add local repos using their path on the file system. For
example /home/baba/path/to/my/repo.

Make sure your ollama server is running. If you don't have one yet you
can start it via docker:

$ docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
$ docker exec ollama ollama pull nomic-embed-text

After adding one or more repos you must update the index. That might
take a while for large repos:

$ cwb update-index --progress

Now you can search the index:

$ cwb search 'generate checksums'
src/basics-test.c:1249+685
 repo: everarch
 branch: main
 head: befb9fa67f4a82017395a4122abb71cb1e6f3074
src/glacier.h:7421+219
 repo: everarch
 branch: main
 head: befb9fa67f4a82017395a4122abb71cb1e6f3074
src/basics-test.c:1020+516
 repo: everarch
 branch: main
 head: befb9fa67f4a82017395a4122abb71cb1e6f3074

The results above show the repo name, branch name, path of the source
file in the repo and the point in the file which matched the search.

The snippet of the first result can be extracted with the following
call:

$ cwb get-file get-file everarch befb9fa67f src/basics-test.c -o 1249 -s 685
evr_trim(&start, &end, s);
assert(start == &s[1]);
assert(end == &s[2]);
}

void test_buf_pos_checksums(void){
char buf[4];
struct evr_buf_pos bp;
// write data with checksum
evr_init_buf_pos(&bp, buf);
evr_push_n(&bp, "abc", 3);
evr_push_8bit_checksum(&bp);
assert_msg((unsigned char)buf[3] == 217, "Checksum was %u", (unsigned char)buf[3]);


------------------------------------------------------------------------
Emacs

The file emacs/code-wombat.el provides the interactive cwb-search
function. It searches the code-wombat index and provides a mode for
easy navigation.


------------------------------------------------------------------------
Bug Reports

Send bug reports to Markus Peröbner <markus.peroebner@gmail.com>.


------------------------------------------------------------------------
License

See the file COPYING for details.