{"slug": "phantomshell", "title": "PhantomShell", "summary": "A developer built PhantomShell, a local-first \"haunted terminal\" that pairs a FastAPI and psutil monitoring backend with a local open-weight LLM served through Ollama to explain suspicious system activity. Deterministic detection rules flag patterns such as file-change bursts and operations outside an authorized workspace, and the model is kept separate from the detection engine so it narrates only evidence-grounded findings rather than inventing incidents. Monitoring is opt-in, with demo events kept distinct from live telemetry.", "body_md": "*This is a submission for the [Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine](https://dev.to/challenges/hacktoberfest-week4-2026-10-26)*\n\nWhat if your terminal could tell you when something strange was happening inside your machine?\n\nNot through a cloud-powered chatbot. Not through fabricated security alerts. But through a local AI model that can observe selected system activity, explain suspicious patterns, and narrate the events like a ghost haunting your computer.\n\nMeet **PhantomShell** — a local-first, AI-powered haunted terminal that combines open-weight AI, system monitoring, and explainable security detection in one spooky experience.\n\nPhantomShell is my interpretation of *Ghost in the Machine*: a digital ghost that inhabits your terminal and helps you understand what your computer is doing behind the scenes.\n\nTraditional terminals show commands and output. Security monitoring tools show events and alerts. PhantomShell adds another layer: a local AI investigator that explains what happened, why an event was flagged, and what you should investigate next.\n\nImagine seeing this in your terminal:\n\n```\n╔═══════════════════════════════════════╗\n║          PHANTOMSHELL v1.0             ║\n║        THE MACHINE IS WATCHING         ║\n╚═══════════════════════════════════════╝\n\n[PHANTOM DETECTED]\n\nSomething has changed inside your workspace.\n\nObservation: Unusual file-change activity\nEvidence: Multiple file modifications detected\nRule: File Change Burst\nRisk: Medium\n\nTHE GHOST SPEAKS:\n\n\"I heard something moving in the dark.\nSeveral files changed in a short interval.\nPerhaps it was you... but perhaps you\nshould investigate.\"\n\nSuggested action: Inspect the event timeline.\n```\n\nThe spooky narration is generated by AI, but the underlying evidence and risk assessment come from the application's monitoring engine. The ghost should never invent events or claim that an ordinary anomaly proves malware is present.\n\nThe goal isn't to claim that PhantomShell can magically detect every threat. It's to make local system activity easier to understand through a memorable AI experience.\n\nThe project is designed around a modular architecture:\n\n```\nPhantomShell\n├── React + Vite frontend\n│   ├── Haunted Terminal\n│   ├── Incident Dashboard\n│   ├── Event Timeline\n│   └── AI Investigator\n│\n├── FastAPI backend\n│   ├── Event Collectors\n│   ├── Detection Engine\n│   ├── Risk Scoring\n│   ├── Incident Storage\n│   └── WebSocket Streaming\n│\n├── Local AI Layer\n│   ├── Ollama\n│   ├── Open-Weight LLM\n│   ├── Constrained Agent Harness\n│   └── Evidence-Grounded Explanations\n│\n└── SQLite\n    └── Local Event and Incident History\n```\n\nThe frontend handles visualization and interaction. The backend collects permitted events, applies detection rules, stores incident metadata, and communicates with the local model.\n\nThe AI layer is deliberately separated from the detection engine so the application can continue to function when the model is unavailable.\n\nI designed PhantomShell around three core components.\n\nThe backend uses Python, FastAPI, and `psutil` to inspect permitted process metadata. A file-system watcher observes an explicitly selected directory.\n\nEvents are normalized into a common structure before being passed to the detection engine.\n\nThe application is designed to avoid unrestricted shell access, hidden monitoring, and automatic destructive actions. Monitoring is opt-in, and demo events remain clearly separated from live telemetry.\n\nRather than asking an LLM to decide whether everything is malicious, PhantomShell uses deterministic rules to identify patterns such as unusual file-change bursts, repeated failed operations, and attempted operations outside an authorized workspace.\n\nEach finding should contain its triggering rule, supporting evidence, timestamp, and risk assessment.\n\nThis separation matters: a language model can generate a convincing explanation for an event that never happened. PhantomShell is designed to ground its narration in actual observations instead.\n\nThe planned default model is **Qwen3 1.7B**, served through **Ollama**.\n\nThe model receives structured incident information and responds in the voice of THE GHOST: mysterious, concise, and slightly unsettling.\n\nA constrained agent harness provides read-only tools for retrieving recent events, inspecting incident details, listing detection rules, and summarizing the monitored system.\n\nIt cannot independently execute arbitrary shell commands or modify files.\n\nThe rest of the stack includes:\n\nThe target is a laptop without a dedicated GPU. Actual performance will depend on available RAM, CPU, and model configuration.\n\nFor PhantomShell, open innovation isn't simply a way to reduce API costs. It changes where the intelligence runs, who controls the data, and how the application can evolve.\n\nSystem activity can reveal sensitive information about a person's work, files, applications, and habits.\n\nBy running the language model locally, PhantomShell can explain monitored events without sending its telemetry to a hosted AI provider.\n\nAfter downloading the model weights and application dependencies, the core monitoring, rule engine, event history, and local AI inference can operate without an internet connection.\n\nThat means the ghost can keep working even when the network disappears.\n\nThe AI layer is designed to be replaceable. Developers can experiment with different compatible open-weight models, compare the quality of explanations, and change the system's behavior without rebuilding the entire application around a proprietary API.\n\nThe monitoring rules are inspectable, the risk scoring is explicit, and the evidence behind each alert can be reviewed.\n\nA judge or contributor can investigate why a finding occurred instead of relying on an opaque AI-generated verdict.\n\nLocal inference removes mandatory per-request charges from a hosted LLM provider. The trade-offs are hardware requirements, model downloads, and local compute costs.\n\nOne important distinction: an open-weight model is not automatically open-source software under every definition. The specific model and dependency licenses must be checked and documented.\n\n**The central idea is simple: your machine's private activity should not need to leave your machine just to become understandable.**\n\nI'd use this section to show the coding agent helping build the detection engine, integrating Ollama, or debugging the boundary between actual telemetry and AI-generated explanations.\n\nThe most valuable session would demonstrate the engineering decisions behind the project, not just the generation of boilerplate code.\n\nThere is something unsettling about a machine that seems to know when something has changed.\n\nA new process appears. A group of files changes unexpectedly. An event triggers a rule you forgot existed.\n\nAnd then a quiet voice explains what it observed.\n\nThat is the experience I want PhantomShell to create: the feeling that the machine has a memory of its own, while keeping the explanation grounded in evidence rather than pretending that a real supernatural presence exists.\n\nThe ghost is fictional. The events it describes are not.\n\nFor me, *Ghost in the Machine* is also about the invisible complexity inside the tools we use every day. Open-source AI gives us a way to explore that complexity without surrendering control of our data or the systems we build.\n\n*Best Use of Gemma*\n\nPhantomShell is an experiment in making local AI both useful and memorable.\n\nIt combines the transparency of deterministic security rules, the flexibility of open-weight language models, and the atmosphere of a haunted terminal into an experience that can run on a personal machine.\n\nNo mandatory cloud inference. No paid LLM API dependency. No need to treat the model as an unquestionable authority.\n\nJust a machine, its evidence, and a ghost that helps you understand what happened.\n\n**Sometimes the most interesting intelligence is the kind that stays inside the machine.** 👻", "url": "https://wpnews.pro/news/phantomshell", "canonical_source": "https://dev.to/pratik_wani_4140d1f732f89/phantomshell-217g", "published_at": "2026-10-27 09:38:10+00:00", "updated_at": "2026-10-27 09:42:53.036240+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "ai-tools", "large-language-models", "ai-safety"], "entities": ["PhantomShell", "Ollama", "FastAPI", "psutil", "React", "Vite", "SQLite", "Hacktoberfest"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/phantomshell", "markdown": "https://wpnews.pro/news/phantomshell.md", "text": "https://wpnews.pro/news/phantomshell.txt", "jsonld": "https://wpnews.pro/news/phantomshell.jsonld"}}