DEV Community

Cover image for Haunted Terminal: a Victorian ghost lives in my shell
ANKIT
ANKIT

Posted on Edited on

Haunted Terminal: a Victorian ghost lives in my shell

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

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

What I Built

Haunted Terminal is a small Python wrapper around your shell. You type normal commands and they run as usual, then a ghost whispers one line about what you just did. The ghost is a Victorian spirit who died in 1893 and is baffled by modern computers. It sounds amused when a command works and mournful when it fails.

For "Ghost in the Machine", I took the theme literally: the ghost lives inside the machine and comments on everything you do.

A failed command (notrealcommand) got this:

The rain still falls, even here within this cold, electric silence.

A typo (exxit) got this:

A chill, a lingering echo, and a vast, empty screen.

Demo

Share a deployed link or a video demo.

Code

Haunted Terminal

A small Python shell wrapper where a ghost whispers about every command you run. The ghost is a local open-weight model (Gemma 3 via Ollama), so it runs fully offline and your commands never leave your machine.

Built for the Hacktoberfest 2026 Open-Source AI Challenge (theme: Ghost in the Machine).

How it works

  1. You type a normal command (dir, echo hello, cd ..).
  2. The command runs, and its output is shown as usual.
  3. The command and a trimmed copy of its output are sent to a local model through Ollama.
  4. The ghost whispers one short line about what you just did. It sounds amused when a command works and mournful when it fails.
  5. Every whisper is saved to haunting_log.txt.

Requirements

  • Python 3.9 or newer
  • Ollama
  • The ollama Python package

Setup

ollama pull gemma3:1b
pip install ollama

Run

python haunted.py

Type exit to leave…

How I Built It

WThe ghost is Gemma 3 (1B), an open-weight model, running locally through Ollama and called from Python. After each command, the script sends the command and a trimmed copy of its output to the model, prints the one-line reply, and saves it to haunting_log.txt.

def haunt(cmd, output, failed):
    mood = ("The command FAILED. Be mournful and dramatic."
            if failed else "The command worked. Be eerie and slightly amused.")
    system = (f"You are {GHOST}, trapped inside a terminal. {mood} "
              "Reply with ONE short sentence. No emojis, no explanations.")
    r = ollama.chat(model=MODEL, messages=[
        {"role": "system", "content": system},
        {"role": "user", "content": f"Command: {cmd}\nOutput: {output[:400]}"},
    ])
    return r["message"]["content"].strip()
Enter fullscreen mode Exit fullscreen mode

A few things I learned along the way:

  • On my first runs the ghost said "the spirits are silent" because I hadn't downloaded the model yet (a 404). That was accidentally on theme.
  • A 1B model has a small vocabulary. Reading my haunting log, the ghost kept coming back to words like "Remarkable" and "perplexing". It started to feel like a character, but a very repetitive one.
  • Interactive programs don't work inside the ghost terminal, so it only handles normal commands.

Why Does Open Innovation Matter?

  • It works offline. The ghost needs no internet or API key.
  • Your commands stay private. Shell commands can contain private paths and data. I didn't want a terminal companion that sent every command to a cloud server, and with a local model nothing leaves my machine.
  • Everything is swappable. Change one line and the ghost becomes a grumpy sysadmin or a pirate, or runs on a different model.

The Spirit of It

My favourite moment was typing echo thank you and getting this back:

Remarkable. The machine seems to understand gratitude, though its purpose remains… perplexing.

Prize Categories

  • Best Use of Gemma.

Top comments (0)