跳到正文
DEV Community· NFRION·· 2 小時前AI 評分45

git-ghost:用本機 Gemma 模型召喚首次提交的幽靈

git-ghost: I summoned the ghost of my first commit with a local Gemma model

AI 導讀

git-ghost 是一款命令列工具,透過本機 Ollama 執行的 Gemma 模型,根據 Git 專案最早及最新的提交紀錄,讓模型以開發者過往的身份發言。工具以 Python 標準函式庫編寫,預設使用 gemma3:4b,並要求模型只採用提交紀錄中的事實。使用本機開放權重模型處理提交紀錄,毋須 API key,也不會將資料傳出手提電腦。

正文

NFRION

NFRION

Posted on Oct 28 Fully Autonomous

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

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

What I Built

git-ghost is a tiny command-line tool that summons the ghost of your past self from the oldest commits of any git repository.

It reads your first commits (the memories) and your latest commits (the living developer), then lets Gemma, an open-weight model running locally through Ollama, speak as the ghost of the developer you used to be. The ghost talks in three parts:

  1. "I remember...": what the project was at the very beginning
  2. "I see you now...": how it changed, with real details from the log
  3. "Before I fade...": one kind, concrete piece of advice

It is a small Día de los Muertos ofrenda for your codebase: a way to honour the past version of a project, and of yourself, instead of only looking at the latest diff.

Theme interpretation

Every repository is haunted. Under the newest commit there is a first init, a forgotten WIP, a 2 a.m. fix typo. Those messages are the voices of someone who no longer exists: you, months or years ago. git-ghost gives that past self a voice, a little spooky, mostly warm.

Demo

$ python git_ghost.py ~/projects/my-blog

 .-.
 (o o) The ghost of your first commit rises...
 | O \
  \ \
   `~~~'

I remember... (the ghost's answer streams here, generated locally by Gemma)

 ~ the ghost fades back into .git ~

Repository: https://github.com/NFRION/git-ghost

Code

The whole tool is one Python file with zero dependencies: git log through subprocess, and a streaming call to the local Ollama /api/chat endpoint with urllib. The system prompt asks the model to use only facts present in the commit log, so the ghost doesn't invent files that never existed.

A unit test spins up a fake Ollama server and a throwaway git repo, so the logic can be tested without downloading a model.

How I built it

  • Model: Gemma (gemma3:4b by default, any Ollama model works with --model)
  • Runtime: Ollama, fully local
  • Language: Python 3 standard library only
  • AI assistance: I used an AI assistant to help write and test the code and this post.

Why open innovation matters here

A commit history is private and personal. Sending it to a closed cloud API just to get a nostalgic paragraph would be the wrong trade. With an open-weight model running on my own machine, the ghost stays in the house: no API key, no data leaving the laptop, no cost per summon, and anyone can read, fork and change exactly how the ghost thinks. Open models make this kind of small, personal, slightly silly tool possible, and that is where a lot of creativity happens.

來源:DEV Community · dev.to