https://github.com/craftvscruft/menderbot
AI-powered command line tool for working with legacy code
https://github.com/craftvscruft/menderbot
ai antlr4 artificial-intelligence code-modification large-language-models llama-index llm python3 refactoring
Last synced: 9 days ago
JSON representation
AI-powered command line tool for working with legacy code
- Host: GitHub
- URL: https://github.com/craftvscruft/menderbot
- Owner: craftvscruft
- License: apache-2.0
- Created: 2023-05-09T21:51:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-21T14:49:50.000Z (almost 2 years ago)
- Last Synced: 2025-12-21T07:13:23.873Z (about 1 month ago)
- Topics: ai, antlr4, artificial-intelligence, code-modification, large-language-models, llama-index, llm, python3, refactoring
- Language: Python
- Homepage: https://mender.ai
- Size: 367 KB
- Stars: 12
- Watchers: 0
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Menderbot


[](https://github.com/craftvscruft/menderbot/blob/main/LICENSE)
[](https://scrutinizer-ci.com/g/craftvscruft/menderbot/?branch=main)
> The AI-powered command line tool for working with legacy code. [Designed](./doc/DESIGN.md) based on the principles of the [Mechanized Mending Manifesto](https://mender.ai/docs/intro).
## Status
Menderbot is usable in development of itself - a very small codebase. For instance, it's used on this project for first drafts of commit messages, it added most of the type annotations, and chat usually gives relevant answers. On codebases of an interesting size (> 10K lines) there is still much work to do.
## Commands implemented (-ish):
* `menderbot ask`: Ask a question about the codebase
* `menderbot chat`: Interactively chat about the codebase
* `menderbot commit`: Git commit the current changeset with a pre-populated commit message
* `menderbot diff`: Summarize the differences between two versions of a codebase
* `menderbot doc`: Generate documentation for the existing code (Python only)
* `menderbot review`: Review a code block or changeset and provide feedback
* `menderbot type`: Insert type hints (Python only)
* `menderbot ingest`: Index the current state of the repo for `ask` and `chat` commands
* `menderbot check`: Verify we have what we need to run
## System requirements
* Python 3.10+
* The environment variable `OPENAI_API_KEY` set to a valid OpenAI API Key.
* git
* Make (you already have it)
## Installing from source
Clone the project and install an editable version (this uses `python3 -m pip install -e .`):
```
git clone git@github.com:craftvscruft/menderbot.git
make install
```
### Installing from pip
You can also install directly from pip and avoid cloning the repo:
```
pip install menderbot --upgrade
```
## Running
You can run with `menderbot` in any repo. It's a good idea to start by running the `check` command to make sure we have what we need. For instance we will need to supply the OPENAI_API_KEY environment variable and a ``.menderbot-config.yaml` file indicating consent.
```
menderbot check
```
### Running with Docker (advanced)
If you don't have Python, you can run from [Docker](https://docs.docker.com/get-started/overview/) using the supplied Dockerfile. Run `make docker` to build the image and print instructions on how to run it.
## Developing
Clone the project...
```sh
git clone git@github.com:craftvscruft/menderbot.git
```
Then you can initialize your Python environment using [venv](https://docs.python.org/3/library/venv.html).
```sh
make venv
source venv/bin/activate
pip install "." ".[dev]"
```
If you want to re-generate the Antlr parsers, see [PARSERS.md](./doc/PARSERS.md), but you probably won't need to.
### Testing
Formatting, linting, tests, and type-checking can all be run with make, check the `Makefile` for the underlying commands. Run before commiting, or CI will bark :)
```sh
# Same as `make test type lint format`
make check
```
Or you can run individual steps if you prefer:
```sh
# Run pytest
make test
# Run pytest with a coverage report
make coverage
# Run mypy
make type
# Run pylint
make lint
# Run black and isort
make format
```
## Author
👤 **Ray Myers**
* YouTube: [Craft vs Cruft](https://www.youtube.com/channel/UC4nEbAo5xFsOZDk2v0RIGHA)
* Twitter: [@lambdapocalypse](https://twitter.com/lambdapocalypse)
* GitHub: [@raymyers](https://github.com/raymyers)
* LinkedIn: [@cadrlife](https://linkedin.com/in/cadrlife)
## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/craftvscruft/menderbot/issues). You can also take a look at the [contributing guide](https://github.com/craftvscruft/menderbot/blob/main/CONTRIBUTING.md).
## Show your support
Give a ⭐️ if this project helped you!
## Acknowledgements
* [OpenAI](https://platform.openai.com/docs/models/overview) GPT and Ada models
* [LlamaIndex](https://gpt-index.readthedocs.io/en/latest/), an LLM data framework
* [Antlr](https://www.antlr.org/) parser generator
## 📝 License
Copyright © 2024 [Ray Myers](https://github.com/raymyers).
This project is [Apache 2](https://www.apache.org/licenses/LICENSE-2.0) licensed.