Skip to main content

The automated guardian of your sanity. Auto-ignores junk & protects repos.

Project description

๐Ÿ‘ป 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 v21.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 โญ

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

ghost_protocol-1.3.1.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

ghost_protocol-1.3.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file ghost_protocol-1.3.1.tar.gz.

File metadata

  • Download URL: ghost_protocol-1.3.1.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for ghost_protocol-1.3.1.tar.gz
Algorithm Hash digest
SHA256 e70490c7cccc0045be51534349b18ae18bedf872d5fe5a8b9e91f506af781d56
MD5 ec8a526a46b13ec636965e4b56c69be2
BLAKE2b-256 e4007db3f8c3a79973892f188623339f059b301c79fe01b3b9e48431feae3adc

See more details on using hashes here.

File details

Details for the file ghost_protocol-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: ghost_protocol-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for ghost_protocol-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04ae981e98b91f931639a4f855b8526e6feaccac2556543f4776fc94c293948e
MD5 688d120ac52173dd169b0043571e9a8b
BLAKE2b-256 e788abc9c06f989003db287aa3839b7ae6364bd32b792a50048be677aa225e53

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