DEV Community

Cover image for The Haunting Protocol: An Open-Source AI Ghost That Lives in Your Codebase
Yogesh
Yogesh

Posted on

The Haunting Protocol: An Open-Source AI Ghost That Lives in Your Codebase

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

Meet The Haunting Protocol — a local AI-powered desktop companion that behaves like a ghost haunting your development environment.

It watches your project directory, notices when files appear or disappear, discovers unfinished TODOs, and responds with eerie commentary. But this isn't just a horror chatbot. The ghost has a persistent memory, allowing it to remember previous events and make each new session feel like another chapter in an unfolding mystery.

Imagine deleting an old file and hearing:

"You deleted the file. Why do I still remember it?"
Or returning to your project the next morning and discovering that the ghost remembers what happened before you left.

Code

How I Built It

The central design decision was to make the open-weight model part of the actual experience, rather than simply adding an AI-generated story to a Halloween-themed interface.

The AI stack
Qwen 2.5 3B via Ollama

I chose a relatively small open-weight language model so the ghost could generate contextual responses on a local machine. Ollama provides a straightforward local inference interface, making it easy to send the ghost's observations to the model without integrating a remote API.

Python and Watchdog

The file watcher detects events in a user-selected directory. Instead of continuously sending project files to an AI, the application focuses on metadata such as event types, relative paths, and selected TODO line numbers.

SQLite for persistent memory

The application stores events, session information, and generated ghost messages in SQLite. On a new session, it retrieves recent events and memories and includes them in the next model prompt.

A custom personality and event engine

The system prompt defines the ghost's behavior: short, unsettling messages, a mysterious personality, and a tendency to treat deleted files as lost memories and TODOs as unfinished promises.

The result is a small local AI agent with a distinct purpose: transforming development activity into an evolving horror narrative.

Why Does Open Innovation Matter?

  1. A ghost that stays on your machine A development environment can contain private source code, unfinished ideas, credentials, and proprietary information. I wanted the experience to work without sending project observations to a third-party AI service.

With a locally running model, the application can keep its inference on the same machine. The current prototype sends selected event metadata rather than file contents to the model.

  1. Freedom to experiment The ghost's personality is defined by a prompt and a small amount of Python code. I can make it poetic, cryptic, sarcastic, or genuinely unsettling without depending on a hosted model's particular behavior.

I can also experiment with different compatible open-weight models and compare how they handle the same events.

  1. Offline by design
    Once Ollama and the model have been installed, the core experience can run without an internet connection. The application does not need a cloud inference API for each message.

  2. No per-request API bill
    Local inference avoids per-request charges from a hosted AI provider, although it still uses hardware, electricity, and disk space.

The Spirit of It

There is something inherently spooky about a computer remembering what you thought was gone.

Developers delete files, abandon experiments, leave TODOs behind, and return to projects months later. Most of the time, these are ordinary traces of work. But viewed through the right lens, they start to resemble the remnants of something that once lived there.

The Haunting Protocol takes those traces and gives them a voice.

It doesn't need to pretend that a supernatural entity is actually inside the machine. The illusion comes from something much more familiar: memory, context, and an AI that knows enough about what happened before to make its next words feel strangely personal.

And because the model runs locally, the ghost doesn't have to leave your machine to tell its story.

Maybe the most unsettling line of code isn't the one you wrote.

Maybe it's the one you deleted.

Prize Categories

🟣 Best Use of Render - powers the deployed backend and API.

Top comments (0)