This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
Haunted Terminal (ghost) is a shell integration where a ghost lives in your terminal. It watches the commands you run and occasionally whispers back in a dim, eerie voice, generated entirely by a local open-weight model.
Run rm -rf and it murmurs a warning. Fail a build at 2 AM and it knows you've been here before. The longer your session runs, the more it takes hold: a possession level (0 to 5) rises with session length, late-night hours, and failure streaks. At level 0 it's a faint unease. By level 5 it's fully possessed (still harmless and funny).
It also has a memory. Every command goes into a local SQLite file, so the ghost can say things like "you ran this last Tuesday at 2:13 AM. It didn't end well."
For the theme, I leaned into the "thin line between past and present" idea: your own command history is the ghost's haunting ground. The past literally comes back to talk to you.
And it's not just spooky. When a command fails, the whisper carries the real hint inside the spooky voice ("the file you seek has crossed over... check the path").
Code
https://github.com/amitsinha-cell/haunted-terminal.git
How I Built It
- Model: Gemma 4 E4B, served locally through Ollama on a laptop with an RTX 4050 (6 GB VRAM).
-
Shell hooks: zsh
preexec/precmdand bashDEBUGtrap +PROMPT_COMMANDcapture each command, exit code, duration, and directory. The hooks never break the shell: if anything fails, the ghost goes silent. -
Latency budget: the model call has a hard 1.5 s timeout, small context, short output, and
keep_aliveso the model stays warm in VRAM. Late whispers show on the next prompt, so the prompt is never blocked. Typical whisper latency on my GPU: [your measured number]. - Possession levels: each level swaps the system prompt and is driven by session length, time of day, and consecutive failures.
- Memory: local SQLite history; at most 3 relevant past entries go into each prompt.
-
Triggers: the ghost doesn't talk constantly. It speaks on errors,
sudo,rm -rf, force pushes, long-running commands, and returning to forgotten directories, plus a random chance scaled by level. Silence makes the whispers land harder. -
Safety: secrets (tokens, keys, passwords,
export X=...) are redacted before anything reaches the model or the database. Model output is display-only and is never executed, and control characters are stripped. - Built with: Antigravity / gemini flash 3.8, Python, SQLite.
Why Does Open Innovation Matter?
A shell history is one of the most private files on a machine. It holds server names, project names, half-typed passwords, and everything you do at 2 AM. A haunted terminal that sends that to a cloud API would be the scariest part of the project.
- Privacy: with an open-weight model, your history never leaves your laptop. There's no telemetry and no network call except to local Ollama.
- Offline: it works on a plane, in a dorm with bad Wi-Fi, or with the internet off.
- Zero cost: a ghost that comments on every failed command would be expensive per-token on a paid API. Locally it costs nothing but electricity.
- Swappable and tunable: the model is a config setting. A small model gives fast whispers and a bigger one gives a richer voice. A closed API wouldn't let me fine-tune a custom spooky-but-helpful persona, and open weights do.
- Won't vanish: nothing here depends on a service that could shut down or change its terms. The ghost will still haunt you in ten years.
Prize Categories
Gemma 4, github
Top comments (0)