Ottodocs is a command-line tool built in Go that utilizes OpenAI's ChatGPT API to generate commit messages, pull requests, answers to questions, and even shell commands based on input prompts and code context. It helps developers automate various parts of their development workflow using AI. The tool requires an OpenAI API key to function.
There are two methods to install OttoDocs:
- Precompiled binaries: Download the precompiled binaries from the GitHub releases tab.
- Build from source: Clone the repo and build the binary by running the following commands:
Simply download the binary for your platform from the GitHub releases tab and place it in your $PATH
.
OttoDocs utilizes the just
command runner for building and running tasks, making maintaining the project easier. If you do not have just
installed, see here for installation methods. Ottodocs requires Go 1.20+ to build.
git clone https://github.com/TimeSurgeLabs/ottodocs.git
cd ottodocs
just build # will build to bin/otto
# or
just install # will build & copy to $GOPATH/bin.
If you want to build for all supported platforms, you can run the following command:
just crossbuild
This will build and compress binaries for all supported platforms and place them in the dist
directory.
First, you need to create an OpenAI API Key. If you do not already have an OpenAI account, you can create a new one and get some free credits to try it out. Once you have an account, you can create an API key by going to the API Keys tab in your account settings.
Once you have an API key, you can log in to ottodocs by running the following command:
otto config --apikey $OPENAI_API_KEY
You can set the model to use by running:
otto config --model $MODEL_NAME
You can add a GitHub Personal Access Token for opening PRs by running:
otto config --token $GITHUB_TOKEN # Optional. Only needed for opening PRs and reading Issues
Make sure that your access token has the repo
scope.
Once that is complete, you can start running commands!
More detailed usage can be found in the documentation.
To Chat with ChatGPT from the commandline, use chat.
otto chat
Otto can generate code and save it directly to your project! To do this, you can run the following command:
otto edit <path to file> -g "Write me a Python function that returns the sum of two numbers"
You can also give Otto additional context to help it generate better code:
otto edit <path to file> -g "Write me a Python function that returns the sum of two numbers" -c hello_world.py
Or you can have it use as much of the repo as possible as context:
otto edit <path to file> -g "Write me a Python function that returns the sum of two numbers" -r
otto docs <path to repo or file>
Or for a single file, you can run:
otto doc -f <path to file>
Ask a question about a repo:
otto ask . -q "What does LoadFile do differently than ReadFile?"
Generate a commit message:
otto commit # optionally add --push to push to remote
Generate a pull request:
# make sure you are creating the PR on the correct base branch
otto pr -b main # optionally add --publish to publish the Pull Request
Generate release notes:
otto release # optionally add --publish to publish the release
Ask it about commands:
otto cmd -q "what is the command to add a remote?"
For detailed usage instructions, please refer to the documentation.