Skip to content

Vansh4195/repochat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RepoChat

Chat with any public GitHub repository, entirely in your browser. Paste a repo URL, add your own Anthropic API key, and ask questions about the codebase — "what does this do?", "where is the HTTP server set up?", "how do I run the tests?" — or get a one-click architecture overview. Answers cite the files they draw from.

There is no backend. The app fetches the repo from the GitHub API and talks to the Anthropic API directly from the page. Your API key never leaves your browser except to go to api.anthropic.com.

How it works

  1. Resolve the repo. A github.com/owner/repo URL, owner/repo, or git URL is parsed to an owner/name pair.
  2. Index it. The app pulls the repository's full file tree via the GitHub Git Trees API, filters out binaries, lockfiles, and vendored dependencies (node_modules/, vendor/, dist/, …), and ranks the rest — READMEs, manifests, and entry points first, tests last.
  3. Load within a budget. It fetches the contents of the top-ranked files up to ~480 KB total (60 files, 60 KB each), which keeps the context comfortably within the model's window for any repo. For small repos this is effectively "load everything that matters."
  4. Chat. The file index and contents are pinned into the system prompt. Each question streams an answer from Claude, rendered as Markdown with inline file citations. Conversation history is kept so follow-ups have context.

The retrieval is deliberately pragmatic — keyword/path ranking plus a size budget, not a vector database — because it runs client-side and needs to work for an arbitrary repo with zero setup.

Run it

It's a static site — no build step, no dependencies.

git clone https://github.com/Vansh4195/repochat.git
cd repochat
python3 -m http.server 8000
# open http://localhost:8000

Any static file server works (npx serve, php -S, etc.). Opening index.html directly via file:// will not work because the app uses ES modules.

Test for free with Gemini

You don't need a paid Anthropic key to verify the chat request/parse logic. A small end-to-end test makes one real LLM call through Google Gemini's OpenAI-compatible endpoint, which is free on the AI Studio tier.

  1. Get a free API key at aistudio.google.com/apikey.

  2. Run the test:

    GEMINI_API_KEY=your_key node tests/e2e.mjs
    # or, equivalently:
    GEMINI_API_KEY=your_key npm run test:e2e

It sends a tiny prompt (max_tokens: 20, costs ~nothing) to gemini-2.0-flash, asserts the response parses and contains text, and prints PASS (exit 0) or FAIL: <reason> (exit non-zero). With no GEMINI_API_KEY set it prints SKIP and exits 0, so CI without a key is not a hard failure. The test runs in Node — no browser, so no CORS — proving the same request/parse logic the app uses works against a real model.

You can also use Gemini inside the app: pick Gemini (free) under Provider on the start screen or in Settings, and paste your free key. It uses the same OpenAI-compatible endpoint and the gemini-2.0-flash model. The endpoint sends permissive CORS headers, so it works directly from the browser; if a particular browser ever blocks it, the Node test above remains the reliable free path. Anthropic stays the default and is unchanged.

Bring your own key

RepoChat is BYO-key. Nothing is stored on a server.

  • Anthropic API key (required to chat with Claude). Get one at console.anthropic.com. Paste it under API keys & options on the start screen, or in Settings. It's saved in your browser's localStorage and sent only to api.anthropic.com, using Anthropic's official browser-CORS header (anthropic-dangerous-direct-browser-access).
  • Gemini API key (free alternative). Switch Provider to Gemini (free) and paste a free key from aistudio.google.com/apikey. Saved the same way and sent only to generativelanguage.googleapis.com via its OpenAI-compatible endpoint. See Test for free with Gemini.
  • GitHub token (optional). Without one you get GitHub's anonymous limit of 60 requests/hour, which is enough for a few small repos. A token — even one with no scopes (public read) — raises that to 5,000/hour. Stored the same way and sent only to api.github.com.

Clear both anytime with Settings → Clear stored keys.

A note on browser API keys

Calling the Anthropic API from a browser means the key is present in the page. That's fine for a personal, local, or single-user tool like this one — you're using your own key on your own machine. Do not deploy this with a shared or embedded key; there is no place in the code for one, and there shouldn't be.

Models

Pick the provider and model in Settings:

Provider Model Notes
Anthropic Claude Opus 4.8 Most capable (default)
Anthropic Claude Sonnet 4.6 Faster, cheaper
Anthropic Claude Haiku 4.5 Cheapest, fine for small repos
Gemini (free) Gemini 2.0 Flash Free on the AI Studio tier

Project layout

index.html     markup + the start / chat / settings views
styles.css     black & white theme (light + dark)
app.js         state, key storage, provider routing, retrieval, UI wiring
github.js      repo parsing, tree fetch, file ranking + content loading
anthropic.js   streaming chat against the Messages API (browser-CORS)
gemini.js      streaming chat against Gemini's OpenAI-compatible endpoint
markdown.js    dependency-free, XSS-safe Markdown → HTML renderer
tests/e2e.mjs  free end-to-end LLM check via Gemini (Node, no browser)
package.json   npm scripts (test:e2e); the app itself has no build step

Limits

  • Large files (>60 KB), binaries, and lockfiles are not indexed, and very large repos are sampled to fit the budget — the sidebar lists exactly what was loaded and the answer will tell you when something it needs wasn't indexed.
  • Only public repositories are supported.

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors