DEV Community

Prajwal Ashok Hulle
Prajwal Ashok Hulle

Posted on

I built a time-decaying knowledge graph for my terminal — here's how it works

TerminalPulse — Automatic Context Capture for AI-Assisted Debugging

Every time I used Claude or ChatGPT to fix a bug, I went through the same ritual:

  1. Read the traceback
  2. Copy the error
  3. Switch to AI chat
  4. Explain my project, branch, and current file
  5. Paste relevant code
  6. Wait for a response
  7. Switch back to the terminal

That's a surprising amount of friction repeated dozens of times per week.

So I built TerminalPulse — a background daemon that continuously captures development context and makes it instantly available when something breaks.

When a command fails:

pulse fix
Enter fullscreen mode Exit fullscreen mode

The context is already there.


Core Idea

TerminalPulse builds a time-decaying context graph from three event streams:

  • Focus — active file in VS Code
  • Activity — recently modified files
  • Distress — failed terminal commands

Each event receives a heat score:

heat = e^(-λ × age_seconds) × severity
Enter fullscreen mode Exit fullscreen mode

where:

  • λ = decay constant
  • age_seconds = current_time - event_time
  • severity = importance weight of the event

Older events naturally fade away while recent events remain highly ranked.

The goal is to provide AI tools with the context that is relevant now, rather than a large amount of stale project history.


Architecture

VS Code (Windows) → HTTP:7077  ─┐
Terminal errors   → Unix socket ─┼─→ pulsed daemon
File saves        → watchdog   ─┘

pulsed daemon
    ↓
~/.devpulse_state.json
    ↓
pulse fix
    ↓
TerminalMind / AI Provider
    ↓
Suggested Fix
Enter fullscreen mode Exit fullscreen mode

The daemon is implemented as a long-running Python asyncio process containing:

  • Unix socket server for shell-hook events
  • HTTP server for editor-focus events
  • Filesystem watchdog for file activity

Shell integration is intentionally lightweight.

A small bash hook runs after failed commands and sends a compact JSON payload to the daemon through a Unix socket without re-executing anything.


Windows ↔ WSL Bridge

I primarily develop using Windows 11 + WSL Ubuntu.

One challenge was transferring editor focus information from Windows into a daemon running inside WSL.

The solution:

  1. Poll GetForegroundWindow() on Windows
  2. Extract the filename from the VS Code title bar
  3. Send focus updates over HTTP
  4. Store them as graph events inside the daemon

This keeps focus tracking independent of VS Code extensions.


Example Workflow

python3 server.py

# KeyError: 'user_id'

⚡ Error detected. Run 'pulse fix' to auto-fix.
Enter fullscreen mode Exit fullscreen mode

Running:

pulse fix
Enter fullscreen mode Exit fullscreen mode

can automatically gather:

  • Project type
  • Current git branch
  • Recent commits
  • Recently modified files
  • Relevant source files
  • Error traceback
  • Active editor context

before sending the request to an AI workflow.


Pattern Detection

TerminalPulse also keeps historical event statistics.

pulse insights
Enter fullscreen mode Exit fullscreen mode

Example output:

Recurring failure:
python3 server.py

Occurrences: 4
Failure rate: 80%

Suggestion:
Consider adding automated tests around authentication logic.
Enter fullscreen mode Exit fullscreen mode

The goal is to identify repeated development bottlenecks rather than only fixing individual failures.


Commands

pulse watch
Enter fullscreen mode Exit fullscreen mode

Auto-detect project and start monitoring.

pulse fix
Enter fullscreen mode Exit fullscreen mode

Generate context and launch AI-assisted debugging.

pulse context
Enter fullscreen mode Exit fullscreen mode

Copy ranked context for ChatGPT, Claude, or Cursor.

pulse insights
Enter fullscreen mode Exit fullscreen mode

Analyze recurring failure patterns.

pulse report
Enter fullscreen mode Exit fullscreen mode

Generate an end-of-day development summary.

pulse mcp
Enter fullscreen mode Exit fullscreen mode

Expose context through an MCP server.


Installation

pip install terminalpulse
pip install terminalmind

tmind auth
pulse install-deps
pulse init

source ~/.bashrc

cd your-project
pulse watch
Enter fullscreen mode Exit fullscreen mode

Current status:

  • Python implementation
  • Asyncio-based daemon architecture
  • Windows + WSL support
  • MCP integration
  • 29 passing unit tests

GitHub:
https://github.com/prajwal-2509/terminalpulse

PyPI:
https://pypi.org/project/terminalpulse/

I'd appreciate feedback on the architecture, event-ranking model, and any edge cases or failure modes that come to mind.

Top comments (1)

Collapse
 
harjjotsinghh profile image
Harjot Singh

Time-decay on a knowledge graph is a smart move. Most memory systems treat every fact as equally true forever, which is exactly how an agent ends up acting on a decision you reversed two weeks ago. Decay encodes the thing humans do automatically: recent context outranks stale context unless something keeps reinforcing it. The design question I'd dig into is the decay function, uniform half-life, or does access/reinforcement reset it so load-bearing facts stay hot while one-off noise fades? That recency-versus-reinforcement balance is the same problem I wrestle with for agent context in Moonshift, what the agent saw recently versus what's structurally important to the task. How are you tuning the decay rate, and does a re-access bump a node back up?