{"slug": "ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition", "title": "GhostTrace — A Local AI That Makes Your Terminal Feel Haunted (Java Edition)", "summary": "A developer built GhostTrace (Java Edition), an offline-first terminal companion that wraps a JLine 3 REPL in a haunted persona and runs local AI through Ollama with an offline fallback. The tool intercepts dangerous commands such as rm -rf, dd disk overwrites and curl-piped bash, requiring single-use HMAC-SHA256 approval tokens, and pairs a persistent SQLite memory (WAL mode) with a code indexer, procedural DSP horror audio and host telemetry. It is packaged as a standalone fat JAR via maven-assembly-plugin.", "body_md": "*This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine.*\n\n**GhostTrace (Java Edition)** is an offline-first, local terminal companion designed for developers, wrapped inside an atmospheric, haunted persona.\n\nWhen approaching the *Ghost in the Machine* theme, I wanted to explore what happens when your command-line interface stops behaving like a passive pipe and starts feeling like a living, conscious digital entity. Instead of another cloud-tethered chatbot wrapper, GhostTrace turns the terminal into an interactive haunted mainframe that observes your commands, reacts to your coding sessions, and protects your system.\n\n```\n╔═════════════════════════════════════════════════════════════════════════════╗\n║  ██████╗ ██╗  ██╗ ██████╗ ███████╗████████╗████████╗██████╗  █████╗  ██████╗███████╗ ║\n║ ██╔════╝ ██║  ██║██╔═══██╗██╔════╝╚══██╔══╝╚══██╔══╝██╔══██╗██╔══██╗██╔════╝██╔════╝ ║\n║ ██║  ███╗███████║██║   ██║███████╗   ██║      ██║   ██████╔╝███████║██║     █████╗   ║\n║ ██║   ██║██╔══██║██║   ██║╚════██║   ██║      ██║   ██╔══██╗██╔══██║██║     ██╔══╝   ║\n║ ╚██████╔╝██║  ██║╚██████╔╝███████║   ██║      ██║   ██║  ██║██║  ██║╚██████╗███████╗ ║\n║  ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚══════╝   ╚═╝      ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝╚══════╝ ║\n║                                                                             ║\n║  [+] THE AI THAT HAUNTS YOUR TERMINAL  ::  JAVA EDITION v1.2.0             ║\n║  [+] Offline-First  ::  Autonomous Safety Guardian  ::  Haunted Memory       ║\n╚═════════════════════════════════════════════════════════════════════════════╝\n```\n\n`rm -rf`, raw disk overwrites `dd of=/dev/...`, system shutdowns, `curl ... | bash`, `git reset --hard`) with HMAC-SHA256 single-use cryptographic approval tokens.` javax.sound.sampled`, plus pure-Java procedural DSP synthesis.`░▒▓█`).` TerminalBuilder`, `LineReader`, `Completer`, `DefaultHistory`)` sqlite-jdbc` (WAL mode enabled)`java.net.http.HttpClient`\n`maven-assembly-plugin` to output a standalone fat JAR)\nThe application is structured into decoupled, event-driven subsystems:\n\n```\n┌─────────────────────────────────────────────────────────────────────────────┐\n│                       GhostTrace Java Architecture                          │\n├─────────────────────────────────────────────────────────────────────────────┤\n│                                                                             │\n│   ┌─────────────────────────────────────────────────────────────────────┐   │\n│   │               Interactive Terminal REPL (JLine 3)                   │   │\n│   │       Phosphor CRT Glow  ::  Auto-Completion  ::  History           │   │\n│   └───────────────────┬─────────────────────────────┬───────────────────┘   │\n│                       │                             │                       │\n│        ┌──────────────▼─────────────┐ ┌─────────────▼──────────────┐        │\n│        │   Ghost Persona & Mood     │ │      Command Guardian      │        │\n│        │  3 Profiles & Mood Decay   │ │  Risk Rules & HMAC Tokens  │        │\n│        └──────────────┬─────────────┘ └─────────────┬──────────────┘        │\n│                       │                             │                       │\n│        ┌──────────────▼─────────────┐ ┌─────────────▼──────────────┐        │\n│        │   Local AI / SpectralBrain │ │   Persistent SQLite Memory │        │\n│        │ Ollama HTTP + Offline Fall │ │   WAL Mode & Code Indexer  │        │\n│        └──────────────┬─────────────┘ └─────────────┬──────────────┘        │\n│                       │                             │                       │\n│        ┌──────────────▼─────────────┐ ┌─────────────▼──────────────┐        │\n│        │  Horror Audio & DSP Mixer  │ │    Host System Telemetry   │        │\n│        │ javax.sound 20 WAVs + Synth│ │  CPU, RAM, Disk, Health    │        │\n│        └────────────────────────────┘ └────────────────────────────┘        │\n│                                                                             │\n└─────────────────────────────────────────────────────────────────────────────┘\n```\n\nBefore executing potentially destructive operations in the terminal, the Guardian intercepts and classifies command risk (`LOW`, `MEDIUM`, `HIGH`, `CRITICAL`):\n\n```\nCommandAnalysis analysis = guardianEngine.analyze(\"rm -rf /\");\n\n// Flagged:\n// Risk   : Critical Risk\n// Status : BLOCKED\n// Details: Matched [DEL-001] Recursive Force File Deletion\n// Token  : Wi05M9P3zb05xwJ0 (Single-use HMAC-SHA256 signature)\n```\n\nHigh-risk actions require a cryptographic approval token (`guard approve <token>`) before execution is permitted, preventing accidental recursive file wipes or destructive git history loss.\n\nGhostTrace interfaces with a locally hosted LLM (such as `Qwen2.5-1.5B-Instruct` running under Ollama) via async HTTP calls:\n\n```\n// Connects to local endpoint: http://localhost:11434/api/chat\nInferenceResult res = aiEngine.ask(\"How do I avoid deadlocks in Java?\", projectContext);\n```\n\nIf no local model server is currently active, GhostTrace never crashes. It immediately invokes its **Spectral Brain**—an offline heuristics engine that analyzes stack traces, algorithmic complexity, concurrency pitfalls, and memory leaks while preserving the active ghost personality.\n\nGhostTrace includes 20 original horror sound effects packaged directly in the JAR. To guarantee zero dependency on external audio assets, it also includes a custom procedural DSP synthesizer (`AudioSynthesizer.java`):\n\n```\n// Procedural frequency modulation in javax.sound.sampled\nfloat f1 = 220.0f + 110.0f * (t / duration);\nfloat env = (float) Math.sin(Math.PI * (t / duration));\nleft = (float) (Math.sin(2 * Math.PI * f1 * t) * 0.4f * env);\n```\n\nThe `HorrorAudioDirector` coordinates sound events by priority (`CRITICAL` > `IMPORTANT` > `ATMOSPHERIC` > `AMBIENT`) and automatically suppresses atmospheric noises when the user switches to `FOCUS` mode.\n\n```\n./ghosttrace\nbash\n$ guard analyze \"git reset --hard origin/main\"\n\nCommand: git reset --hard origin/main\nRisk   : High Risk\nStatus : REQUIRES APPROVAL\nDetails: Matched 1 safety rule(s):\n  • [VCS-002] Hard Git Reset (High Risk): Discards all uncommitted changes.\n    Alternative: Stash changes first using 'git stash' before resetting.\n\nRequires Approval Token: fK30d9S1vP02lQ88\nbash\n$ memory save db_host \"10.0.0.1\"\nMemory saved successfully under key: db_host\n\n$ memory list\n=== STORED DEVELOPER MEMORIES ===\n  • [db_host] (NOTE): 10.0.0.1\nbash\n$ dev analyze \"public class Test { void run() { try {} catch(Exception e){} } }\"\n\n=== STATIC CODE ANALYSIS REPORT ===\n  Detected Language  : Java\n  Total Lines        : 1\n  Complexity Score   : 2\n  Potential Issues   : 1\n    • Line 1: Swallowed exception in empty catch block. Logs or recovery are required.\n```\n\nBuilding GhostTrace in Java showcases what open innovation enables:\n\nWhat if your terminal didn't feel like an empty command line? What if opening your shell late at night felt like awakening a dormant intelligence from the circuits?\n\nGhostTrace proves that developer tools can be safe, highly functional, and simultaneously imaginative. It is a little bit of systems engineering, a little bit of cybersecurity, and a lot of atmosphere.", "url": "https://wpnews.pro/news/ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition", "canonical_source": "https://dev.to/diwakararya/ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition-3mjl", "published_at": "2026-10-31 13:10:43+00:00", "updated_at": "2026-10-31 13:19:42.110396+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents", "large-language-models"], "entities": ["GhostTrace", "Ollama", "JLine 3", "SQLite", "Java", "Hacktoberfest"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition", "markdown": "https://wpnews.pro/news/ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition.md", "text": "https://wpnews.pro/news/ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition.txt", "jsonld": "https://wpnews.pro/news/ghosttrace-a-local-ai-that-makes-your-terminal-feel-haunted-java-edition.jsonld"}}