Skip to main content

Semantic Git Blame Tool

A powerful semantic search tool for git repositories using LanceDB. Search your git history, find code authors, and understand code evolution using natural language queries.

Features

  • 🔍 Semantic Search: Search commits, code changes, and blame data using natural language
  • 👤 Author Attribution: Find who implemented specific features or functionality
  • 📈 Code Evolution: Track how code has changed over time
  • ⚡ Fast Indexing: Efficient vector indexing with LanceDB
  • 🔌 IDE Integration: Works with Continue for in-editor code intelligence
  • 🌐 HTTP API: REST endpoint for integration with other tools

Quick Start

Prerequisites

  • Python 3.9+
  • Git
  • uv (recommended) or pip

Installation

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone the repository
git clone https://github.com/yourusername/git_blame_search.git
cd git_blame_search

# Install globally from local directory
uv tool install .

Option 2: Local Development

# Clone the repository
git clone https://github.com/yourusername/git_blame_search.git
cd git_blame_search

# Install dependencies
uv sync

Usage

1. Index Your Repository

# Index current repository (recent 100 commits)
git_blame_search index --max-commits 100

# Index a specific repository
git_blame_search index --repo /path/to/repo --max-commits 500

# For testing with minimal commits (e.g., new repos)
git_blame_search index --max-commits 1

2. Index Specific Files for Blame Analysis

# Index blame data for important files
git_blame_search index-file main.py
git_blame_search index-file src/core/auth.py

3. Search Commits

# For testing in a new (this) repository
git_blame_search search "init"

# Search by natural language
git_blame_search search "authentication implementation"
git_blame_search search "bug fix for memory leak"
git_blame_search search "refactoring database layer" --limit 20
# Find who wrote specific functionality
git_blame_search blame "error handling logic"
git_blame_search blame "database connection" --file src/db.py

5. Author Attribution

# Find who implemented features
git_blame_search who "authentication system"
git_blame_search who "caching implementation"

Continue Integration

1. Index Your Repository First

# Index your repository before using MCP. It will take a minute on mature projects.
git_blame_search index --max-commits 100

# Optionally index specific files for blame analysis
git_blame_search index-file src/main.py

2. Configure Continue

Add to your ~/.continue/config.yml:

mcpServers:
  - name: git_blame_search
    command: git_blame_search
    args:
      - mcp
    cwd: "."

3. Use in VSCode

  • Use git_blame_search in Continue chat
  • Ask questions like "who implemented the auth system?"

Example Queries

Finding Code Authors

uv run python git_blame_tool.py who "security vulnerability fix"
uv run python git_blame_tool.py who "REST API implementation"

Understanding Code Evolution

uv run python git_blame_tool.py search "added try-catch blocks"
uv run python git_blame_tool.py search "refactored to use async/await"

Blame Analysis

uv run python git_blame_tool.py blame "validate.*email"
uv run python git_blame_tool.py blame "test_.*authentication" --file tests/

Architecture

The tool uses:

  • LanceDB: Vector database for storing and searching embeddings
  • Sentence Transformers: Microsoft's CodeBERT for code-aware embeddings
  • GitPython: For parsing git repository data
  • Rich: For beautiful CLI output

Data Schema

Commits Table

  • Commit metadata (hash, author, timestamp, message)
  • Files changed, additions, deletions
  • Message vector embeddings

Blame Table

  • File path, line number, commit hash
  • Author information and timestamps
  • Code content and vector embeddings

Diffs Table

  • Change type, file paths
  • Old and new content
  • Diff chunk vector embeddings

Performance Tips

Large Repositories

For repositories with 10k+ commits:

# Process in batches
uv run python git_blame_tool.py index --max-commits 1000 --skip 0
uv run python git_blame_tool.py index --max-commits 1000 --skip 1000

Memory Optimization

# Use smaller batches
uv run python git_blame_tool.py index --max-commits 50

# Increase PyTorch memory
export PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512

Faster Embeddings

Modify the embedder for speed:

# In git_blame_tool.py, change:
self.embedder = SentenceTransformer('all-MiniLM-L6-v2')  # Faster

API Reference

CLI Commands

  • index - Index a git repository

    • --repo, -r - Repository path (default: current directory)
    • --max-commits, -m - Maximum commits to index
  • index-file - Index blame data for a specific file

    • FILE_PATH - Path to file to index
  • search - Search commits

    • QUERY - Natural language search query
    • --limit, -l - Number of results (default: 10)
  • blame - Search blame data

    • QUERY - Natural language search query
    • --file, -f - Filter by file path
    • --limit, -l - Number of results (default: 5)
  • who - Find code authors

    • QUERY - Natural language search query
    • --limit, -l - Number of results (default: 5)
  • serve - Start HTTP server for IDE integration

HTTP API

POST /retrieve

{
  "query": "authentication implementation"
}

Response:

{
  "results": [
    {
      "title": "Commit: Add JWT authentication",
      "content": "Author: Jane Smith\nDate: 2024-01-15\n\nAdd JWT authentication middleware",
      "metadata": {
        "type": "commit",
        "hash": "a1b2c3d4e5f6"
      }
    }
  ]
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Acknowledgments

Metadata

Release files for git-blame-search 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-blame-search 0.1.0
File Size Uploaded Provenance
git_blame_search-0.1.0.tar.gz 144.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for git-blame-search 0.1.0
File Interpreter ABI Platform
git_blame_search-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 308.2 kB

Release files / git_blame_search-0.1.0.tar.gz

Download URL git_blame_search-0.1.0.tar.gz
Size 144.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6ddc933d8bc79dab78f7b3a752b762e5fd86f8596b918881e47587b4974864e5
BLAKE2b-256 checksum
How to use checksums
b066b9bdfef8a17de4efeb01271b64adc700b237fcc5ab4394d568914bda7d8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / git_blame_search-0.1.0-py3-none-any.whl

Download URL git_blame_search-0.1.0-py3-none-any.whl
Size 164.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b742c3c3a226d0df01c067dab4990a0748ab0fcccc5b0fd6a1b614fe2d37f5d0
BLAKE2b-256 checksum
How to use checksums
702aa83b96e68741503f44c59b8215e6c397b3cbf393718b3a28a0827b247472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for git-blame-search 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page