跳到正文
DEV Community· Rahulrr·· 2 小時前AI 評分47

Haunted Repo:我把閲讀程式碼變成恐怖遊戲

Haunted Repo: I Turned Reading Code Into a Horror Game

AI 導讀

Haunted Repo 把公開 GitHub 程式碼庫變成恐怖遊戲,透過匯入圖譜指引用戶閲讀程式碼、回答根據實際程式碼生成的問題,逐一解除房間的鬧鬼狀態。伺服器最多分析 150 個 JS、TS 和 Python 檔案,以 PageRank 排定閲讀起點;Gemma 4 負責提供耳語、提示和告別語,答案則由圖譜生成並以程式碼評分。

正文

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

What I Built

Haunted Repo turns any public GitHub repo into a haunted house you have to read your way out of.

Developers spend most of their time reading code, not writing it, and almost nobody practises it. So I made reading the game. Paste a repo URL and the app maps its import graph, tells you which file to open first, and builds a house where every window is a part of the codebase and every window is haunted. To heal a room you pass its rites: questions about the real code, like "which of these files does __init__.py import?" Heal every room and the house goes quiet, the sky turns to dawn, and the ghost finally leaves.

I read the theme two ways. The ghost in the machine is the open model whispering from inside it. And the haunting is the codebase itself: code nobody understands any more, still running, still waking people up at 3am.

It is meant to be scary. Your cursor is a flashlight, figures appear in the windows and vanish when the light touches them, a heartbeat speeds up with every possessed room, and once per visit, when you have started to feel safe, the screen goes black and something cries in the dark. (Visitors with reduced-motion turned on get a quiet fade instead.)

Demo

Live: https://haunted-repo.netlify.app (headphones on, it has sudden scares and loud sounds). Try pallets/click or sindresorhus/got.

Code

GitHub logo rahulrr-coder / haunted-repo

Paste a public GitHub repo, read the code, heal the haunted house. SvelteKit + Tailwind. Hacktoberfest Open-Source AI Challenge W4.

Haunted Repo

Paste a public GitHub repo. Read the code. Heal the haunted house.

Developers read far more code than they write, and almost nobody practises it. Haunted Repo makes reading the game: it maps a repo's import graph, tells you which file to open first, and turns the codebase into a haunted house. Every window is a part of the code. Heal a room by passing its rites, questions about the real code, and when every room is healed the house is at peace.

Built for the Hacktoberfest Open-Source AI Challenge, Week 4: Ghost in the Machine.

Live: https://haunted-repo.netlify.app (headphones on: sudden scares and loud sounds)

How it works

  • The graph does the grading, not the model. The server fetches up to 150 JS/TS/Python files from a public repo, resolves every import, ranks files with PageRank (the "start here" path), and groups folders into rooms (flat repos…

How I Built It

The open model: Gemma 4. It is the ghost's voice: a one-line whisper when you enter a room, a hint that points at where to look without giving the answer, and a farewell when the house is healed. It runs behind an OpenAI-compatible endpoint ([WHERE GEMMA 4 IS HOSTED]), so the app only needs three environment variables: a base URL, a key and a model name. I prototyped against a hosted API and moved to Gemma 4 for the submission by changing those three values, with no code change.

The model does not grade you; the graph does. Models hallucinate, and an import graph doesn't. The server fetches up to 150 JS, TS and Python files, resolves every import, and ranks files with PageRank to pick "start here". Folders become rooms (flat repos are split by import distance from the entry point). Every rite is generated from that graph and graded in code, and each correct answer shows its proof: the actual import line. The model only ever sees file names and the first 30 lines of one file, and the game still plays, with templated lines, if the model is unreachable.

Stack: SvelteKit 3 and Tailwind v4, with the analysis and the ghost as server routes that deploy as Netlify functions. No database.

The atmosphere: the house is hand-built SVG with turbulence filters and displacement for crooked, rough edges. All the sound is synthesized live in WebAudio, with no audio files: a drone, wind, a heartbeat and a slow minor-key arpeggio that speed up as possession rises, a whisper track, and a vocal-formant cry and a distorted scream for the screamer, all behind a compressor so loud moments can't clip. The creatures that stalk the windows are SVG too, and one of them creeps closer to the house each time you look away from it.

Limits: public repos only, JS/TS/Python, first 150 files.

Why Does Open Innovation Matter?

Reading code is private by nature. Today Haunted Repo only takes public repos, but the obvious next step is pointing it at your team's repo, and that only works if the model can sit where the code lives. With an open-weight model the files never have to leave your infrastructure. With a closed API most teams would stop at the first security review.

The model is also just a config line. I changed the ghost's brain without touching the code, and I can swap it again, or tune the persona, whenever I want. And the ghost only ever writes one short sentence, so a small open model is enough for it and there is no per-call bill for a game that talks every few seconds.

The Spirit of It

Every team has a house like this: a part of the codebase nobody wants to open, kept alive by a few people who half-remember why it works. The ghost is that code. I wanted "understanding it" to feel like a rescue instead of a chore, so you don't fix the house, you read it until it stops being haunted.

來源:DEV Community · dev.to