An interactive tool for applying, reviewing, and managing incremental code patches in your projects that also integrates AI-driven patch generation via conversational prompts. Leveraging the Vibe Patches specification, this tool provides a streamlined UI for generating, previewing, and committing code changes.
Coding with AI can be fun, rewarding, and profitable, but it can also be frustrating and time consuming. This tool aims to bridge this gap by providing you with the controls you need to code in confidence, knowing you can revert any changes that break your code, and avoid whitespace issues that plague traditional patch systems.
- Apply Vibe Patches: Seamlessly apply
add_function
,add_method
,add_class
,add_block
,remove_*
, andreplace_*
patches. - Version Navigation: Browse through patch history with forward and backward controls.
- Backup Originals: Automatically back up original files before applying changes.
- Dry‑Run Mode: Preview patches without modifying disk files.
- Diff Viewer: See side‑by‑side diffs of pending and applied changes.
- Clone the repository:
conda create -n vibe python=3.12 -y # [optional] conda activate vibe # [optional] cd ~/code/ # use your code directory git clone git@github.com:wyojustin/Vibe.git # clone the repo cd Vibe
- Install dependencies:
pip install -r requirements.txt # install reqs
- Run tests:
python tests/regression_tester.py # run the regression tests
- Copy example fixtures:
cp -r tests/multi_patch/ ~/tmp/example/ # save to tmp for testing
- Start the UI:
python server.py --help # check out the options python server.py --baseDir ~/tmp/example # launch server
Below is a step-by-step guide to using the Vibe Patch Diff UI, illustrated with screenshots.
Open a terminal and run:
python launch_vibe.py
Select the Python file you wish to edit, then click Launch Server.
After browsing and selecting your file, and launching the server, the Diff View will display the current file contents.
Click the LLM Patch tab to bring up the prompt interface.
Type your desired modification in the prompt box (e.g., “Please add a class that greets people”).
Click Preview Patch to view the patch preview. The diff view will update to show changes side-by-side.
Click Apply to accept the changes and update your file. The diff view now shows the new code as applied.
Tip: Use the Previous and Next buttons to navigate between backups.
Note: All screenshots are located in Vibe/docs/screenshots/.
To leverage the AI-driven patch generation capabilities of Vibe, you need to configure your Google Gemini API key. Vibe uses the python-dotenv
library to load this key from a .env
file in your project root, making configuration straightforward and secure.
-
Obtain a Gemini API Key:
- Visit Google AI Studio.
- You may need to sign in with your Google account and agree to the terms.
- Once in AI Studio, click on "Get API key" (often found in the left sidebar or by clicking your profile/avatar).
- Follow the prompts to create a new API key. Copy this key securely.
-
Create a
.env
File:- In the root directory of your Vibe project (the
Vibe/
directory whereserver.py
andrequirements.txt
are located), create a new file named.env
. - Add your Google Gemini API key to this file. The Vibe server typically expects this key under the environment variable name
GOOGLE_API_KEY
:ReplaceGOOGLE_API_KEY="your_google_api_key_here"
"your_google_api_key_here"
with your actual Gemini API key.
- In the root directory of your Vibe project (the
-
Ensure
.env
is Ignored by Git (Crucial for Security):- Your API key is sensitive information and should never be committed to version control.
- Open your
.gitignore
file (create one in the project root if it doesn't exist) and add the following line:.env
- This will prevent Git from tracking your
.env
file and accidentally exposing your key.
-
Launch the Server:
- With the
.env
file in place,python-dotenv
(assuming it's integrated intoserver.py
or a startup script) will automatically load theGOOGLE_API_KEY
into the environment when the application starts. - Start the Vibe server as usual:
python launch_vibe.py
Browse to the file you'd like to edit, then click "Launch Server"
- With the
-
Verify Integration:
- Open the Vibe UI in your browser: http://127.0.0.1:8000/. (if not already opened by Launch Server click)
- Navigate to the "LLM Patch" tab.
- If the "Generate Patch" button is enabled and there are no error messages like "LLM generation is not available" or "Error checking LLM availability" in the status area below the prompt input, your API key is likely configured correctly and the server is communicating with the Gemini API.
Important Security Reminders:
- Always keep your API keys confidential.
- The
.env
file method is for local development. For production deployments, use your hosting provider's recommended way to manage secrets (e.g., environment variables set directly on the server, secret management services like Google Cloud Secret Manager). - Double-check that
.env
is listed in your.gitignore
file before committing any changes.
If Vibe is configured to use a different environment variable name for the Gemini key, please adjust the .env
file accordingly.
- Open the tool in your browser at
http://localhost:8000
. - Click Load File and select
hello.py
. - Click Load Patch and select a
.vibe
file. - Preview the diff and click Accept to apply changes.
- Use Previous and Next buttons to navigate backups.
- In the chat prompt, ask:
Please create a Vibe Patch to add a new class called GrumpyGreater to hello.py
- The AI returns a patch spec:
# VibeSpec: 1.5 patch_type: add_class file: hello.py --- code: | class GrumpyGreater: """ A grumpy greeter that begrudgingly greets. """ def __init__(self, name): self.name = name def greet(self): print(f"{self.name}, what do you want?")
- Paste this patch into the bottom editor and click Load Patch to preview.
- Click Accept to apply the class into
hello.py
.
Suppose you want to add a decorated function to your project. Create a .vibe
file:
# VibeSpec: 1.6
patch_type: add_function
file: hello.py
--- code: |
@log_enter_exit
@timer()
def greet(name):
print(f"Greetings, {name}!")
Then apply it via CLI or UI:
# Preview the patch (dry‑run)
python vibe_cli.py preview decorator_patch.vibe
# Apply the patch
python vibe_cli.py apply decorator_patch.vibe
After applying, hello.py
will include:
@log_enter_exit
@timer()
def greet(name):
print(f"Greetings, {name}!")
This project is licensed under the MIT License. See LICENSE for details.