Skip to main content

Ghost - AI-Powered Test Generation & Healing for Python

Project description

Ghost

PyPI Python Versions License Code Style

Ghost Logo

Autonomous Test Generation & Self-Healing for Python

Ghost is an intelligent agent that lives in your terminal. It watches your codebase, automatically generates comprehensive test suites, and—most importantly—fixes them when they fail.


The Workflow

Ghost operates on a continuous feedback loop, ensuring your tests are always green without manual intervention.

graph TD
    A[File Change Detected] -->|Ghost Watcher| B(Analyze Code)
    B --> C{Tests Exist?}
    C -- No --> D[Generate New Tests]
    C -- Yes --> E[Run Existing Tests]
    D --> E
    E --> F{Tests Pass?}
    F -- Yes --> G[✅ All Green]
    F -- No --> H[Analyze Stack Trace]
    H --> I[Self-Healing Agent]
    I -->|Apply Fix| E

Key Capabilities

Autonomous Generation

Ghost analyzes your Python source code to understand its logic, edge cases, and types. It then generates a complete test suite covering happy paths, error conditions, and boundary cases in any framework.

Self-Healing Engine

When a test fails, Ghost doesn't just report the error. It captures the stdout, stderr, and stack trace, feeds them back into the LLM, and generates a patch to fix the test code. It repeats this process until the test passes.

Real-time Watcher

Designed to run in the background. Ghost uses watchdog to monitor file system events. As soon as you save a file, Ghost triggers the testing cycle, providing immediate feedback.

Multi-Provider Architecture

Ghost is built to be model-agnostic. It supports (with your API keys):

  • Groq: For ultra-low latency feedback loops (recommended for watch mode).
  • OpenAI: GPT for complex reasoning and difficult test scenarios.
  • Anthropic: Claude for high-quality, idiomatic code generation.
  • Ollama: For local, privacy-focused development using Llama 3 or DeepSeek.

Installation

Using pip (Standard)

pip install ghosttest

Using uv (Fastest)

uv pip install ghosttest

From Source

git clone git@github.com:tripathiji1312/ghost.git
cd ghost
pip install -e .

Getting Started

  1. Initialize Ghost Run the initialization command in your project root. This creates a ghost.toml configuration file.

    ghost init
    
  2. Configure API Keys Export your API keys as environment variables or add them to a .env file.

    export OPENAI_API_KEY=sk-...
    # or
    export GROQ_API_KEY=gsk_...
    
  3. Start Watching Launch the daemon. Ghost will now monitor your project.

    ghost watch
    

Command Line Interface

Command Arguments Description
ghost init [PATH] Initializes a new Ghost configuration in the specified directory. Defaults to current directory.
ghost watch [PATH] Starts the file watcher daemon. Monitors for changes and triggers the test/heal loop.
ghost generate <FILE> Manually triggers test generation for a specific Python file.
ghost config N/A Opens an interactive configuration wizard to set providers, models, and paths.
ghost providers N/A Lists all currently supported AI providers and available models.
ghost version N/A Displays the current installed version of Ghost.

Configuration

Ghost is highly configurable via ghost.toml.

[ghost]
# The AI provider to use (openai, anthropic, groq, ollama)
provider = "openai"

# The specific model identifier
model = "gpt-4o"

# Directory where tests should be generated
test_dir = "tests"

# Maximum number of healing attempts before giving up
max_retries = 3

# List of files or directories to ignore
ignore = [
    "setup.py",
    "migrations/"
]

License

Distributed under the MIT License. See LICENSE for more information.

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

ghosttest-0.2.0.1.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

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

ghosttest-0.2.0.1-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file ghosttest-0.2.0.1.tar.gz.

File metadata

  • Download URL: ghosttest-0.2.0.1.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ghosttest-0.2.0.1.tar.gz
Algorithm Hash digest
SHA256 addac1ccae0b38798dceda6316571b94e72d42d3b9b20eb065f3580a5705cb68
MD5 4d1262195b63a52398304f2f64c18b27
BLAKE2b-256 696019aadb1518f9c19dfd85fcc3436e56da94aa9bc1eb5c2f160d595557a01e

See more details on using hashes here.

File details

Details for the file ghosttest-0.2.0.1-py3-none-any.whl.

File metadata

  • Download URL: ghosttest-0.2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ghosttest-0.2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fee60acaa8f667a2e38c87501498d7bfac15fd2564cccf58856ab2e3d4a1134
MD5 581823be55dd9c18a97927b731d4c2ac
BLAKE2b-256 cae7e6f969a7d6367e752a2b15996abfe345821c801dfc347f8c79f650ab8e90

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