cd /news/ai-tools/ghosttrace-a-local-ai-that-makes-you… · home › topics › ai-tools › article
[ARTICLE · art-161523] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

GhostTrace — A Local AI That Makes Your Terminal Feel Haunted (Java Edition)

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.

by read4 min views1 publishedOct 31, 2026

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

GhostTrace (Java Edition) is an offline-first, local terminal companion designed for developers, wrapped inside an atmospheric, haunted persona.

When 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.

╔═════════════════════════════════════════════════════════════════════════════╗
║  ██████╗ ██╗  ██╗ ██████╗ ███████╗████████╗████████╗██████╗  █████╗  ██████╗███████╗ ║
║ ██╔════╝ ██║  ██║██╔═══██╗██╔════╝╚══██╔══╝╚══██╔══╝██╔══██╗██╔══██╗██╔════╝██╔════╝ ║
║ ██║  ███╗███████║██║   ██║███████╗   ██║      ██║   ██████╔╝███████║██║     █████╗   ║
║ ██║   ██║██╔══██║██║   ██║╚════██║   ██║      ██║   ██╔══██╗██╔══██║██║     ██╔══╝   ║
║ ╚██████╔╝██║  ██║╚██████╔╝███████║   ██║      ██║   ██║  ██║██║  ██║╚██████╗███████╗ ║
║  ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚══════╝   ╚═╝      ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝╚══════╝ ║
║                                                                             ║
║  [+] THE AI THAT HAUNTS YOUR TERMINAL  ::  JAVA EDITION v1.2.0             ║
║  [+] Offline-First  ::  Autonomous Safety Guardian  ::  Haunted Memory       ║
╚═════════════════════════════════════════════════════════════════════════════╝

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 maven-assembly-plugin to output a standalone fat JAR) The application is structured into decoupled, event-driven subsystems:

┌─────────────────────────────────────────────────────────────────────────────┐
│                       GhostTrace Java Architecture                          │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │               Interactive Terminal REPL (JLine 3)                   │   │
│   │       Phosphor CRT Glow  ::  Auto-Completion  ::  History           │   │
│   └───────────────────┬─────────────────────────────┬───────────────────┘   │
│                       │                             │                       │
│        ┌──────────────▼─────────────┐ ┌─────────────▼──────────────┐        │
│        │   Ghost Persona & Mood     │ │      Command Guardian      │        │
│        │  3 Profiles & Mood Decay   │ │  Risk Rules & HMAC Tokens  │        │
│        └──────────────┬─────────────┘ └─────────────┬──────────────┘        │
│                       │                             │                       │
│        ┌──────────────▼─────────────┐ ┌─────────────▼──────────────┐        │
│        │   Local AI / SpectralBrain │ │   Persistent SQLite Memory │        │
│        │ Ollama HTTP + Offline Fall │ │   WAL Mode & Code Indexer  │        │
│        └──────────────┬─────────────┘ └─────────────┬──────────────┘        │
│                       │                             │                       │
│        ┌──────────────▼─────────────┐ ┌─────────────▼──────────────┐        │
│        │  Horror Audio & DSP Mixer  │ │    Host System Telemetry   │        │
│        │ javax.sound 20 WAVs + Synth│ │  CPU, RAM, Disk, Health    │        │
│        └────────────────────────────┘ └────────────────────────────┘        │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Before executing potentially destructive operations in the terminal, the Guardian intercepts and classifies command risk (LOW, MEDIUM, HIGH, CRITICAL):

CommandAnalysis analysis = guardianEngine.analyze("rm -rf /");

// Flagged:
// Risk   : Critical Risk
// Status : BLOCKED
// Details: Matched [DEL-001] Recursive Force File Deletion
// Token  : Wi05M9P3zb05xwJ0 (Single-use HMAC-SHA256 signature)

High-risk actions require a cryptographic approval token (guard approve <token>) before execution is permitted, preventing accidental recursive file wipes or destructive git history loss.

GhostTrace interfaces with a locally hosted LLM (such as Qwen2.5-1.5B-Instruct running under Ollama) via async HTTP calls:

// Connects to local endpoint: http://localhost:11434/api/chat
InferenceResult res = aiEngine.ask("How do I avoid deadlocks in Java?", projectContext);

If 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.

GhostTrace 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):

// Procedural frequency modulation in javax.sound.sampled
float f1 = 220.0f + 110.0f * (t / duration);
float env = (float) Math.sin(Math.PI * (t / duration));
left = (float) (Math.sin(2 * Math.PI * f1 * t) * 0.4f * env);

The HorrorAudioDirector coordinates sound events by priority (CRITICAL > IMPORTANT > ATMOSPHERIC > AMBIENT) and automatically suppresses atmospheric noises when the user switches to FOCUS mode.

./ghosttrace
bash
$ guard analyze "git reset --hard origin/main"

Command: git reset --hard origin/main
Risk   : High Risk
Status : REQUIRES APPROVAL
Details: Matched 1 safety rule(s):
  • [VCS-002] Hard Git Reset (High Risk): Discards all uncommitted changes.
    Alternative: Stash changes first using 'git stash' before resetting.

Requires Approval Token: fK30d9S1vP02lQ88
bash
$ memory save db_host "10.0.0.1"
Memory saved successfully under key: db_host

$ memory list
=== STORED DEVELOPER MEMORIES ===
  • [db_host] (NOTE): 10.0.0.1
bash
$ dev analyze "public class Test { void run() { try {} catch(Exception e){} } }"

=== STATIC CODE ANALYSIS REPORT ===
  Detected Language  : Java
  Total Lines        : 1
  Complexity Score   : 2
  Potential Issues   : 1
    • Line 1: Swallowed exception in empty catch block. Logs or recovery are required.

Building GhostTrace in Java showcases what open innovation enables:

What 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?

GhostTrace 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.

── more in #ai-tools 4 stories · sorted by recency
── more on @ghosttrace 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/ghosttrace-a-local-a…] indexed:0 read:4min 2026-10-31 · —