跳到正文
DEV Community· Parth Kulkarni·· 3 小時前AI 評分41

bhoot.sh:用 Gemma 2 打造本機桌面幽靈,監視編程習慣並吐槽

bhoot.sh: I Put the Ghost of a Frustrated Indian Senior Dev on My Desktop (100% Local with Gemma 2)

AI 導讀

開發者打造 bhoot.sh,一款以 Gemma 2 為核心的本機桌面幽靈,會追蹤滑鼠、監察剪貼簿與視窗活動,並以 Hinglish 和英文吐槽編程習慣。它透過 Ollama 在本機運行 Gemma 2(2B),並以 60 FPS 顯示動畫;作者稱所有監察均在本機進行,不會把剪貼簿資料傳到雲端。

正文

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

What I Built

When I looked at the "Ghost in the Machine" prompt, I noticed almost everyone was building haunted CLI shells or digital memory altars. As an Indian developer, my mind immediately went to a different kind of horror: the evolutions of Indian ghost cinema—and the terrifying spirit of a fed-up senior developer watching you copy-paste from Stack Overflow at 2:00 AM.

Classic Indian horror evolved from melodramatic spirits in ancestral havelis (Mahal, 1949) and Ramsay Brothers folklore into modern, self-aware "Good Ghosts" (Stree, Bhoot) who haunt you with lived realities rather than cheap jump scares. Simultaneously, I was inspired by the floating interactive "Loony" lobby companion from Brawl Stars.

So I combined the two and built bhoot.sh ("Bhoot" = Ghost in Hindi/Marathi): a frameless, 60 FPS transparent desktop wraith that literally possesses your Windows OS, stalks your IDE peripheral vision, tracks your mouse cursor with glowing hollow eyes, and roasts your bad coding habits out loud in Romanized Hinglish and English.

What bhoot.sh Actually Does on Your Screen:

  • Autonomous IDE Stalker & Real-Time Eye Tracking: Unlike a passive terminal script, bhoot.sh is a live PyQt6 desktop entity whose glowing pupils calculate trigonometric vectors (math.hypot) to follow your mouse cursor across the screen in real time. Instead of blocking the code you are actively typing, it glides to targeted IDE zones:
    • Stack Overflow Copy / Terrible Git Commit: Hovers along the right-hand margin of VS Code, glaring sideways at your editor.
    • Terminal Crash / Test Failure: Glides down to hover directly over your bottom terminal panel, shaking with a crimson aura.
    • API Key Leak / Reels Distraction: Creeps right up next to your mouse cursor to confront you.
  • 3-Tier Sin Escalation (short → medium → long): Every coding sin you commit is counted. Your first mistake gets a short warning ("Ctrl C, Ctrl V. Wah, engineer."). Your second gets a medium roast ("Stack Overflow wale bhaiya ko salary de de, project toh unhone hi likha hai."). Hit the long tier (3rd+ offense) and the wraith becomes ENRAGED—triggering a full-screen, click-through blood-crimson vignette (VoidDimmer) across your entire monitor whilelocal Gemma 2 (gemma2:2b) improvises a fresh roast.
  • Poltergeist Mode (Anti-Poke Retaliation): If you get annoyed and spam-click the ghost 5 times in under 3 seconds, it retaliates. It triggers a harmless UI-only Poltergeist Override, dimming your screen blood-red, rapidly teleporting across 6 chaotic screen coordinates so you can't catch it, and flashing a fake System32 / Git branch deletion warning before laughing at you.

Demo

📸 Screenshots

  1. The Grim Wraith Stalking VS Code (Side-Margin Glare & Eye-Tracking):

The Grim Wraith Stalking VS Code

  1. Enraged Tier + Full-Screen Crimson VoidDimmer + Poltergeist Mode:

Enraged Tier + Full-Screen Crimson  raw `VoidDimmer` endraw  + Poltergeist Mode

  1. Sentry Agent Tracing Spans (ai.inference on Local Gemma 2):

Sentry Agent Tracing Spans

ai.inference

  1. MongoDB Atlas Persistent Sin Ledger (bhoot_sh.coding_sins):

MongoDB Atlas Persistent Sin Ledger


Code

GitHub logo p-rth12999 / bhoot-sh

A floating, offline desktop ghost that haunts your screen, tracks your coding sins, and roasts you in Hinglish using local Gemma 2.

👻 bhoot.sh

