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.2.0.tar.gz (18.7 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.2.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ghost_protocol-1.2.0.tar.gz
  • Upload date:
  • Size: 18.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 5748660363e1f28a46d8952ec0dc32119c119be8eeeb62d257201ad913b509d7
MD5 856c7cecc3d3bb9932fa92f77acc5811
BLAKE2b-256 f67f2f561dd59917fc66f661ebadc0972d319f0a6800402de916a0e94b21abcf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ghost_protocol-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57f29bc1196a98ff482cbe0b4174068791e74ee4b8b697672035fa58586de8ab
MD5 488fe88840661ed688026ac7eefeffa8
BLAKE2b-256 c8adc559621ec0e7edb1cced7d80904e043f8045eb31e295d3b6ab2d3240a698

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