Skip to main content

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 .txt or .md file 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

  1. Launch the application:
    pig-t3
    
  2. Select your project folder (or let it auto-detect).
  3. In the Generator tab, optionally adjust extensions and ignore list, then click Generate Context.
  4. Copy the generated file and send it to your favourite AI assistant.
  5. Paste the AI's JSON response into the Editor tab, click Apply Changes.

🧩 How It Works

Workflow

  1. Scan → Collect all source files into a single report.
  2. Send → The report is given to an LLM along with the editing instructions (optionally).
  3. Receive JSON → The LLM returns a JSON array of file operations.
  4. 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

pig_t3-1.1.1.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pig_t3-1.1.1-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file pig_t3-1.1.1.tar.gz.

File metadata

  • Download URL: pig_t3-1.1.1.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

Hashes for pig_t3-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b5072797d21dc121bc3333f9e354f31dc8894b0d9ce915fb1d7c4871f4f33a8a
MD5 4bd440062633047e9e796a685a277dcb
BLAKE2b-256 994044e7d6edc7bc5e3d884f0b0e3fda0a6fbb6fcf4d9e87c9878bcba951f584

See more details on using hashes here.

File details

Details for the file pig_t3-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pig_t3-1.1.1-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

Hashes for pig_t3-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ecbbaaaad7be484c9d0624baa14b8de355e7a0cc897785614b058b2270a1c9e0
MD5 390cafcfdf8c1ffd4027f9a61093a866
BLAKE2b-256 da22388c91f20d749904c3045b123627fcc7554333d461e7eca4027a6255fc85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page