DEV Community

Shubham Hagawane
Shubham Hagawane

Posted on

Terminal Déjà Vu: I Got Tired of Solving the Same Error Twice, So My Terminal Now Remembers

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built
Every developer has the same quiet ritual: a command fails, you paste the error into a search engine, you land on a familiar answer, and you think I have definitely fixed this before. You did. You just don't remember where.
Terminal Déjà Vu is a local-first CLI tool that remembers for you. When a command fails, it searches your own past fixes and tells you: "You solved something like this on [date]. Here's what worked." If it has never seen the error, it falls back to a local model that explains the failure in plain language.
No cloud API. No account. Nothing leaves your machine.

Who It's For
Anyone who lives in a terminal and keeps rediscovering the same fixes: port already in use, npm dependency conflicts, git detached HEAD, permission denied, MongoDB connection refused. That is most of us, and especially students and juniors who haven't yet built up muscle memory.

Demo
The flow in about 30 seconds:

  1. A command fails: node server.js throws EADDRINUSE.
  2. I run dejavu why.
  3. It answers: "You solved something like this on [date]: lsof -i :3000, then kill the process." It also adds one line adapting the fix to the current port.
  4. A brand new error gets a clearly labeled "no past fix found" explanation from a local Gemma model.
  5. After I fix it, dejavu save stores the fix, so next time it's instant. Code: [https://github.com/ShubhamHagawane/Terminal-D-j-Vu.git]

The Sloth Angle
The theme was building something that does the work so you don't have to, so I made the tool lazy in the right ways:
• You do nothing to capture data. A tiny shell hook records failures in the background, and the prompt never slows down.
• It indexes lazily. A "sloth mode" indexer embeds new items in small batches, sleeps between them, and backs off when the laptop is on battery or busy.
• It saves effort on repeat. Solve a problem once and you never really solve it again.

How I Built It
The design decisions that mattered most:

  1. Normalize before embedding. Error messages are full of paths, ports, line numbers, and hashes. I strip those out first, so "same error, different project" still matches. This single step improved retrieval more than any model change.
  2. Redact before storing. Shell history is full of tokens, passwords, and API keys. A redaction step masks likely secrets before anything touches disk, and it has its own tests.
  3. Keep the model on a short leash. When a past fix is found, the prompt contains only that fix and the current error, and tells Gemma not to invent extra steps. The model adapts your answer; it doesn't replace it.
  4. Degrade gracefully. If Ollama isn't running, the tool falls back to keyword search and says so, instead of failing. I built this in four parts (foundation, retrieval, the Gemma layer, then stats and polish) and tested each one before starting the next.

Why Open Innovation Matters Here
This project only makes sense with open models.
Privacy is the whole point. Your shell history contains hostnames, file paths, internal project names, and sometimes secrets you pasted by accident. A tool that sends that to a cloud API is a liability. Running Gemma and the embedding model locally means the data physically cannot leave your machine.
It works offline. I turned Wi-Fi off and ran the same demo. Nothing changed, because nothing was ever online. A closed API would have stopped working the moment I lost connection, which is exactly when I'm most likely to be debugging on a train or in a dorm with bad Wi-Fi.
It costs nothing to run. A tool that runs on every failed command would be expensive per call with a paid API. Locally, it's free forever, so I can run it as often as I like.
I can see inside it. Because the models and the code are open, I could inspect exactly what gets sent to the model and tighten the prompt. With a hosted model, that's a black box.

Prize Category
Best Use of Gemma: Gemma generates the plain-language explanations and adapts a saved fix to the current error, all running locally through Ollama. [CONFIRM WHICH GEMMA VARIANT YOU USED AND WHY.]
What I'd Build Next
• Mining shell history to suggest fixes automatically, by spotting a failed command followed by a successful variation
• PowerShell and fish support
• Sharing a fix library with a teammate through an opt-in, redacted export
Try It
git clone [https://github.com/ShubhamHagawane/Terminal-D-j-Vu.git]
cd terminal-deja-vu
npm install
ollama pull nomic-embed-text && ollama pull [gemma2:2b]
node demo/seed.js # optional: load sample fixes
dejavu init --shell zsh # follow the printed instructions
If it saves you from solving the same error twice, that's the whole job done. Thanks for reading, and happy Hacktoberfest!
Built for the Hacktoberfest Open-Source AI Challenge, Week 3: Slow and Steady.

Top comments (1)

Collapse
 
launchgatecheck profile image
Launch Gate •

The normalize-before-embedding step deserves the credit you give it. The same trick generalizes: strip timestamps, PIDs, ports, paths and hashes from any log line before deduping and your alert noise drops the same way. One thing to watch as the store grows: fixes go stale. The npm conflict fix from two years ago can be the wrong answer on a current version. Consider storing the tool version alongside the fix (node --version, npm --version at save time) and ranking a same-version hit above an older one, so the memory ages with the toolchain instead of becoming a museum of expired fixes.