A reincarnated, highly judgmental senior developer haunting your desktop. Built for the Hacktoberfest 2026: Ghost in the Machine challenge, bhoot.sh is a frameless, transparent desktop wraith that monitors your clipboard and active windows 100% locally—roasting your bad coding habits in Hinglish and English.

If you copy-paste from Stack Overflow for the tenth time, accidentally copy a live API key, open Instagram Reels near a deadline, or push "fix bug" straight to main, this phantom glides across your screen, locks its glowing eyes onto your mouse cursor, dims your monitor blood-red, and yells at you.


✨ Key Features

  • Autonomous Stalker Roaming & Eye-Tracking: Glides dynamically to specific IDE zones without blocking your active typing line—hovering along the right editor margin when you copy-paste, flying down to glare at your VS Code terminal on a crash, or creeping up beside your cursor when you open distraction tabs.
  • 5-Mood…

---

How I Built It

I designed bhoot.sh around a hybrid local-first architecture so that the UI remains butter-smooth at 60 FPS while monitoring system-level events without ever freezing or leaking private clipboard data to the cloud.

+-----------------------------------------------------------------------+
|                        WINDOWS DESKTOP / IDE                          |
|  [Clipboard (pyperclip)]   [Window Titles (pygetwindow)]   [Cursor]   |
+-------------+----------------------------+--------------------+-------+
              |                            |                    |
              v                            v                    |
