Skip to content

Repository files navigation

πŸ‘» Ghost Protocol

The silent guardian of your AI-assisted workflow

Python 3.8+ License: MIT PRs Welcome


Stop wasting tokens on garbage files.
Stop committing 50MB SQLite databases.
Stop explaining to AI why your project has 847 PNG files.


Installation β€’ Quick Start β€’ Features β€’ Configuration


PyPI version


πŸ€” The Problem

You're vibe-coding with Claude/Cursor/Copilot. Life is good.

Then you notice:

  • πŸ’Έ Token costs are through the roof
  • 🐌 AI responses are slow because context is bloated
  • 😱 You accidentally committed a 200MB video file
  • πŸ”„ AI keeps "seeing" your node_modules or __pycache__

Ghost Protocol fixes all of this. Automatically. In the background.


✨ Features

Feature What it does
🚫 Auto-Ignore Detects heavy files (images, videos, databases) and adds them to .gitignore + .cursorignore
🧹 Self-Cleaning Removes stale entries when you delete the original files
πŸ›‘οΈ Commit Guard Blocks git commit if you try to push oversized source files
πŸ“Š Live Monitor Beautiful TUI dashboard showing token count & estimated API cost
⚑ Zero Config Works out of the box. Sensible defaults.
πŸ”‡ Silent Runs in background. No notifications. No interruptions.

πŸ“¦ Installation

From PyPI (Recommended)

pip install ghost-protocol

After installation, the ghost command will be available globally.

From Source

# Clone the repo
git clone https://github.com/Adrena1ine-ai/Ghost-Protocol.git
cd Ghost-Protocol

# Install in development mode
pip install -e .

πŸš€ Quick Start

Three commands. That's it.

# 1. Install the git hook (one time only)
ghost --install

# 2. Start the guardian daemon (run in background)
ghost --ghost

# 3. (Optional) Open the monitor in another terminal
ghost --monitor

Now forget about it. Ghost Protocol handles the rest.


πŸ“Š The Monitor

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ‘» Ghost Protocol v2.0.0 | Status: ACTIVE                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ“Š Project Stats           β”‚  🧠 The Brain                  β”‚
β”‚                             β”‚                                β”‚
β”‚  Total Tokens    1,247,832  β”‚  β€’ Writer: IgnoreManager (DRY) β”‚
β”‚  Files Tracked        342   β”‚  β€’ Scanner: Auto-updating (30s)β”‚
β”‚  Est. Cost ($3/M)  $3.74    β”‚  β€’ Config: Cached & Valid      β”‚
β”‚                             β”‚                                β”‚
β”‚                             β”‚  Press Ctrl+C to exit.         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš™οΈ Configuration

Create ghost_config.json in your project root:

{
  "limits": {
    "max_asset_size_mb": 1.0,
    "max_code_size_mb": 0.5,
    "debounce_seconds": 0.5
  },
  "skip_dirs": ["my_custom_folder", "secrets"],
  "extensions": {
    "garbage": [".custom", ".mybigfile"],
    "code": [".mycode"]
  }
}

Default Settings

Setting Default Description
max_asset_size_mb 1.0 Auto-ignore assets larger than this
max_code_size_mb 0.5 Warn/block code files larger than this
debounce_seconds 0.5 Wait time before processing file changes

Pre-configured Skip Directories

venv, .venv, node_modules, __pycache__, .git, 
.idea, .vscode, dist, build, coverage, target...

Pre-configured Garbage Extensions

.log, .sqlite, .db, .zip, .mp4, .mp3, .pdf, 
.png, .jpg, .gif, .exe, .dll, .bin...

πŸ—οΈ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Watchdog   │────▢│   Queue     │────▢│  IgnoreManager  β”‚
β”‚  (Events)   β”‚     β”‚  (Debounce) β”‚     β”‚  (Atomic Write) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                               β”‚
                                               β–Ό
                                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                        β”‚ .gitignore  β”‚
                                        β”‚.cursorignoreβ”‚
                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Design Decisions:

  • Singleton Config β€” Thread-safe, cached sets for O(1) lookups
  • File Locking β€” Cross-platform advisory locks (fcntl/msvcrt)
  • Atomic Writes β€” temp file β†’ os.replace() for data integrity
  • Fail-Closed β€” Git hook blocks commit on any error

πŸ§‘β€πŸ’» For Developers

# Project structure
ghost-protocol/
β”œβ”€β”€ main.py              # Entry point & CLI
β”œβ”€β”€ requirements.txt     # Dependencies
└── src/
    β”œβ”€β”€ config.py        # Singleton configuration
    β”œβ”€β”€ core.py          # Logger & console
    β”œβ”€β”€ utils.py         # Atomic write, file locking
    β”œβ”€β”€ watcher.py       # File system events β†’ queue
    β”œβ”€β”€ scanner.py       # Project stats & git integration
    β”œβ”€β”€ pruner.py        # Cleanup stale ignore entries
    β”œβ”€β”€ ignore_manager.py # DRY: single source for ignore logic
    └── monitor.py       # Rich TUI dashboard

🀝 Contributing

PRs are welcome! Please:

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

πŸ†˜ Troubleshooting

Command ghost not found (Windows)

This is a common issue on Windows when Python Scripts folder is not in PATH.

Quick fix - Use Python module instead:

python -m src --install
python -m src --ghost

Permanent fix - Add Scripts to PATH:

  1. Find your Scripts folder:

    python -c "import site; import os; print(os.path.join(site.getuserbase(), 'Scripts'))"
  2. Add to PATH temporarily:

    $env:Path += ";C:\Users\YourName\AppData\Roaming\Python\Python314\Scripts"
  3. Add to PATH permanently:

    • Press Win + R, type sysdm.cpl, press Enter
    • Go to Advanced β†’ Environment Variables
    • Under User variables, find Path β†’ Edit
    • Click New and add the Scripts path
    • Click OK and restart your terminal

Other Issues

  • Not a git repo: Make sure you're in a git repository (git init if needed)
  • Import errors: Reinstall with pip install --upgrade ghost-protocol

πŸ“„ License

MIT Β© 2024 β€” Do whatever you want with it.


Made for vibe coders, by a vibe coder.

Because life's too short to manually edit .gitignore


⭐ Star this repo if Ghost saved your tokens ⭐

About

Ghost Protocol watches your project in the background and protects you from yourself. 🚫 **Auto-Ignore Heavy Assets:**🧹 **Smart Cleanup:**πŸ›‘οΈ **Commit Guard:**πŸ“Š **Live Dashboard:**πŸš€ **Performance:**

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages