跳到正文
DEV Community· David Nguyen·· 4 小時前AI 評分40

Ghost Terminal AI:每條日誌都留下幽靈般的痕跡 👻

Ghost Terminal AI: Every Log Leaves a Haunting 👻

AI 導讀

Ghost Terminal AI 是一款開源應用,結合終端日誌排查與 AI 故事生成,使用 Google 的 Gemma 3 模型及 Ollama。Instant Scan 無需 AI 即可識別常見錯誤;Gemma 3 則可分析日誌、比較部署差異,並生成故事或結構化故障説明。

正文

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

What I Built

Every log leaves a trace. Every error tells a story. Sometimes, there's a ghost hiding in the machine. 👻

As developers, we spend countless hours reading terminal output, investigating failed builds, comparing deployments, and trying to understand what went wrong.

A single missing dependency, an occupied port, or an unexpected process termination can turn an otherwise ordinary deployment into a debugging mystery.

That inspired me to build Ghost Terminal AI, an open-source application that combines practical log investigation with AI-powered storytelling using Google's Gemma 3 model and Ollama.

The project started with a simple creative idea: What if our forgotten terminal logs could tell their own stories?

As I developed it, I realized those same logs could also help developers investigate real technical problems.

The result is a tool with two personalities: a practical debugging assistant and a haunted storytelling machine.

🔍 Key Features

1. Instant Scan — Error Detection Without AI

Instant Scan uses deterministic analysis to identify recognizable error patterns without requiring an AI model.

It can highlight relevant lines, recognize common failures, and suggest safe verification steps.

This is particularly useful when Ollama is offline or you want immediate feedback without waiting for model inference.

2. AI Log Analyzer — Powered by Gemma 3

Gemma 3 analyzes sanitized application logs and generates structured explanations, including:

  • A summary of the detected issue
  • Potential root causes
  • Relevant source evidence
  • Suggested troubleshooting steps

The goal is to help developers understand failures more quickly, while clearly distinguishing AI-generated hypotheses from verified facts.

3. Compare Logs — Investigate Deployment Regressions

Developers can compare logs from previous and current runs to identify meaningful differences.

The comparison engine highlights added and removed lines and can optionally ignore timestamp-only changes, making deployment regressions easier to investigate.

Gemma 3 can then help interpret what those differences might mean.

4. Built-in Testing Scenarios

Ghost Terminal AI includes synthetic testing scenarios covering common development problems, including:

  • Port conflicts
  • Missing Python modules
  • Network connection errors
  • Out-of-memory failures
  • Disk capacity problems
  • Deployment failures
  • Logs without obvious errors

These examples allow anyone to explore the application without uploading private production logs.

5. Markdown Diagnostic Reports

Analysis results can be copied or exported as Markdown reports for documentation, issue tracking, and technical discussions.

6. Ghost Story Mode — The Original Inspiration

This is where the Hacktoberfest theme comes alive.

Users can transform terminal history into original AI-generated stories using three creative modes:

  • Haunting: An eerie interpretation of forgotten terminal events
  • Remembrance: A reflective story about the people and work behind the logs
  • Mystery: A detective-style narrative exploring what might have happened

Gemma 3 generates the story dynamically instead of returning predefined responses.

For me, this feature captures the spirit of Ghost in the Machine: giving a voice to the traces our software leaves behind.

Demo

🎬 Video Demonstration

💻 Source Code

GitHub: https://github.com/hoangsvit/ghost-terminal-ai

Try It Locally

Ghost Terminal AI can run on your own computer using Python and Ollama.

Step 1 — Clone the repository

git clone https://github.com/hoangsvit/ghost-terminal-ai.git
cd ghost-terminal-ai

Step 2 — Install the Gemma 3 model

Install Ollama from https://ollama.com/download, then run:

ollama pull gemma3:1b

Step 3 — Start the application

python app.py

Step 4 — Open the application

Visit:

http://127.0.0.1:8765

Select one of the built-in scenarios and try Instant Scan, Analyze, Compare, or Story.

Instant Scan works without Ollama. AI-powered analysis and story generation require the model to be running.

Example: Finding a Ghost in a Deployment

Consider this synthetic log:

[12:00:00] Starting application...
[12:00:01] Initializing HTTP server
[12:00:02] ERROR: EADDRINUSE
[12:00:03] Process exited with code 1

The deterministic analyzer can recognize the EADDRINUSE signature and identify the relevant error line.

It can suggest investigating whether another process is already using the application's port.

Gemma 3 adds a second layer by explaining possible causes and recommending what to verify next.

Rather than simply displaying an error message, Ghost Terminal AI helps turn the log into a structured investigation.

And in Story mode, the same failed deployment can become a fictional tale of two processes competing for the same doorway.

One log. Two perspectives.

Code

The complete source code is available on GitHub:

https://github.com/hoangsvit/ghost-terminal-ai

The repository is licensed under MIT and includes documentation, automated tests, GitHub issue templates, contribution guidelines, and deployment scripts.

The project intentionally uses a lightweight stack:

Component Technology
AI Model Google Gemma 3
AI Runtime Ollama
Backend Python
Frontend HTML, CSS, JavaScript
Optional Cloud Hosting Google Cloud Compute Engine
Reverse Proxy / HTTPS Caddy
Source License MIT

There are no mandatory third-party Python packages or frontend build dependencies.

The source is designed to be easy to inspect, modify, and extend.

How I Built It

The most important architectural decision was to separate deterministic evidence extraction from AI-generated interpretation.

I didn't want the application to rely entirely on a language model for recognizing problems.

Instead, Ghost Terminal AI processes logs in several stages.

1. Input Validation and Sanitization

