Thanks to visit codestin.com
Credit goes to github.com

Skip to content

An automated Senior Engineer in your terminal. Detects crashes, analyzes root causes, and fixes code by making AI agents argue.

Notifications You must be signed in to change notification settings

rudra-swnt-12/ghost-cli

Repository files navigation

Ghost

A CLI tool that fixes your code by making AI agents argue with each other until they agree on a solution. It's like an automated Senior Engineer in your terminal.

What is this?

This is a pure vibe coded project. I didn't write a spec document or draw UML diagrams. I just started typing because the current state of "AI Code Repair" tools didn't sit right with me.

Most tools right now fall into two buckets:

  1. Too Simple: They take an error, pass it to GPT-4, and apply the first try/except block it spits out. This is "lazy coding" and usually breaks the logic.
  2. Too Complex: Full-blown autonomous agents that take 5 minutes to run, cost $2 per execution, and require a Docker container.

I wanted the sweet spot. Fast & context-aware.

The Backstory

This project is actually a fusion of three previous projects I built, which were all cool but isolated:

  • Orion: An SRE "Detective" that analyzed stack traces. It was great at finding what broke, but bad at fixing it.
  • Maven: A git analytics tool. It knew who wrote the code and if the file was "high risk" (high churn), but it couldn't actually read or fix bugs.
  • LLM Court: A fun experiment inspired by Andrej Karpathy's LLM Council where I made several LLMs debate code changes.

The problem was I was the middleware. I found myself running a script, copying the error to Orion, checking Maven for context, and then pasting it all into LLM Court. It was manual and annoying.

So I smashed them together into a single binary called Ghost.

The Idea

When you run ghost run python app.py, Ghost sits in the background. If your app crashes, Ghost wakes up and runs a pipeline:

  1. Orion parses the traceback. It doesn't just read the error; it uses a "Tree of Thoughts" approach to hypothesize why it happened.
  2. Maven checks the git history. It tells the repair agent: "Hey, Rudra wrote this 3 months ago, and this file changes constantly. Be careful."
  3. The Court Council convenes.
    • Defense: Proposes a fix.
    • Prosecutor: Critiques the fix against The Ghost Laws (e.g., "You can't just delete the code to fix the error!").(P.S, I spent a lot of time on this issue)
    • Judge: Synthesizes the arguments, takes the final judgement & writes the final code.

The "Ghost Laws"

This is the cool part. I noticed LLMs are very lazy if you give them the same error again. If they see a ZeroDivisionError, they just delete the math and return 0. To stop this, I wrote a strict "Constitution" (prompt) that the agents must follow.

  • Law of Preservation: You must preserve the original intent. Fixing the crash is not enough; the logic must survive.
  • Law of Integrity: No pass blocks. No placeholders.

Usage

Install it directly from GitHub:

uv tool install git+https://github.com/rudra-swnt-12/ghost-cli.git

Then, just wrap your command:

ghost run python broken_code.py

If it crashes, Ghost fixes it, shows you a diff, and applies it. Then you can even let it write the commit message:

ghost commit

Tech

Built with Python, Typer (CLI), Rich (pretty logs), and powered by Groq (because I need the debate to happen fast).

Feel free to add new features to this project
Enjoy.

About

An automated Senior Engineer in your terminal. Detects crashes, analyzes root causes, and fixes code by making AI agents argue.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages