跳到正文
DEV Community· Shreyashi Gupta·· 3 小時前AI 評分28

HauntedShell:以詭異語氣回答開發問題的終端機工具

The Ghost in My Shell Has a Question for You.

AI 導讀

作者為 Hacktoberfest Open-Source AI Challenge 打造 HauntedShell,一款會以詭異語氣回答開發問題,並在每次回答後提出一個問題的命令列工具。

正文

Cover image for The Ghost in My Shell Has a Question for You.

Shreyashi Gupta

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

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

What I Built

HauntedShell is a command-line tool where a ghost lives in your terminal. You ask it a developer question and it answers correctly, in a spooky voice, then asks you a spooky question back so you have to think. If you only say "hey, what's up", it refuses small talk and drags you back to dev topics.

For "Ghost in the Machine" I took the theme literally: the ghost lives in the shell. It is my first CLI, and I wanted it to be fun and to teach me something real.

Demo

A real answer:

$ hauntedshell "what is a race condition"

A race condition haunts your program when multiple threads reach for shared
memory at the exact same instant. The final outcome becomes an unpredictable
phantom, bound to the non-deterministic timing of execution order. If you do
not protect the critical section with a mutex, corrupted state will haunt your
logs forever.

Have you checked if your shared variables are truly atomic, or do they whisper
corrupted values when the CPU context switches?

Small talk:

$ hauntedshell "hey what's up"

I do not do small talk, mortal. The dead have no time for pleasantries.

Tell me instead... what is the difference between a process and a thread?

With Wi-Fi turned off, the ghost covers for the failure instead of crashing:

$ hauntedshell "what is a race condition"
The old server groans and falls silent. I cannot reach the other side.

Why should a program retry a failed request only a limited number of times?

Code

HauntedShell

A haunted terminal ghost that answers your developer questions correctly, in a spooky voice, and always asks one back.

Built for Hacktoberfest 2026, Week 4: "Ghost in the Machine".

$ hauntedshell "what is npm"

It is npm, the Node Package Manager that summons thousands of JavaScript
libraries into your vendor darkness. Through its command-line interface, it
fetches remote packages from the registry and binds them to your package.json
manifest. Beware, for nested dependencies sleep silently inside node_modules,
waiting to bloat your disk.

Have you audited the phantom scripts lurking deep within your package-lock.json
before running npm install at midnight?

What it does

  • Answers developer questions in an eerie voice, and keeps the facts correct.
  • Ends every answer with a spooky question that makes you think.
  • Refuses small talk. Say "hey, what's up" and the ghost drags you back to dev topics.
  • Checks every AI reply before you see it…

How I Built It

  • Node.js with no runtime libraries. I only used what Node already has: fetch, util.parseArgs and node:test.
  • The path of one question: a bouncer (plain code, no AI) turns away small talk, then one call to the Gemini API asks for a JSON reply, then a checker inspects it, then the answer is typed out. The ghost's rules go in a separate system instruction, and the question is wrapped as data.
  • The checker verifies the shape, the length, that there is exactly one follow-up question, that no banned wording is present, and that the key technical terms survived the spooky rewrite.
  • If anything fails (no internet, a timeout, a strange reply), a pre-written ghost line covers for it. A missing or wrong API key is shown clearly instead, because only the user can fix that.
  • 36 automated tests, using a fake Gemini so they need no internet or key. The voice lines were made with the built-in Windows voice.
  • To be clear about the AI: I did not use an open-weight model. The AI is the hosted Gemini API. The --offline flag does not run a model, it prints pre-written ghost lines.
  • I built it step by step with an AI assistant (Claude) that wrote the code and explained each file. I ran every step and fixed the mistakes that came up.

Why Does Open Innovation Matter?

I should be upfront: this version runs on a closed, hosted API, and I felt the limits. It needs internet and a key, it has rate limits, and one call took about 7 seconds in my test. My laptop has 8 GB of RAM, so I did not try a local model, and I have not tested one.

What open innovation makes possible here is the next step. The project is MIT-licensed, uses only Node's own tools, and keeps the model behind a single file (model.js). Anyone can swap in an open-weight model like Gemma and turn --offline into a real offline ghost, running on their own machine with no key and no internet. That is the experiment I want to run next, and it is something a hosted API alone cannot give me.

The Spirit of It

Two moments made me smile. The first was the ghost refusing "hey what's up" with "I do not do small talk, mortal." The second was turning Wi-Fi off and getting "A cold wind blows through the wires, and your answer is lost in it." instead of an error message.

來源:DEV Community · dev.to