Skip to content

rameshreddy-adutla/gitsage

πŸ§™β€β™‚οΈ GitSage

A sage that knows your codebase

Index your entire GitHub org β†’ Ask questions about your code β†’ Get AI-powered answers with source citations

CI License: MIT Java 21 Micronaut 4 GitHub Copilot Extension Docker


Quick Start β€’ Features β€’ Architecture β€’ Copilot Extension β€’ Configuration β€’ Contributing



πŸ’‘ What is GitSage?

GitSage is a self-hosted RAG (Retrieval-Augmented Generation) bot that indexes your GitHub organisation's repositories and lets you chat with your codebase. It understands your code, READMEs, issues, and development patterns β€” and cites its sources.

Works as a GitHub Copilot Extension β€” type @gitsage in Copilot Chat and ask anything about your org's code.

You:      @gitsage how does authentication work in our services?

GitSage:  Based on the codebase, authentication is handled by the `auth-service` 
          repository using JWT tokens...
          
          πŸ“ auth-service/src/main/java/com/example/AuthController.java
          πŸ“ auth-service/src/main/java/com/example/JwtTokenProvider.java
          
          The flow is: Login β†’ Validate credentials β†’ Issue JWT β†’ Store in 
          HTTP-only cookie β†’ Verify on subsequent requests via JwtAuthFilter...

✨ Features

Feature Description
πŸ” Full Org Indexing Crawls all repos β€” READMEs, source code, issues
🧠 RAG-Powered Chat Answers grounded in your actual code, not hallucinations
πŸ€– Copilot Extension @gitsage in GitHub Copilot Chat (VS Code, JetBrains, github.com)
πŸ“‘ Streaming Responses Real-time SSE streaming for both REST API and Copilot
πŸ”„ Incremental Indexing Only re-indexes changed files (content hash tracking)
⏰ Scheduled Re-indexing Configurable cron-based automatic updates
🐘 pgvector Storage HNSW-indexed vectors in PostgreSQL β€” no extra infra
🐳 One-Command Setup docker compose up and you're running
πŸ”’ Signature Verification Cryptographic webhook verification for Copilot requests
πŸ“Š REST API Full HTTP API for chat, indexing, and status

πŸ— Architecture

graph LR
    subgraph "Your Team"
        A[πŸ‘©β€πŸ’» Developer] -->|"@gitsage"| B[GitHub Copilot]
        A -->|curl/UI| C[REST API]
    end

    subgraph "GitSage"
        B -->|SSE| D["πŸ§™ Copilot Extension<br/>/copilot"]
        C --> E["πŸ’¬ Chat API<br/>/api/chat"]
        
        D --> F[RAG Engine]
        E --> F
        
        F --> G["πŸ” Retrieval<br/>Similarity Search"]
        F --> H["πŸ€– LLM<br/>GPT-4o"]
        
        I["πŸ“₯ Indexer"] --> J["βœ‚οΈ Chunker"]
        J --> K["πŸ“ Embeddings"]
        K --> L
        
        G --> L[("🐘 PostgreSQL<br/>+ pgvector")]
    end

    subgraph "External"
        I -->|GitHub API| M["πŸ“¦ Your Repos"]
        K -->|API| N["OpenAI"]
        H -->|API| N
    end

    style D fill:#6f42c1,color:#fff
    style F fill:#0969da,color:#fff
    style L fill:#336791,color:#fff
Loading

πŸ“– See docs/architecture.md for detailed sequence diagrams and design decisions.

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • GitHub Personal Access Token (create one with repo read access)
  • OpenAI API key (get one)

1. Clone and configure

git clone https://github.com/open-ai-school/gitsage.git
cd gitsage

# Create your environment file
cat > .env << EOF
GITHUB_TOKEN=ghp_your_token_here
GITHUB_ORG=your-org-name
OPENAI_API_KEY=sk-your-key-here
EOF

2. Start everything

docker compose -f docker/docker-compose.yml --env-file .env up -d

That's it. GitSage is running at http://localhost:8080.

3. Index your org

# Trigger initial indexing
curl -X POST http://localhost:8080/api/index

# Check progress
curl http://localhost:8080/api/index/status

4. Ask questions

# Chat with your codebase
curl -X POST http://localhost:8080/api/chat \
  -H "Content-Type: application/json" \
  -d '{"question": "How is error handling implemented across our services?"}'

5. Stream responses

# Real-time streaming
curl -N -X POST http://localhost:8080/api/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"question": "What design patterns are used in the codebase?"}'

πŸ€– Copilot Extension

The killer feature β€” use GitSage directly inside GitHub Copilot Chat.

Setup

  1. Register a GitHub App with Copilot Extension support
  2. Point the webhook URL to https://your-domain.com/copilot
  3. Install the app on your organisation

πŸ“– Full setup guide: docs/copilot-extension-setup.md

Usage

Once installed, any developer in your org can:

@gitsage what does the payment service do?
@gitsage show me how we handle database migrations
@gitsage which repos use Spring Security?
@gitsage explain the CI/CD pipeline in the platform repo

πŸ› οΈ Configuration

GitSage is configured via environment variables:

Variable Required Description Default
GITHUB_TOKEN βœ… GitHub PAT (read-only) β€”
GITHUB_ORG βœ… GitHub org to index β€”
OPENAI_API_KEY βœ… OpenAI API key β€”
POSTGRES_HOST ❌ Database host localhost
POSTGRES_PORT ❌ Database port 5432

πŸ“– Full configuration reference: docs/configuration.md

πŸ“Š API Reference

Endpoint Method Description
/api/chat POST Chat with your codebase (JSON response)
/api/chat/stream POST Streaming chat (SSE)
/api/index POST Trigger full org indexing
/api/index/{repo} POST Index a single repository
/api/index/status GET Get indexing status
/copilot POST Copilot Extension endpoint (SSE)
/health GET Health check

πŸ§ͺ Development

# Start PostgreSQL
docker compose -f docker/docker-compose.yml up -d postgres

# Set environment variables
export GITHUB_TOKEN=ghp_xxx
export GITHUB_ORG=your-org
export OPENAI_API_KEY=sk-xxx

# Run tests
./gradlew test

# Run locally
./gradlew run

πŸ—ΊοΈ Roadmap

  • Ollama support β€” local LLM without API keys
  • Web UI β€” browser-based chat interface
  • Multi-org support β€” index multiple organisations
  • GitHub Discussions β€” index discussion threads
  • PR review context β€” understand review comments
  • GraalVM native image β€” instant startup, minimal memory
  • Slack/Teams integration β€” chat from your team channels

🀝 Contributing

Contributions are welcome! Please read the Contributing Guide before submitting a PR.

πŸ“„ License

MIT β€” see LICENSE for details.


Built with β˜• Java 21 β€’ 🧩 Micronaut 4 β€’ 🦜 LangChain4j β€’ 🐘 PostgreSQL + pgvector

⭐ Star this repo if GitSage helps your team understand their codebase better!

About

πŸ§™ A sage that knows your codebase β€” RAG-powered GitHub org knowledge bot with Copilot Extension support

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors