跳到正文
DEV Community· Yashika Kumari Vishwakarma·· 3 小時前AI 評分44

LastWords:程式碼留下記錄,讓你追問當年由誰撰寫

# 👻 The Code Remembers. Now You Can Ask Who Wrote It. 💻✨

AI 導讀

LastWords 是一款本機優先的 AI 工具,讓用戶向已不活躍的程式碼貢獻者詢問程式碼背後的設計理由。它透過 Git blame 和提交記錄檢索證據,再以 Ollama 本機執行的 Gemma 2B 生成可追溯至提交記錄的回答。專案有 68 項測試通過,推理所用的程式碼庫內容留在開發者的裝置上。

正文

What if you could have a conversation with the developer who wrote a piece of code five years ago — even if they've long since left the project?

Every codebase has ghosts. 👻

Not the scary kind.

I'm talking about developers who once spent nights fixing bugs, designing systems, writing clever workarounds, and leaving behind thousands of lines of code.

Eventually, they move on. 🚶‍♂️

Their commits remain. Their reasoning gets buried. And someone new inherits a codebase full of decisions nobody remembers making.

Then I started thinking...

💡 What if we could ask those developers about their work?

That question became LastWords.

Welcome to my submission for Hacktoberfest Open-Source AI Challenge — Week 4: Ghost in the Machine! 🎃
(https://dev.to/challenges/hacktoberfest-week4-2026-10-26)*


🚀 What I Built

👻 LastWords

Talk to the contributors who built your codebase.

LastWords is a local-first AI tool that brings a codebase's contributor history into a conversation.

It identifies inactive contributors, retrieves their real Git commits, and uses an open-weight AI model to generate evidence-grounded answers in their first-person voice.

It has three main capabilities:

🔮 1. Summon the Contributors

Point LastWords at a Git repository.

It analyzes the commit history, identifies inactive contributors, and calculates how many source-code lines they still maintain.

💬 2. Ask the Ghosts

Ever wondered why a developer implemented something in a particular way?

Now you can ask!

For example:

"Why was this function implemented this way?"

LastWords uses Git blame to identify the contributor responsible for the line, retrieves relevant commits, and asks Gemma to generate an answer based on that evidence.

Every response can include commit-hash references, allowing you to trace the answer back to the actual project history.

🕯️ 3. Build an Ofrenda

LastWords generates a Día de los Muertos-inspired tribute website for contributors.

It displays their names, actual commit messages, and surviving source-line counts.

It's a digital tribute to the people whose work continues to live inside open-source software. 🌼

One important clarification: a "ghost" simply means a contributor who has not committed in a long time. It never implies that the person has passed away.


🎬 Demo Time!

🌐 Live Website (Vercel): https://lastwords-chi.vercel.app/

The live website showcases the generated contributor ofrenda.

The interactive AI conversation runs locally through Python and Ollama.

⚡ Try It Yourself

# 🔮 Summon contributors
python -m lastwords.cli summon ./path/to/repository

# 💬 Ask a contributor about a particular line
python -m lastwords.cli ask ./path/to/repository \
  "Why was this implementation chosen?" \
  --file app.py --line 120

# 🕯️ Generate the ofrenda website
python -m lastwords.cli ofrenda ./path/to/repository \
  --top 6 --out site

🛠️ How I Built It

I wanted the AI to do more than imitate a developer's personality.

It needed to have actual evidence from the repository.

🧰 Technology Stack

Technology Purpose
🐍 Python Core application and CLI
🔗 GitPython Git history and blame analysis
🧠 Gemma 2B (gemma2:2b) Open-weight AI model
🦙 Ollama Local model inference
🎨 Jinja2 HTML template generation
📊 Sentry Optional tracing and observability
▲ Vercel Public static website hosting

🧠 How the AI Works

When someone asks about a particular line of code, LastWords:

  1. 🔍 Uses Git blame to identify the contributor responsible for that line.
  2. 📜 Retrieves the commit that introduced the line.
  3. 🧩 Searches the contributor's history for additional relevant commits.
  4. 📝 Constructs a context-grounded prompt from the retrieved evidence.
  5. 🧠 Sends that context to Gemma running locally through Ollama.
  6. ✅ Validates commit citations against the retrieved commit history.

The most important design decision:

Git history is the source of evidence. Gemma is the conversational layer.

If the available history doesn't contain an answer, LastWords can acknowledge that it doesn't remember rather than inventing a technical explanation.

🌼 The Ofrenda

The ofrenda is deterministic by default.

Its contributor notes come from real commit messages, not fabricated AI biographies. This means the tribute website can be generated without requiring an AI model.

🧪 Testing and Reliability

I didn't want this to remain just a concept or a pretty interface.

The project includes automated tests covering:

  • Git history and contributor analysis
  • Commit retrieval and citation validation
  • Unicode contributor names
  • Error handling
  • Tracing and privacy safeguards
  • HTML escaping
  • Reproducible website generation

🎯 Final test result: 68 tests passed!


🌍 Why Does Open Innovation Matter?

For LastWords, open innovation is not just about choosing an open model. It directly shapes the architecture.

A Git repository can contain private source code, internal implementation details, and sensitive development history.

I wanted developers to explore that history without sending repository context to a hosted AI inference API.

That's why LastWords uses Gemma through Ollama.

🖥️ The model runs locally, and the repository context used for inference stays on the developer's machine.

Open-weight AI makes this possible:

  • 🔐 Privacy: Repository context is not sent to a hosted AI inference API.
  • 🎛️ Control: Developers can choose and run their own local model.
  • 💸 Accessibility: The core workflow does not require a paid AI API subscription.
  • 🔄 Flexibility: Developers can experiment with different models.
  • 🌱 Independence: The application isn't dependent on a single closed AI provider.

Open innovation gave me the freedom to build something privacy-conscious, customizable, and accessible.


🤖 My Agent Session

I used Claude Code as my development assistant throughout the project.

My workflow included:

  • 🔍 Architecture auditing
  • 🏗️ Incremental implementation
  • 🧪 Automated testing
  • 🛡️ Security and privacy reviews
  • 📦 Release preparation

The important part wasn't simply generating code. It was repeatedly reviewing the implementation, testing edge cases, improving retrieval quality, and ensuring AI-generated responses remained grounded in actual commits.


🕯️ The Spirit of It

There is something strangely beautiful about an old Git repository.

You might find a commit from 2015 that fixed a tiny bug. A refactor that nobody remembers. A developer who spent hours solving a problem that would otherwise have disappeared into history.

Years later, another developer opens that file and wonders:

"Why did they do it this way?"

The code cannot answer everything.

But it can preserve traces of the person who wrote it.

I built LastWords because I believe open-source software is more than code.

It is a collection of human decisions, experiments, mistakes, ideas, and contributions.

The developers may move on.

Their code remains.

And now, you can ask it a question. 👻❤️


🏆 Prize Category

🧠 Best Use of Gemma

Gemma 2B powers LastWords' evidence-grounded contributor conversations through local Ollama inference.


✨ Built with curiosity, open-source technology, and a little bit of ghostly inspiration.

Hacktoberfest Open-Source AI Challenge — Week 4: Ghost in the Machine

hf26challenge #hacktoberfest #opensource #AI #Gemma #Ollama #Python #DevChallenge #OpenSourceAI

來源:DEV Community · dev.to