DEV Community

Nischay Shukla
Nischay Shukla

Posted on

Week4 Dev Challenge

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

haunt is a ghost that lives in your shell. It reads each command you run, along with its exit code, and whispers one line of eerie commentary back, written on the spot by an open-weight model running on your own machine.
I read “Ghost in the Machine” literally. The terminal is a place where things die constantly: failed builds, killed processes, commands that never came back. So I gave it a haunting.

It comes with three spirits:

The poltergeist treats every command as an omen.
The ghost of COBOL (born 1959, still running in a bank somewhere) is baffled by your JavaScript framework.
Abuela is a gentle, teasing grandmother watching from an ofrenda. She reminds you to rest, eat, and back up your work. She’s my nod to Día de los Muertos, which begins tonight: the dead as company rather than menace.

At the end of the day, haunt eulogy writes a short, tender eulogy for every command that died in your terminal.

How I Built It

Model: an open-weight model (Llama 3.2 3B by default, swappable for Qwen, Gemma, or Phi via HAUNT_MODEL).

Inference: Ollama, running locally. haunt.py talks to its /api/generate endpoint with plain urllib, so there are no dependencies to install.

Possession: bash’s PROMPT_COMMAND or zsh’s precmd hook hands the last command and its exit code to haunt.py. The prompt sent to the model is tiny: the command, the exit code, and the directory name.

Personality: each spirit is a system prompt that insists on one sentence and no real advice. The ghost is theatre, never help. The reply is trimmed to its first line, so a chatty small model can’t flood your terminal.

Restraint: it ignores ls and cd, speaks on most failures and risky commands (rm -rf, --force, sudo, reset --hard), and otherwise appears about a third of the time. A ghost that haunts every keystroke is just a spinner.
A fallback that never breaks your shell: if the model doesn’t answer within a few seconds, the ghost uses a built-in book of canned whispers. Unreachable model, missing model, or no network, the shell never hangs on it.

I tested the pipeline against a mock Ollama server (the fallback path, the model path, the redaction, and the eulogy).

Why Does Open Innovation Matter?

A haunted terminal sees everything you type: paths, hostnames, project names, a password pasted into the wrong window, the typo you’d rather forget. With a hosted API, that stream goes to someone else’s server so a ghost can make a joke. I wouldn’t want that tradeoff, and I don’t think anyone should have to make it for a Halloween project.

Open-weight models changed the arithmetic:

Private by construction. Inference happens on localhost, so your command history never leaves your machine. As a second line of defense, haunt also redacts obvious secrets (tokens, passwords, Bearer headers, URL credentials) before the prompt is built. Redaction is best-effort pattern matching. Staying local is the real guarantee.
Works with the lights off. Turn off the Wi-Fi and the ghost still talks. That’s the demo.
Can’t be shut down. The weights sit on my disk, so no vendor can retire the endpoint, change the pricing, or rate-limit a ghost mid-haunting. It will still run years from now, a good property for a project about not letting things vanish.
Hackable all the way down. Swap the model, rewrite the spirits, or point HAUNT_HOST at any server that speaks Ollama’s API. The whole thing is short enough to read in one sitting.

A closed API could have written the whispers. It couldn’t have made them private, offline, and permanent, and for a tool that watches your terminal those properties are the point.

Prize Categories

  1. Best Use of Gemma
  2. Best Use of Entire

Top comments (0)