👻 Ghost - AI-Powered Test Generation & Healing for Python
Project description
Ghost
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 pytest suite covering happy paths, error conditions, and boundary cases.
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:
- Groq: For ultra-low latency feedback loops (recommended for watch mode).
- OpenAI: GPT-4o for complex reasoning and difficult test scenarios.
- Anthropic: Claude 3.5 Sonnet 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 https://github.com/ghost-team/ghost.git
cd ghost
pip install -e .
Getting Started
-
Initialize Ghost Run the initialization command in your project root. This creates a
ghost.tomlconfiguration file.ghost init -
Configure API Keys Export your API keys as environment variables or add them to a
.envfile.export OPENAI_API_KEY=sk-... # or export GROQ_API_KEY=gsk_...
-
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
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 ghosttest-0.2.0.tar.gz.
File metadata
- Download URL: ghosttest-0.2.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea456384ef7f7ee879cc54c7fbf322d1e0db54c5c65f31d7fe3e44c25989e3c6
|
|
| MD5 |
47930e07dee075fa38e4fd7ca9a236b2
|
|
| BLAKE2b-256 |
78d85abf4db2b189e292e6d3e366c86249bb93b4a9d13a01f6df2dc74b94308c
|
File details
Details for the file ghosttest-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ghosttest-0.2.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74b0ab3872cde25df6635af233e9772d896480edc0e476d86b035348ab93dc93
|
|
| MD5 |
a90732454e38594bb5fa9240795aedaa
|
|
| BLAKE2b-256 |
ed2b9cf3bd94be0f7d41dfce7f8dfead7c86472bfe9bbc85d709ac19e15c25ce
|