AI Context Generator & Patcher with GUI – analyse, patch and optimise codebases via local LLMs
Project description
🐖 PIG-T3 – AI Context Generator & Patcher
PIG-T3 is a powerful desktop application (GUI) that helps you work with large codebases together with AI assistants (ChatGPT, Claude, DeepSeek, local Ollama models).
It generates a context report containing the full project structure and source code, ready to be sent to any LLM. It then allows you to apply the AI's JSON-based code changes automatically – including creating, editing, moving and deleting files – with full undo/redo support.
Additionally, PIG-T3 includes:
- 📝 AI Plan Manager – generate step-by-step implementation plans and execute them automatically.
- 🔍 Code Quality Scanner – analyse your Python code (complexity, maintainability, lint score, security).
- 🧠 Context Optimizer – select only the most relevant files for a given task using dependency graphs and AI ranking.
- 🎨 Multiple themes (dark, light, pink, eye-care) and Git integration.
✨ Features
🏠 Context Generator
- Scan a project folder, ignore binary/unwanted files, collect source code.
- Produce a single
.txtor.mdfile with XML-like tags for each file. - Optionally include line numbers and an AI instruction prompt for JSON patching.
- Copy the output file directly to the clipboard.
✏️ JSON Patcher (Editor)
- Paste the LLM's response (JSON array of actions).
- Validate and pretty-print the JSON.
- Apply changes to the disk: create, delete, move, edit (replace_lines, insert_after_line, replace_text).
- Built-in Ollama Auto-Fix – if the LLM returns malformed JSON, let a local model repair it.
- Full Undo/Redo history (files are backed up inside
.pig/backups).
📝 AI Plan Manager
- Describe your project goal in natural language – PIG-T3 will generate a detailed step-by-step plan.
- Each step can be executed automatically:
- The app prepares an optimized context.
- An LLM (local or web) generates the necessary code changes in JSON format.
- Changes are applied immediately (or sent to the Editor for manual review).
- Supports retries on errors, plan validation, and Git auto-commit before each step.
📊 Code Quality Analysis
- Scans all Python files in the project.
- Calculates:
- Cyclomatic Complexity (Radon CC)
- Maintainability Index (Radon MI)
- Pylint Score (custom penalty-based score)
- Security Issues (Bandit)
- Displays results in a sortable tree with color-coded statuses.
🧠 Context Optimizer
- Given a task description, selects the most important files for the AI to understand.
- Uses a dependency graph (imports) with BFS and an LLM-based relevance ranking.
- Helps keep the context size within token limits while retaining crucial information.
🤖 Supported AI Backends
- Ollama – any local model (e.g.,
qwen2.5-coder). - Web APIs – DeepSeek (Chat), Gemini (AI Studio) via browser automation.
- BomjAPI – a manual testing tool (opens a window where you paste responses by hand).
📦 Installation
PIG-T3 requires Python 3.8+. Install directly from PyPI:
pip install pig-t3
If you plan to use the Web API backends (DeepSeek, Gemini), you also need to install a Chromium browser for Playwright:
playwright install chromium
Dependencies
These are installed automatically:
requests, radon, pylint, vulture, bandit, Pillow, majorchik-api (Playwright-based web automation), networkx.
🚀 Quick Start
- Launch the application:
pig-t3
- Select your project folder (or let it auto-detect).
- In the Generator tab, optionally adjust extensions and ignore list, then click Generate Context.
- Copy the generated file and send it to your favourite AI assistant.
- Paste the AI's JSON response into the Editor tab, click Apply Changes.
🧩 How It Works
Workflow
- Scan → Collect all source files into a single report.
- Send → The report is given to an LLM along with the editing instructions (optionally).
- Receive JSON → The LLM returns a JSON array of file operations.
- Apply → PIG-T3 parses the JSON, backs up affected files, and performs the changes.
JSON Actions Reference
A typical LLM response looks like this:
[
{
"action": "create",
"path": "utils/helper.py",
"content": "def help():\n return True"
},
{
"action": "edit",
"path": "main.py",
"operations": [
{
"type": "replace_lines",
"start": 10,
"end": 12,
"content": " new_code()"
},
{
"type": "insert_after_line",
"line": 15,
"content": " logger.info('Done')"
}
]
}
]
Full specification is available in the Info / JSON Specs tab inside the app.
⚙️ Configuration
All settings are saved in app_config.json (global) and in .pig/state.json (per project).
You can tweak:
- Theme, font size, tree row height.
- Context optimizer parameters (BFS depth, LLM weighting).
- Git integration (auto-commit, auto-push, branch mode).
- LLM timeouts and retry settings.
🐙 Git Integration
When enabled in settings, PIG-T3 can:
- Automatically create a new Git branch before executing a plan step.
- Commit all changes with a descriptive message.
- Push to remote after each successful step.
🧪 Development & Building
To build a standalone executable (Windows):
pyinstaller --noconsole --onefile --icon=PIG_T3/icon.png --add-data "PIG_T3/logo.png;." --add-data "PIG_T3/icon.png;." --name PIG PIG_T3/main.py
📄 License
PIG-T3 is released under the MIT License. See the LICENSE file for details.
🙏 Acknowledgements
This project uses several open-source libraries and tools: Radon, Pylint, Vulture, Bandit, NetworkX, Playwright, and others. Special thanks to the Ollama project for local AI capabilities.
Made with ❤️ by Loki (gosoftware2025@gmail.com)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pig_t3-1.1.0.tar.gz.
File metadata
- Download URL: pig_t3-1.1.0.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18c5d9af670eb297542bd1c1952080d0f725d8feeb9fc6f1254485c1f456bb4f
|
|
| MD5 |
e464fcf03818efc51f529645fa2b1d0d
|
|
| BLAKE2b-256 |
5cd37b32c99cee7ea65531b4efedfe6420e037b5ecb332bba20d4b210b6058f7
|
File details
Details for the file pig_t3-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pig_t3-1.1.0-py3-none-any.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc2e64e73174cc10e7e55e69fce32a39ef31c5a054cbff5de00e5a842d7118a3
|
|
| MD5 |
6e8a80d52336fdde1d52b3af8593e01f
|
|
| BLAKE2b-256 |
0eb5b64cce1fc898b72c407a79a74a97d51842cec0b627a2b1c48e38ed7ce801
|