Agentic AI Workflows for DevOps
An open-source framework for patching and managing code repositories using large language models. PatchWork allows you to automate workflows like PR reviews, bug fixing, security patching, and more using a self-hosted CLI agent and your preferred LLMs.
Patchflows can be run locally in your CLI and IDE, or as part of your CI/CD pipeline.
PatchWork is available on PyPI and can be installed using pip:
pip install patchwork-cli --upgrade
PatchWork is built using Poetry, a dependency management and packaging tool for Python. To install PatchWork using Poetry, follow these steps:
Make sure you have Poetry installed. If you don't have it installed, you can install it by running:
curl -sSL https://install.python-poetry.org | python3 -
Clone the PatchWork repository:
git clone https://github.com/patched-codes/patchwork.git
Navigate to the project directory:
cd patchwork
Activate a shell using virtual environment:
poetry shell
Install the dependencies using Poetry:
poetry install
The CLI runs Patchflows, as follows:
patchwork <Patchflow> <?Arguments>
Where
key=value
. If key
does not have any value, it is considered a boolean True
flag.For an AutoFix patchflow which patches vulnerabilities based on a scan using Semgrep:
patchwork AutoFix openai_api_key=<YOUR_OPENAI_API_KEY> github_api_key=<YOUR_GITHUB_TOKEN>
The above command will default to patching code in the current directory, by running Semgrep to identify the vulnerabilities.
You can take a look at the default.yml
file for the list of configurations you can set to manage the AutoFix patchflow.
The patchwork-configs repository contains the default configuration and prompts for all the patchflows. You can clone that repo and pass it as a flag to the CLI:
patchwork AutoFix --config /path/to/patchwork-configs/patchflows
Patchwork comes with a set of predefined patchflows, and more will be added over time. Below is a sample list of patchflows:
Prompt templates are used by patchflows and passed as queries to LLMs. Templates contain prompts with placeholder variables enclosed by {{}} which are replaced by the data from the steps or inputs on every run.
Below is a sample prompt template:
{
"id": "diffreview_summary",
"prompts": [
{
"role": "user",
"content": "Summarize the following code change descriptions in 1 paragraph. {{diffreviews}}"
}
]
}
Each patchflow comes with an optimized default prompt template. But you can specify your own using the prompt_template_file=/path/to/prompt/template/file
option.
To create a new patchflow, follow these instructions.
To create a new step, follow these instructions.