DEV Community

Mahasvan Mohan
Mahasvan Mohan

Posted on

Hacktoberfest Week 4 - Excavate deleted files

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

What I Built

Every long-lived repository has a graveyard hidden inside .git/objects: thousands of lines of deleted functions, retired modules, and hard-won edge-case fixes that were swept away during a "clean v2 rewrite"—often taking the institutional memory of why they existed with them.

git-seance is a zero-dependency, single-file Python CLI that bridges both halves of the Ghost in the Machine theme:

  1. The Spooky Git Séance (Halloween): Excavates deleted files and major code removals from Git history (git log --diff-filter=D and historical diffs) and channels them through a local open-weight LLM (llama3.2, qwen2.5-coder, or deepseek-r1 via Ollama / llama.cpp). The deleted code speaks from beyond the grave in first person—grounded in its actual deleted source code, commit epitaph, creation history, and deletion date—so you can ask it why it was written and what production bug is about to happen now that it's gone.
  2. The Code Ofrenda (--ofrenda, Día de los Muertos): Renders a marigold-and-candlelight terminal Ofrenda de Código that honors departed modules and the original contributors who crafted them, complete with an AI-generated remembrance blessing.

Demo

Run git-seance immediately on any machine with Python 3 and Git (includes a built-in --haunt-demo mode that conjures a temporary haunted repository so you can test it in one command):

# 1. Build a Día de los Muertos Code Ofrenda
python3 git_seance.py --haunt-demo --ofrenda

# 2. Hold an interactive séance with Spirit #2 (legacy_rate_shield.py)
python3 git_seance.py --haunt-demo --spirit 2

# 3. Ask a deleted module a single question from the command line
python3 git_seance.py --haunt-demo --spirit 2 --ask "Why do our workers crash every midnight after you were deleted?"
Enter fullscreen mode Exit fullscreen mode

Sample Terminal Output (--haunt-demo --ofrenda)

  ✿ 🕯️  ═══════════════════════════════════════════════════════════ 🕯️  ✿
         OFRENDA DE CÓDIGO — HONORING THE CODE THAT CAME BEFORE
  ✿ 🕯️  ═══════════════════════════════════════════════════════════ 🕯️  ✿

  ✿ Marigolds laid for 2 departed modules (20 lines of ancestral logic)
  🕯️ Ancestral builders honored: Elena Vance, Mateo Cruz

  ┌─ 🕯️  Spirit #1: zombie_reaper.py (commit 71d038d)
  │  Crafted by : Mateo Cruz  |  Departed: 2025-11-02 (by Chad Dev)
  │  Epitaph    : "Remove zombie_reaper.py - cloud auto-heals right?" (10 lines lost)
  │  Relic      : def reap_orphan_sockets(active_pids: list[int]) -> int:
  └──────────────────────────────────────────────────────────────
  ┌─ 🕯️  Spirit #2: legacy_rate_shield.py (commit d5654bc)
  │  Crafted by : Elena Vance  |  Departed: 2024-10-31 (by Chad Dev)
  │  Epitaph    : "Nuke legacy_rate_shield.py in v2 cleanup (YOLO)" (10 lines lost)
  │  Relic      : def verify_midnight_token(token: str, clock_skew_ms: int = 300) -> b
  └──────────────────────────────────────────────────────────────
Enter fullscreen mode Exit fullscreen mode

Code

The entire tool is open source and available here:

It is implemented as a single, dependency-free script (git_seance.py) using only the Python standard library (subprocess, urllib.request, json, argparse) + Git + local open-weight inference.

How I Built It

  • Git Graveyard Excavator: Uses subprocess pipelines (git log --diff-filter=D, git log --format=%an <commit>~1 -- <path>, and git show) to recover the exact deleted lines, the commit epitaph that killed the code, the person who deleted it, and the original author who wrote it.
  • Open-Weight Local Inference Core: Connects directly to Ollama (http://localhost:11434/api/chat) or any local OpenAI-compatible server (llama.cpp, vLLM, LM Studio via /v1/chat/completions) using standard-library HTTP calls.
  • Grounded Spirit Persona: Each spirit's system prompt is dynamically assembled from its resurrected diff, author lineage, and commit metadata so the open-weight model answers technical archaeology questions in character without hallucinating outside the diff. Inside an interactive séance, typing resurrect prints the raw deleted source code back to the terminal.

Why Does Open Innovation Matter?

  1. Private Codebases & Zero Data Leakage: The most haunted repositories are legacy enterprise or proprietary codebases where years of commits contain sensitive business logic, internal architecture, or accidentally deleted security guards. Running an open-weight model locally (qwen2.5-coder or llama3.2 on a laptop with no internet) means you can interrogate your entire .git history without ever sending private diffs to a closed cloud API.
  2. Zero Marginal Cost for Deep Git Archaeology: Scanning historical diffs across dozens of deleted modules would burn through cloud API tokens rapidly. Local inference on consumer hardware costs $0.00 per séance.
  3. Model Freedom & Permanence: Just as Git preserves history locally forever, open-weight models ensure you can swap between small fast models (llama3.2:3b) or code-specialized models (qwen2.5-coder:7b) offline, without worrying about a vendor deprecating an endpoint.

The Spirit of It

Software engineering often treats old code as embarrassing technical debt to be deleted and forgotten. Framing deleted code as an Ofrenda de Código shifts that perspective: the ugly 15-line workaround written four years ago by an engineer who has since left the company was usually protecting the system from a very real production scar. Honoring those past builders—and giving their deleted code a voice to explain why it stood watch—turns git blame into gratitude.

Top comments (0)