The Python backend validates submitted logs, normalizes their content, and applies best-effort redaction for common credential patterns.

This includes certain API keys, tokens, passwords, and authorization headers.

Input logs are treated as untrusted data rather than instructions.

An important limitation is that hosted users send their input to the server before server-side sanitization occurs. Redaction is not guaranteed to remove every secret, so confidential logs should never be uploaded to a public demo.

2. Deterministic Log Analysis

The backend searches for recognizable error signatures and extracts evidence from the original source lines.

This makes it possible to display line references independently of the language model.

For example, the application can recognize selected port conflicts, missing modules, connection errors, and infrastructure failures.

The deterministic approach also powers Instant Scan, which operates without any AI inference.

3. Gemma 3 Integration Through Ollama

For deeper analysis, Ghost Terminal AI sends the sanitized log and extracted evidence to Gemma 3 through Ollama.

The model generates structured explanations and suggested verification steps.

Ollama communicates with the Python application over a loopback HTTP endpoint.

This makes local inference possible without depending on a paid hosted AI API.

4. Evidence Grounding and Output Validation

One challenge with AI-generated explanations is that language models can produce convincing but unsupported statements.

To reduce this risk, Ghost Terminal AI separates extracted log evidence from model-generated interpretations.

The application validates structured responses and checks source references rather than blindly accepting invented quotations.

The model provides hypotheses. The original log provides evidence.

This distinction is especially important when building tools for developers.

5. Timestamp-Aware Log Comparison

I also added a comparison workflow for investigating deployment changes.

The backend compares previous and current logs and can normalize certain leading timestamps during matching.

This helps distinguish changes in log content from changes caused only by the time a message was written.

Original source lines remain available for inspection.

6. A Lightweight Web Interface

The frontend is built using HTML, CSS, and vanilla JavaScript.

It provides an atmospheric dark interface that supports both the technical analysis tools and the creative storytelling experience.

The interface includes test scenarios, model readiness indicators, result panels, report actions, and responsive layouts.

Model-generated content is rendered as text rather than executed as HTML.

7. Testing and Deployment

The repository includes automated Python and JavaScript tests covering input validation, analysis rules, HTTP handling, response validation, and other application behavior.

Model interactions are mocked during automated tests. This helps validate application logic, but does not replace testing with a real running Gemma model.

I also implemented an optional Google Cloud Compute Engine deployment workflow using:

  • Ubuntu
  • Ollama
  • Gemma 3
  • Python
  • systemd
  • Caddy HTTPS

The application can run entirely on a local computer, while the cloud deployment provides an option for hosting a demonstration.

The cloud version uses the same open-weight model, but user input is processed on the hosted VM rather than remaining on the visitor's device.

Why Does Open Innovation Matter?

For this project, open innovation is not just about making the source code available.

It's about giving developers control over how AI runs, how their data is processed, and how the application evolves.

Freedom to Run Models Locally

With Gemma 3 and Ollama, developers can run inference on their own infrastructure.

There is no need to create an account with a paid inference provider or send prompts to an external hosted AI service.

After downloading the model and dependencies, inference can run without relying on an internet connection.

Freedom to Experiment

Because the model is open-weight and the application is open source, developers can inspect prompts, change analysis logic, experiment with different supported model sizes, and extend the interface.

They can also add new error patterns or improve how evidence is extracted.

Lower Barriers to Learning

I wanted Ghost Terminal AI to remain approachable.

A developer can clone the repository, run a Python application, and explore the logic without installing a complicated framework or managing multiple cloud services.

Instant Scan also makes the application useful even without the hardware needed for model inference.

Community-Driven Improvement

The project includes GitHub Issues, pull request templates, contribution guidelines, and an MIT license for its application source.

This makes it possible for other developers to report bugs, contribute new scenarios, improve accessibility, or experiment with different approaches.

Gemma model weights and Ollama have their own licensing terms, separate from the application's MIT license.

Open innovation matters because a useful experiment shouldn't become inaccessible when an API trial expires, a service changes its pricing, or its original developer moves on.

The Spirit of It

I started this project thinking about the traces developers leave behind.

Every terminal session tells a small part of a larger story.

A failed deployment might represent hours of debugging.

A forgotten Git commit might contain an idea that never made it into production.

A process that unexpectedly stops might leave only a few lines explaining its final moments.

During Halloween and Día de los Muertos, the idea of remembering what has been lost feels especially meaningful.

Ghost Terminal AI approaches that theme from two directions.

The technical side tries to understand what happened.

The creative side imagines what those forgotten events might say if they had a voice.

In one moment, the application helps identify a port conflict.

In another, Gemma 3 turns the same terminal output into a mysterious story about a machine that refuses to let go.

That contrast became my favorite part of building this project.

Not every ghost is supernatural. Sometimes it's a forgotten process, an abandoned deployment, or a single error line waiting to be understood.

Prize Categories

Best Use of Gemma

I am submitting Ghost Terminal AI for Best Use of Gemma.

Google's open-weight Gemma 3 model is central to the application.

Through Ollama, it powers both technical log explanations and creative story generation.

The deterministic analysis engine provides grounded evidence, while Gemma 3 helps transform that evidence into understandable explanations and original narratives.

Using an open-weight model makes it possible to run the application locally, experiment with its behavior, and build without relying on a paid hosted AI API.


Built for Hacktoberfest 2026 — Ghost in the Machine. 👻

GitHub: https://github.com/hoangsvit/ghost-terminal-ai

If you're interested in open-weight AI, developer tools, log analysis, or creative experiments with Gemma, feel free to explore the repository.

Issues, suggestions, and pull requests are welcome!

Every log leaves a trace. Every trace tells a story.

來源:DEV Community · dev.to