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.
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-keyInstall dependencies:
bun installRun against a local repository or Git URL:
bun run start -- ./repos/travel-with-usAsk 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-indexRemote repositories are cached under repos by default. LangChain HNSW vector
indexes are persisted under .rag/indexes.
Run the full pre-push check:
bun run checkUseful individual commands:
bun run type-check
bun run lint
bun run format
bun testsrc/
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.