+-------------------------------------------------------+       |
|          src/watcher.py (Background QThread)          |       |
|  • Regex Secret Scanner (sk-*, ghp_*, mongodb+srv://) |       |
|  • Distraction Tab Detector (Reels, YouTube, X)       |       |
|  • Terminal Crash & Console.log Detector              |       |
+---------------------------+---------------------------+       |
                            |                                   |
                            v                                   |
+-------------------------------------------------------+       |
|         src/memory.py (MongoDB Atlas + Local)         |       |
|  • Logs sin category & timestamp to bhoot_sh.sins     |       |
|  • Escalates severity: 1=SHORT -> 2=MEDIUM -> 3+=LONG |       |
+---------------------------+---------------------------+       |
                            |                                   |
                            v                                   |
+-------------------------------------------------------+       |
|     src/ghost_brain.py + GemmaWorker (Async QThread)  |       |
|  • Tier 1-3: Instant lookup from scenariohindi.json   |       |
|    & scenarioenglish.json + Pre-baked ElevenLabs MP3  |       |
|  • Tier 4+: Few-Shot Prompting on Local Gemma 2 (2B)  |       |
|    via Ollama, wrapped in Sentry Agent Tracing Spans  |       |
+---------------------------+---------------------------+       |
                            |                                   |
                            v                                   v
+-----------------------------------------------------------------------+
|              src/ui_overlay.py (PyQt6 Frameless Overlay)              |
|  • 60FPS Procedural Grim Wraith + Rising Smoke Particles              |
|  • Real-Time Pupil Tracking + QPropertyAnimation Zone Roaming         |
|  • Full-Screen Click-Through VoidDimmer + Native winmm.dll Audio      |
+-----------------------------------------------------------------------+

The Stack Breakdown:

  1. Open-Weight Local Model (Gemma 2 2B via Ollama):
    Running inside an asynchronous GemmaWorker(QThread) in src/main.py, gemma2:2b powers our dynamic roast engine. Instead of generating generic AI slop, src/ghost_brain.py dynamically injects lines from our bilingual datasets (scenariohindi.json and scenarioenglish.json) as few-shot style examples into the prompt so Gemma nails the exact sarcastic Hinglish cadence ("Bas kar bhai", "Deploy karleeee", "Mera past life yaad aa gaya").

  2. System Telemetry Daemon (src/watcher.py):
    A dedicated QThread monitors clipboard changes (pyperclip), active window titles (pygetwindow), and system clock hours. It uses regex pattern matching to classify 18+ distinct developer sins—from exposed sk- / ghp_ / mongodb+srv:// keys and git push --force commands to late-night 2:00 AM coding sessions.

  3. Dual-Voice Pre-Baked Audio Engine (src/tts_baker.py + winmm.dll):
    We built a custom baker script using ElevenLabs (eleven_multilingual_v2) with two distinct personas: Daniel for thick, dramatic Hinglish delivery and Clyde for gravelly English roasts. By dropping stability to 0.25 and cranking style to 0.85 with injected pause punctuation (... and —), the voice sighs, rasps, and mocks naturally. At runtime, ui_overlay.py plays these .mp3 files directly through Windows' native Multimedia Control Interface (ctypes.windll.winmm.mciSendStringW) with dynamic alias rotation—achieving 0ms network latency and 100% offline execution.

  4. Persistent Sin Memory (MongoDB Atlas):
    src/memory.py connects to our MongoDB Atlas cluster (bhoot_sh.coding_sins) to store an immutable ledger of every coding sin, severity tier, and timestamp (with automatic offline fallback if Wi-Fi is off).

  5. Agent Observability (Sentry Agent Tracing):
    Every call to local gemma2:2b is wrapped in a sentry_sdk.start_span(op="ai.inference") transaction tagged with language, severity_tier, and model, giving us full visibility into local CPU/GPU inference latency.


Why Does Open Innovation Matter?

Building bhoot.sh exposed two massive reasons why open-weight models and local inference are non-negotiable for OS-level developer tools:

1. The Clipboard Privacy Paradox

For bhoot.sh to catch you copying code from Stack Overflow or accidentally copying a production .env secret (api_key_exposed), it has to inspect your system clipboard and active window titles every second.
If bhoot.sh were built on a closed cloud API, watching for leaked API keys would literally require sending your leaked API keys and proprietary source code over the internet to a third-party server! That turns a fun developer companion into a massive security vulnerability. Because gemma2:2b runs 100% locally via Ollama on my own laptop, my clipboard never leaves localhost. You can turn off your Wi-Fi completely, and the ghost still haunts your machine.

2. Escaping the Cloud Quota & Safety-Filter Wall (Architectural Lesson & Future Scope)

First, closed commercial LLMs often neuter "roast" or "horror" personas with overly sanitized corporate refusals. Open-weight gemma2:2b let us use few-shot Hinglish prompting to capture raw, authentic Indian developer banter without censorship.

Second, during development, we hit a classic closed-API bottleneck with voice synthesis: a desktop agent that reacts to every clipboard event triggers dozens of times an hour. Calling a cloud TTS API dynamically on every error introduces 2+ seconds of lag and burns through free-tier character quotas (and paywalled voice libraries) in a single afternoon.
While our hybrid solution (tts_baker.py pre-baking core ElevenLabs MP3s + live Gemma 2 text) solved this for v1.0, it proved why our immediate v2.0 roadmap is integrating a 100% open-weight local neural TTS (Kokoro-82M / Parler-TTS) alongside Ollama—allowing every unscripted Gemma 2 roast to be voiced locally on-device with zero API limits forever.


My Agent Session


The Spirit of It

The moment bhoot.sh truly landed for me was at 2:00 AM while debugging ui_overlay.py.

Initially, when I triggered a live Gemma 2 roast, the synchronous inference call blocked the main thread and froze the ghost's animation—making it feel like a buggy script. After moving Gemma 2 into a background QThread and replacing our early cartoon balloon prototype with the hooded dark wraith, I accidentally copied a stack trace three times in a row while testing.

Suddenly, my entire monitor flashed blood-crimson (VoidDimmer), the hooded wraith glided straight down over my VS Code terminal with its red pupils locked onto my cursor, and the speakers rasped out in Hindi:

"Deploy karleeee, bol raha tha na? Ab rollback kar, aur apni izzat bhi saath mein rollback kar le."

Then I spam-clicked it in frustration, accidentally triggering Poltergeist Mode, and watched it violently glitch and teleport across my screen yelling about System32. It crossed the line from "a Python script I'm writing" to "an annoying, hilarious roommate living inside my laptop."


Prize Categories

  • Best Use of Gemma: Uses local gemma2:2b via Ollama inside an asynchronous QThread with bilingual few-shot prompting (scenariohindi.json & scenarioenglish.json) to improvise context-aware developer roasts.
  • Best Use of ElevenLabs: Uses eleven_multilingual_v2 with custom low-stability/high-style emotional voice settings across dual personas (Daniel for Hinglish, Clyde for English) via src/tts_baker.py to voice the desktop ghost.
  • Best Use of MongoDB Atlas: Uses pymongo in src/memory.py to persist developer coding sins, timestamps, and escalation tiers (short / medium / long) to a cloud bhoot_sh.coding_sins collection.
  • Best Use of Sentry Agent Tracing: Instruments local gemma2:2b inference calls in src/ghost_brain.py with sentry_sdk.start_span(op="ai.inference") to track latency and metadata across languages and escalation tiers.

來源:DEV Community · dev.to