Skip to content

fayzanrj/git-rag-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-rag-cli

git-rag-cli is a Bun + TypeScript terminal RAG assistant for source-code repositories. It uses LangChain JS to load source documents, split code chunks, persist a local HNSW vector index, rerank retrieved context with MMR, and answer questions with source citations.

Setup

Create a .env file with your OpenAI-compatible model values:

OPENAI_MODEL=your-chat-model
OPENAI_EMBEDDING_MODEL=your-embedding-model
OPENAI_BASE_URL=https://your-compatible-endpoint.example.com/v1
OPENAI_API_KEY=your-api-key

Install dependencies:

bun install

Run against a local repository or Git URL:

bun run start -- ./repos/travel-with-us

Ask one question and exit:

bun run start -- ./repos/travel-with-us --question "Where is the homepage built?"

Rebuild the persisted vector index:

bun run start -- ./repos/travel-with-us --rebuild-index

Remote repositories are cached under repos by default. LangChain HNSW vector indexes are persisted under .rag/indexes.

Quality Checks

Run the full pre-push check:

bun run check

Useful individual commands:

bun run type-check
bun run lint
bun run format
bun test

Project Structure

src/
  cli/
    args.ts              Parses CLI flags and renders help text.
    chat.ts              Runs the interactive question loop.
  client/
    llmClient.ts         Creates LangChain chat and embedding clients.
  ingestion/
    cloner.ts            Resolves local paths or clones remote Git repositories.
    loader.ts            Loads supported repository files as LangChain documents.
    splitter.ts          Splits repository documents into citation-aware chunks.
  rag/
    context.ts           Formats retrieved chunks for the prompt context.
    prompt.ts            Defines the repository answer prompt.
    response.ts          Normalizes LLM text and token usage.
  retrieval/
    vectorStore.ts       Builds, loads, saves, and queries the HNSW vector store.
  types/
    *.ts                 Keeps shared TypeScript shapes in one place.
  config.ts              Reads model and retrieval settings.
  index.ts               Coordinates the CLI application entry point.
  rag.ts                 Orchestrates indexing and answering.
  terminal.ts            Handles terminal output and prompts.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors