npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jchaffin/gh-rag

v0.3.7

Published

Hybrid RAG over GitHub repos: BM25 + Pinecone + cited answers.

Downloads

783

Readme

import { createGhRag } from "@jchaffin/gh-rag";

const rag = await createGhRag({
  openaiApiKey: process.env.OPENAI_API_KEY!,
  pinecone: { apiKey: process.env.PINECONE_API_KEY!, index: "repo-chunks" },
});

await rag.ingest({ gitUrl: "https://github.com/owner/repo.git" });

const { text } = await rag.answer({
  repo: "repo",
  question: "Tell me about the payments project"
});
console.log(text);

Realtime ask (low-latency retrieval)

For voice or streaming clients, pull context snippets fast without generating a full answer:

const rag = createGhRag({
  openaiApiKey: process.env.OPENAI_API_KEY!,
  pine: { index: /* Pinecone index handle */ } as any,
});

const snippets = await rag.ask({ repo: "repo", query: "auth flow", limit: 6 });
// Each snippet: { path, start, end, text }

Server endpoint (Fastify):

  • Start: npm run build && npm run start
  • POST http://localhost:3000/ask with JSON { "repo": "repo", "query": "auth flow", "limit": 6 }

Notes:

  • Set OPENAI_EMBED_MODEL to match your ingested index (e.g., text-embedding-3-small for speed). Ingestion also respects this.
  • In-memory caching smooths identical queries for ~10s; embeddings cache for ~60s.
  • Local BM25 index is optional. By default, ingest does not write any local files. To enable BM25 text ranking (used by ask when available), either pass writeBm25: true to ingestRepo/rag.ingest, or set GH_RAG_WRITE_BM25=1 and provide a workdir if you don't want ..

CLI

Ask questions from the command line after ingesting a repo into Pinecone.

  • Env: set OPENAI_API_KEY, PINECONE_API_KEY, optional PINECONE_INDEX (default repo-chunks), optional GITHUB_TOKEN.

Examples:

# Build once
npm run build

# Ask (uses env REPO and QUESTION if set)
npm run ask -- --repo my-repo --question "What does the auth flow look like?"

# With JSON output
npm run ask -- -r my-repo -q "Key modules?" --json

# If installed globally (after publish or npm link)
gh-rag-ask -r my-repo "How do I run this?"

# Ingest a repo (GitHub URL or local path)
npm run ask -- --repo-url https://github.com/owner/repo.git --repo repo

# Ingest then immediately ask in one command
npm run ask -- --repo-url https://github.com/owner/repo.git -q "What are the core services?"

# Ingest ALL your GitHub repos (requires GITHUB_TOKEN)
# Default filters: excludes forks and archived repos
npm run ingest:all -- --affiliation owner --visibility all --concurrency 2

# Or if installed globally
gh-rag-ingest-all --affiliation owner --visibility all

# Flags:
#   --include-forks        Include forked repos
#   --include-archived     Include archived repos
#   --dry-run              List what would be ingested
#   --index <name>         Override Pinecone index