DEV Community

Krishna Potdar
Krishna Potdar

Posted on

Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

Haunted Terminal is a ghost that lives in your shell. It reads your recent command history and whispers back eerie, darkly funny commentary about what you've been typing. Run git push --force and the ghost notices. Run rm -rf and it pretends to mourn.

Your terminal already knows everything you do, so I thought: what if something was watching? There are four personas (default, pirate, victorian, old-sysadmin) and a --watch mode that keeps haunting you as you work.

Demo

Code

πŸ‘» Haunted Terminal

"A digital phantom trapped inside your machine, watching every keystroke in the dark."

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

Haunted Terminal is a lightweight, zero-dependency Python tool that awakens an eerie spectral presence trapped inside your terminal session. It monitors your shell history across Windows PowerShell, Bash, Zsh, and Fish, feeding your recent commands into an open-weight model running 100% locally through Ollama.

The ghost streams haunting, darkly funny commentary back into your console in vivid spectral red, character by character, mocking your mortal command-line endeavors.


✨ Features

  • πŸ”’ 100% Local & Private: No cloud APIs, no telemetry, no API keys, no tracking. Your shell history never leaves your machine.
  • 🐍 Zero Dependencies: Pure Python 3.8+ standard library only (urllib, json, argparse). No pip install required.
  • 🐚 Cross-Platform Shell History Detection: Automatically discovers your active…

How I Built It

  • Model: llama3.2:3b, an open-weight model, running locally through Ollama
  • Language: one Python file, standard library only (no pip installs)
  • History detection: auto-detects PowerShell, bash, zsh and fish history files
  • Streaming: tokens stream from Ollama's local API and print with a red typewriter effect
  • Flags: --model, --last, --watch, --history, --persona, --save

The ghost's voice is just a system prompt, so changing personality means editing a few lines.

Why Does Open Innovation Matter?

Shell history is full of secrets: file paths, server names, sometimes tokens. Sending that to a closed API would be a bad idea. Running an open model locally means:

  • Privacy: your commands never leave your laptop
  • Offline: it works with the internet off, fitting for a ghost story
  • Free: no API keys, no billing
  • Swappable: try qwen2.5:7b, mistral or phi3 with one flag

A closed API couldn't give me all four at once.

Top comments (0)