repomind-ai 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- repomind_ai-0.1.0/PKG-INFO +313 -0
- repomind_ai-0.1.0/README.md +291 -0
- repomind_ai-0.1.0/pyproject.toml +36 -0
- repomind_ai-0.1.0/repomind/__init__.py +3 -0
- repomind_ai-0.1.0/repomind/agents/__init__.py +1 -0
- repomind_ai-0.1.0/repomind/agents/repository_agent.py +421 -0
- repomind_ai-0.1.0/repomind/analyzers/__init__.py +1 -0
- repomind_ai-0.1.0/repomind/analyzers/code_analyzer.py +179 -0
- repomind_ai-0.1.0/repomind/analyzers/dependency_analyzer.py +206 -0
- repomind_ai-0.1.0/repomind/analyzers/repository_analyzer.py +241 -0
- repomind_ai-0.1.0/repomind/cli/__init__.py +1 -0
- repomind_ai-0.1.0/repomind/cli/__main__.py +8 -0
- repomind_ai-0.1.0/repomind/cli/main.py +210 -0
- repomind_ai-0.1.0/repomind/cli/ui.py +138 -0
- repomind_ai-0.1.0/repomind/config.py +109 -0
- repomind_ai-0.1.0/repomind/github/__init__.py +1 -0
- repomind_ai-0.1.0/repomind/github/github_client.py +202 -0
- repomind_ai-0.1.0/repomind/llm/__init__.py +30 -0
- repomind_ai-0.1.0/repomind/llm/base.py +49 -0
- repomind_ai-0.1.0/repomind/llm/gemini_client.py +185 -0
- repomind_ai-0.1.0/repomind/llm/openai_client.py +170 -0
- repomind_ai-0.1.0/repomind/retrieval/__init__.py +1 -0
- repomind_ai-0.1.0/repomind/retrieval/chunker.py +104 -0
- repomind_ai-0.1.0/repomind/retrieval/vector_store.py +103 -0
- repomind_ai-0.1.0/repomind/utils/__init__.py +1 -0
- repomind_ai-0.1.0/repomind/utils/helpers.py +209 -0
- repomind_ai-0.1.0/repomind_ai.egg-info/PKG-INFO +313 -0
- repomind_ai-0.1.0/repomind_ai.egg-info/SOURCES.txt +35 -0
- repomind_ai-0.1.0/repomind_ai.egg-info/dependency_links.txt +1 -0
- repomind_ai-0.1.0/repomind_ai.egg-info/entry_points.txt +2 -0
- repomind_ai-0.1.0/repomind_ai.egg-info/requires.txt +15 -0
- repomind_ai-0.1.0/repomind_ai.egg-info/top_level.txt +1 -0
- repomind_ai-0.1.0/setup.cfg +4 -0
- repomind_ai-0.1.0/tests/test_cli.py +59 -0
- repomind_ai-0.1.0/tests/test_core.py +94 -0
- repomind_ai-0.1.0/tests/test_server.py +155 -0
- repomind_ai-0.1.0/tests/test_url_parsing.py +36 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: repomind-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Understand any GitHub repository with AI - analysis plus evidence-based agent chat.
|
|
5
|
+
Author: RepoMind
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: streamlit>=1.36
|
|
10
|
+
Requires-Dist: google-genai>=1.0
|
|
11
|
+
Requires-Dist: openai>=1.40
|
|
12
|
+
Requires-Dist: chromadb>=0.5
|
|
13
|
+
Requires-Dist: python-dotenv>=1.0
|
|
14
|
+
Requires-Dist: requests>=2.31
|
|
15
|
+
Requires-Dist: rich>=13.7
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
18
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
19
|
+
Provides-Extra: server
|
|
20
|
+
Requires-Dist: fastapi>=0.115; extra == "server"
|
|
21
|
+
Requires-Dist: uvicorn[standard]>=0.30; extra == "server"
|
|
22
|
+
|
|
23
|
+
# 🧠 RepoMind
|
|
24
|
+
|
|
25
|
+
**Understand any GitHub repository with AI.**
|
|
26
|
+
|
|
27
|
+
RepoMind is an AI-powered developer tool that analyzes any public GitHub
|
|
28
|
+
repository and lets you have an evidence-based conversation with it. Paste a
|
|
29
|
+
repository URL, and RepoMind clones it safely, understands its architecture,
|
|
30
|
+
tech stack, APIs, and database, generates a structured report — and then answers
|
|
31
|
+
your questions by actually searching and reading the code.
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- **One-click repository analysis** — URL in, structured report out: overview,
|
|
36
|
+
tech stack, file structure, entry points, architecture, data flow, important
|
|
37
|
+
files, dependencies, APIs, database, setup guide, and AI insights.
|
|
38
|
+
- **Agent-style chat ("Ask RepoMind")** — not a single LLM call. The agent
|
|
39
|
+
decides which tools to use (`search_repository`, `read_file`,
|
|
40
|
+
`semantic_search`, `find_api_endpoints`, ...) and answers from real evidence,
|
|
41
|
+
citing file paths and functions.
|
|
42
|
+
- **Semantic code retrieval** — code is chunked on function/class boundaries,
|
|
43
|
+
embedded (Gemini or any OpenAI-compatible API), and stored in a persistent
|
|
44
|
+
ChromaDB vector store, so large repositories are searched, not dumped into
|
|
45
|
+
the model.
|
|
46
|
+
- **Smart filtering** — ignores `.git`, images, binaries, lock files, generated
|
|
47
|
+
files, and oversized files; prioritizes README → configs → entry points →
|
|
48
|
+
core source.
|
|
49
|
+
- **Hallucination-resistant** — if the repository has no evidence for a claim,
|
|
50
|
+
RepoMind says so instead of inventing it.
|
|
51
|
+
- **Architecture diagram** — a Mermaid diagram generated from the detected
|
|
52
|
+
entry points, API endpoints, and database usage.
|
|
53
|
+
- **Disk cache** — analyses are cached per commit SHA; re-opening the same
|
|
54
|
+
repository is instant.
|
|
55
|
+
- **Safe by design** — repository code is never executed, installed, or passed
|
|
56
|
+
to a shell; only read and analyzed.
|
|
57
|
+
|
|
58
|
+
## Architecture
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Streamlit UI (app.py)
|
|
62
|
+
│
|
|
63
|
+
▼
|
|
64
|
+
RepositoryAnalyzer (orchestrator)
|
|
65
|
+
│ ┌──────────────────────┐
|
|
66
|
+
├──► github_client │ URL validation, REST API metadata,
|
|
67
|
+
│ └─────────────────────┘ safe shallow clone
|
|
68
|
+
│ ┌──────────────────────┐
|
|
69
|
+
├──► analyzers/ │ deterministic: dependencies, entry
|
|
70
|
+
│ └─────────────────────┘ points, API routes, DB code, ranking
|
|
71
|
+
│ ┌──────────────────────┐
|
|
72
|
+
├──► retrieval/ │ code-aware chunker + ChromaDB store
|
|
73
|
+
│ └─────────────────────┘ (embeddings)
|
|
74
|
+
│ ┌──────────────────────┐
|
|
75
|
+
└──► agents/ │ tool registry + ReAct-style loop
|
|
76
|
+
└─────────────────────┘ (LLM function calling)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The **agent loop** works like this: the user question plus a system prompt
|
|
80
|
+
("answer only from repository evidence") is sent to the LLM along with the tool
|
|
81
|
+
schemas. The model returns a *function call*, the agent executes the real tool
|
|
82
|
+
against the local clone / vector store, feeds the result back, and repeats until
|
|
83
|
+
the model produces a final answer (capped at 8 iterations). Tools are plain
|
|
84
|
+
Python functions — adding a tool means adding one function and one schema entry.
|
|
85
|
+
|
|
86
|
+
## Tech Stack
|
|
87
|
+
|
|
88
|
+
| Layer | Technology |
|
|
89
|
+
|-------|-----------|
|
|
90
|
+
| Desktop UI | Streamlit |
|
|
91
|
+
| Web UI | FastAPI + vanilla HTML/CSS/JS (Cobalt design system) |
|
|
92
|
+
| CLI | `repomind` console script, wrapped by an npm launcher (`npx repomind-ai`) |
|
|
93
|
+
| LLM | Google Gemini (default) **or** any OpenAI-compatible API (OpenAI, NVIDIA) via a pluggable client |
|
|
94
|
+
| Embeddings | Gemini embedding model (or `nvidia/nv-embed-v1` via the OpenAI client) |
|
|
95
|
+
| Vector store | ChromaDB (persistent, cosine similarity) |
|
|
96
|
+
| Repo access | GitHub REST API + shallow `git clone` (depth 1) |
|
|
97
|
+
| Config | `python-dotenv` + `.env` |
|
|
98
|
+
|
|
99
|
+
## Screenshots
|
|
100
|
+
|
|
101
|
+
_Screenshots to be added — run the app and capture the landing page, the report
|
|
102
|
+
tabs, and the chat view._
|
|
103
|
+
|
|
104
|
+
## Installation
|
|
105
|
+
|
|
106
|
+
Requires **Python 3.11+** and **Git** on your PATH.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 1. Clone or download this repository
|
|
110
|
+
git clone https://github.com/your-username/repomind.git
|
|
111
|
+
cd repomind
|
|
112
|
+
|
|
113
|
+
# 2. Create a virtual environment and install dependencies
|
|
114
|
+
python -m venv .venv
|
|
115
|
+
.venv\Scripts\activate # Windows
|
|
116
|
+
source .venv/bin/activate # Linux/macOS
|
|
117
|
+
|
|
118
|
+
pip install -e .
|
|
119
|
+
|
|
120
|
+
# 3. Configure environment
|
|
121
|
+
copy .env.example .env # Windows
|
|
122
|
+
cp .env.example .env # Linux/macOS
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Terminal CLI
|
|
126
|
+
|
|
127
|
+
RepoMind also runs in your terminal (published as `repomind-ai`; the command is `repomind`):
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# One-time install via uv (installs Python for you if missing)
|
|
131
|
+
uv tool install repomind-ai
|
|
132
|
+
|
|
133
|
+
# Analyze a repository, then chat about it interactively
|
|
134
|
+
repomind https://github.com/psf/requests
|
|
135
|
+
|
|
136
|
+
# Or ask a single question and exit
|
|
137
|
+
repomind https://github.com/psf/requests --ask "where is authentication handled?"
|
|
138
|
+
|
|
139
|
+
# Once published to npm, no-install usage works too:
|
|
140
|
+
npx repomind-ai https://github.com/psf/requests
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
On first run the CLI asks for your Gemini or OpenAI key and saves it to
|
|
144
|
+
`~/.repomind/config.env`. Override providers/models with `--provider` and
|
|
145
|
+
`--model`.
|
|
146
|
+
|
|
147
|
+
## Website
|
|
148
|
+
|
|
149
|
+
A self-hostable web app built on FastAPI. It serves the same analyzer through a
|
|
150
|
+
job-based API and ships with a dependency-free static frontend.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Install server extras and run locally
|
|
154
|
+
pip install -e ".[server]"
|
|
155
|
+
uvicorn server.main:app --reload
|
|
156
|
+
# open http://localhost:8000
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
API surface:
|
|
160
|
+
|
|
161
|
+
| Endpoint | Purpose |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `POST /api/analyze` `{url, api_key?}` | Start an analysis job, returns `{job_id}` |
|
|
164
|
+
| `GET /api/jobs/{id}` | Poll status + current pipeline stage |
|
|
165
|
+
| `GET /api/report/{id}` | Full structured report (JSON) |
|
|
166
|
+
| `POST /api/ask` `{job_id, question, api_key?}` | Ask the agent; answers cite files |
|
|
167
|
+
|
|
168
|
+
**Hybrid key model:** visitors without a key use the server's shared key under
|
|
169
|
+
per-IP daily limits (`REPOMIND_DAILY_ANALYZES`, default 5; `REPOMIND_DAILY_QUESTIONS`,
|
|
170
|
+
default 40). Pasting your own Gemini/OpenAI key in the UI bypasses the limits;
|
|
171
|
+
keys stay in the browser session and are never persisted server-side.
|
|
172
|
+
|
|
173
|
+
## Deployment
|
|
174
|
+
|
|
175
|
+
The included `Dockerfile` builds one container that serves the frontend, API,
|
|
176
|
+
and worker threads (Python 3.12 slim + git).
|
|
177
|
+
|
|
178
|
+
**Deploy to Render / Fly.io / Railway:**
|
|
179
|
+
|
|
180
|
+
1. Push this repository to GitHub.
|
|
181
|
+
2. Create a Web Service from the repo — the host detects the Dockerfile
|
|
182
|
+
(Render/Railway) or use `fly launch` (Fly.io).
|
|
183
|
+
3. Set environment variables on the host:
|
|
184
|
+
- `GEMINI_API_KEY` (or `OPENAI_API_KEY` + `OPENAI_BASE_URL`) — the shared key
|
|
185
|
+
- `GITHUB_TOKEN` (optional, raises GitHub API limits)
|
|
186
|
+
4. Deploy. The cache lives at `/tmp/repomind` inside the container and is
|
|
187
|
+
disposable — a cold cache simply means the next analysis re-clones.
|
|
188
|
+
|
|
189
|
+
**Continuous delivery:** tagging a release (`git tag v0.1.0 && git push --tags`)
|
|
190
|
+
triggers `.github/workflows/publish.yml`, which publishes the Python package to
|
|
191
|
+
PyPI (trusted publishing) and the npm launcher to npmjs.com. One-time setup:
|
|
192
|
+
add the PyPI trusted publisher for this repo (workflow `publish.yml`,
|
|
193
|
+
environment `pypi`) and store an npm automation token as the `NPM_TOKEN`
|
|
194
|
+
secret. CI (pytest on Linux/macOS/Windows × Python 3.11/3.12) runs on every
|
|
195
|
+
push via `.github/workflows/ci.yml`.
|
|
196
|
+
|
|
197
|
+
## Environment Variables
|
|
198
|
+
|
|
199
|
+
| Variable | Required | Default | Purpose |
|
|
200
|
+
|----------|----------|---------|---------|
|
|
201
|
+
| `LLM_PROVIDER` | No | `gemini` | `gemini` or `openai` (OpenAI/NVIDIA-compatible) |
|
|
202
|
+
| `EMBEDDING_PROVIDER` | No | *(= `LLM_PROVIDER`)* | Override the embedding provider separately (e.g. NVIDIA embeddings + Gemini chat) |
|
|
203
|
+
| `GEMINI_API_KEY` | For Gemini | — | Free key from [aistudio.google.com](https://aistudio.google.com) |
|
|
204
|
+
| `OPENAI_API_KEY` | For OpenAI | — | OpenAI or NVIDIA (`nvapi-...`) key |
|
|
205
|
+
| `OPENAI_BASE_URL` | For NVIDIA | `https://api.openai.com/v1` | Set to `https://integrate.api.nvidia.com/v1` for NVIDIA |
|
|
206
|
+
| `OPENAI_MODEL` | No | `gpt-4o-mini` | Chat model for the OpenAI client |
|
|
207
|
+
| `OPENAI_EMBEDDING_MODEL` | No | `text-embedding-3-small` | Embeddings for the OpenAI client (NVIDIA: `nvidia/nv-embed-v1`) |
|
|
208
|
+
| `GITHUB_TOKEN` | No | — | Raises GitHub API rate limits (60/hr → 5000/hr) |
|
|
209
|
+
| `REPOMIND_CACHE_DIR` | No | `~/.repomind` | Where clones/reports/vectors persist |
|
|
210
|
+
| `REPOMIND_MAX_REPO_MB` | No | `500` | Max repository size |
|
|
211
|
+
| `REPOMIND_MAX_FILES` | No | `200` | Max files analyzed per repo |
|
|
212
|
+
| `REPOMIND_TOP_K` | No | `8` | Semantic search result count |
|
|
213
|
+
| `REPOMIND_DAILY_ANALYZES` | No | `5` | Website: per-IP daily analyses on the shared key |
|
|
214
|
+
| `REPOMIND_DAILY_QUESTIONS` | No | `40` | Website: per-IP daily questions on the shared key |
|
|
215
|
+
|
|
216
|
+
> **Note on free tiers:** Gemini's free tier works reliably for chat but limits
|
|
217
|
+
> embedding requests (`gemini-embedding-001`, ~100 requests/min). NVIDIA's free
|
|
218
|
+
> tier authenticates and provides embeddings (`nvidia/nv-embed-v1`) but chat
|
|
219
|
+
> completions time out. A practical combination: **Gemini for chat + NVIDIA for
|
|
220
|
+
> embeddings** — set `EMBEDDING_PROVIDER=openai` with the NVIDIA key/base URL.
|
|
221
|
+
> **OpenCode Zen** (`https://opencode.ai/zen/v1`, `sk-...` key) also works as an
|
|
222
|
+
> OpenAI-compatible chat provider — e.g. `OPENAI_MODEL=hy3-free` (free models
|
|
223
|
+
> are rate-limited per account). The OpenAI client is also fully usable with a
|
|
224
|
+
> paid OpenAI key.
|
|
225
|
+
|
|
226
|
+
## Running Locally
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
streamlit run app.py
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Open the printed URL (default `http://localhost:8501`), paste a public GitHub
|
|
233
|
+
repository URL, and click **Analyze Repository**.
|
|
234
|
+
|
|
235
|
+
## Example Usage
|
|
236
|
+
|
|
237
|
+
1. Enter `https://github.com/psf/requests`
|
|
238
|
+
2. RepoMind clones it, builds the report (~1–3 min depending on repo size), and
|
|
239
|
+
shows the tabs.
|
|
240
|
+
3. In **💬 Ask RepoMind**, try:
|
|
241
|
+
- "What does this project do?"
|
|
242
|
+
- "Where is authentication implemented?"
|
|
243
|
+
- "Explain the architecture."
|
|
244
|
+
- "Which database is being used?"
|
|
245
|
+
- "What files should I read first if I'm new to this project?"
|
|
246
|
+
|
|
247
|
+
Answers cite evidence, e.g.:
|
|
248
|
+
|
|
249
|
+
> Authentication lives in `requests/auth.py` → `HTTPBasicAuth.__call__()`, which
|
|
250
|
+
> sets the `Authorization` header on each request.
|
|
251
|
+
|
|
252
|
+
If a claim cannot be supported by the repository, you'll see: *"I couldn't find
|
|
253
|
+
evidence for this in the repository."*
|
|
254
|
+
|
|
255
|
+
## Project Structure
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
├── app.py # Streamlit UI (desktop/local)
|
|
259
|
+
├── pyproject.toml # packaging; console script `repomind`
|
|
260
|
+
├── Dockerfile # web deployment container
|
|
261
|
+
├── .github/workflows/ # CI (pytest) + publish (PyPI/npm)
|
|
262
|
+
├── repomind/
|
|
263
|
+
│ ├── config.py # env vars, limits, paths
|
|
264
|
+
│ ├── github/github_client.py # URL validation, API, safe clone
|
|
265
|
+
│ ├── analyzers/
|
|
266
|
+
│ │ ├── repository_analyzer.py # orchestration, tree, ranking, mermaid
|
|
267
|
+
│ │ ├── dependency_analyzer.py # manifests & tech stack
|
|
268
|
+
│ │ └── code_analyzer.py # entry points, API routes, DB code
|
|
269
|
+
│ ├── retrieval/
|
|
270
|
+
│ │ ├── chunker.py # code-aware chunking
|
|
271
|
+
│ │ └── vector_store.py # ChromaDB persistence + search
|
|
272
|
+
│ ├── agents/repository_agent.py # tool registry + agent loop + report
|
|
273
|
+
│ ├── cli/ # terminal entry point (rich TUI)
|
|
274
|
+
│ ├── llm/gemini_client.py # Gemini wrapper, retries, embeddings
|
|
275
|
+
│ └── utils/helpers.py # logging, safe subprocess, file guards
|
|
276
|
+
├── server/
|
|
277
|
+
│ ├── main.py # FastAPI: analyze jobs, ask endpoint
|
|
278
|
+
│ ├── ratelimit.py # per-IP daily limits (shared key)
|
|
279
|
+
│ └── static/ # frontend (tokens.css / styles.css / app.js)
|
|
280
|
+
├── npm/ # `npx repomind-ai` launcher (bootstraps uv)
|
|
281
|
+
├── tests/ # pytest suite
|
|
282
|
+
└── docs/superpowers/specs/ # design specifications
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Testing
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
.venv\Scripts\python -m pytest -q
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Limitations
|
|
292
|
+
|
|
293
|
+
- Analyzes **public** repositories only (private repos are refused by design).
|
|
294
|
+
- Free-tier Gemini rate limits apply; a Pro model can be set via
|
|
295
|
+
`REPOMIND_CHAT_MODEL`.
|
|
296
|
+
- Repos over 500 MB (configurable) are refused before cloning.
|
|
297
|
+
- Heuristic detection of API endpoints and database code covers common
|
|
298
|
+
frameworks (FastAPI, Flask, Django, Express, Spring, etc.); exotic
|
|
299
|
+
frameworks may be partially detected.
|
|
300
|
+
- Analysis time scales with repository size (bounded by `REPOMIND_MAX_FILES`).
|
|
301
|
+
|
|
302
|
+
## Future Improvements
|
|
303
|
+
|
|
304
|
+
- GitHub PR / commit-history analysis
|
|
305
|
+
- Code-quality and security-vulnerability scanning
|
|
306
|
+
- Repository comparison and developer-onboarding mode
|
|
307
|
+
- Automatic documentation generation
|
|
308
|
+
- "Explain this code like I'm a beginner" mode
|
|
309
|
+
- Deeper architecture visualization (per-module diagrams)
|
|
310
|
+
|
|
311
|
+
## License
|
|
312
|
+
|
|
313
|
+
MIT
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# 🧠 RepoMind
|
|
2
|
+
|
|
3
|
+
**Understand any GitHub repository with AI.**
|
|
4
|
+
|
|
5
|
+
RepoMind is an AI-powered developer tool that analyzes any public GitHub
|
|
6
|
+
repository and lets you have an evidence-based conversation with it. Paste a
|
|
7
|
+
repository URL, and RepoMind clones it safely, understands its architecture,
|
|
8
|
+
tech stack, APIs, and database, generates a structured report — and then answers
|
|
9
|
+
your questions by actually searching and reading the code.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **One-click repository analysis** — URL in, structured report out: overview,
|
|
14
|
+
tech stack, file structure, entry points, architecture, data flow, important
|
|
15
|
+
files, dependencies, APIs, database, setup guide, and AI insights.
|
|
16
|
+
- **Agent-style chat ("Ask RepoMind")** — not a single LLM call. The agent
|
|
17
|
+
decides which tools to use (`search_repository`, `read_file`,
|
|
18
|
+
`semantic_search`, `find_api_endpoints`, ...) and answers from real evidence,
|
|
19
|
+
citing file paths and functions.
|
|
20
|
+
- **Semantic code retrieval** — code is chunked on function/class boundaries,
|
|
21
|
+
embedded (Gemini or any OpenAI-compatible API), and stored in a persistent
|
|
22
|
+
ChromaDB vector store, so large repositories are searched, not dumped into
|
|
23
|
+
the model.
|
|
24
|
+
- **Smart filtering** — ignores `.git`, images, binaries, lock files, generated
|
|
25
|
+
files, and oversized files; prioritizes README → configs → entry points →
|
|
26
|
+
core source.
|
|
27
|
+
- **Hallucination-resistant** — if the repository has no evidence for a claim,
|
|
28
|
+
RepoMind says so instead of inventing it.
|
|
29
|
+
- **Architecture diagram** — a Mermaid diagram generated from the detected
|
|
30
|
+
entry points, API endpoints, and database usage.
|
|
31
|
+
- **Disk cache** — analyses are cached per commit SHA; re-opening the same
|
|
32
|
+
repository is instant.
|
|
33
|
+
- **Safe by design** — repository code is never executed, installed, or passed
|
|
34
|
+
to a shell; only read and analyzed.
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Streamlit UI (app.py)
|
|
40
|
+
│
|
|
41
|
+
▼
|
|
42
|
+
RepositoryAnalyzer (orchestrator)
|
|
43
|
+
│ ┌──────────────────────┐
|
|
44
|
+
├──► github_client │ URL validation, REST API metadata,
|
|
45
|
+
│ └─────────────────────┘ safe shallow clone
|
|
46
|
+
│ ┌──────────────────────┐
|
|
47
|
+
├──► analyzers/ │ deterministic: dependencies, entry
|
|
48
|
+
│ └─────────────────────┘ points, API routes, DB code, ranking
|
|
49
|
+
│ ┌──────────────────────┐
|
|
50
|
+
├──► retrieval/ │ code-aware chunker + ChromaDB store
|
|
51
|
+
│ └─────────────────────┘ (embeddings)
|
|
52
|
+
│ ┌──────────────────────┐
|
|
53
|
+
└──► agents/ │ tool registry + ReAct-style loop
|
|
54
|
+
└─────────────────────┘ (LLM function calling)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The **agent loop** works like this: the user question plus a system prompt
|
|
58
|
+
("answer only from repository evidence") is sent to the LLM along with the tool
|
|
59
|
+
schemas. The model returns a *function call*, the agent executes the real tool
|
|
60
|
+
against the local clone / vector store, feeds the result back, and repeats until
|
|
61
|
+
the model produces a final answer (capped at 8 iterations). Tools are plain
|
|
62
|
+
Python functions — adding a tool means adding one function and one schema entry.
|
|
63
|
+
|
|
64
|
+
## Tech Stack
|
|
65
|
+
|
|
66
|
+
| Layer | Technology |
|
|
67
|
+
|-------|-----------|
|
|
68
|
+
| Desktop UI | Streamlit |
|
|
69
|
+
| Web UI | FastAPI + vanilla HTML/CSS/JS (Cobalt design system) |
|
|
70
|
+
| CLI | `repomind` console script, wrapped by an npm launcher (`npx repomind-ai`) |
|
|
71
|
+
| LLM | Google Gemini (default) **or** any OpenAI-compatible API (OpenAI, NVIDIA) via a pluggable client |
|
|
72
|
+
| Embeddings | Gemini embedding model (or `nvidia/nv-embed-v1` via the OpenAI client) |
|
|
73
|
+
| Vector store | ChromaDB (persistent, cosine similarity) |
|
|
74
|
+
| Repo access | GitHub REST API + shallow `git clone` (depth 1) |
|
|
75
|
+
| Config | `python-dotenv` + `.env` |
|
|
76
|
+
|
|
77
|
+
## Screenshots
|
|
78
|
+
|
|
79
|
+
_Screenshots to be added — run the app and capture the landing page, the report
|
|
80
|
+
tabs, and the chat view._
|
|
81
|
+
|
|
82
|
+
## Installation
|
|
83
|
+
|
|
84
|
+
Requires **Python 3.11+** and **Git** on your PATH.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 1. Clone or download this repository
|
|
88
|
+
git clone https://github.com/your-username/repomind.git
|
|
89
|
+
cd repomind
|
|
90
|
+
|
|
91
|
+
# 2. Create a virtual environment and install dependencies
|
|
92
|
+
python -m venv .venv
|
|
93
|
+
.venv\Scripts\activate # Windows
|
|
94
|
+
source .venv/bin/activate # Linux/macOS
|
|
95
|
+
|
|
96
|
+
pip install -e .
|
|
97
|
+
|
|
98
|
+
# 3. Configure environment
|
|
99
|
+
copy .env.example .env # Windows
|
|
100
|
+
cp .env.example .env # Linux/macOS
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Terminal CLI
|
|
104
|
+
|
|
105
|
+
RepoMind also runs in your terminal (published as `repomind-ai`; the command is `repomind`):
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# One-time install via uv (installs Python for you if missing)
|
|
109
|
+
uv tool install repomind-ai
|
|
110
|
+
|
|
111
|
+
# Analyze a repository, then chat about it interactively
|
|
112
|
+
repomind https://github.com/psf/requests
|
|
113
|
+
|
|
114
|
+
# Or ask a single question and exit
|
|
115
|
+
repomind https://github.com/psf/requests --ask "where is authentication handled?"
|
|
116
|
+
|
|
117
|
+
# Once published to npm, no-install usage works too:
|
|
118
|
+
npx repomind-ai https://github.com/psf/requests
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
On first run the CLI asks for your Gemini or OpenAI key and saves it to
|
|
122
|
+
`~/.repomind/config.env`. Override providers/models with `--provider` and
|
|
123
|
+
`--model`.
|
|
124
|
+
|
|
125
|
+
## Website
|
|
126
|
+
|
|
127
|
+
A self-hostable web app built on FastAPI. It serves the same analyzer through a
|
|
128
|
+
job-based API and ships with a dependency-free static frontend.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Install server extras and run locally
|
|
132
|
+
pip install -e ".[server]"
|
|
133
|
+
uvicorn server.main:app --reload
|
|
134
|
+
# open http://localhost:8000
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
API surface:
|
|
138
|
+
|
|
139
|
+
| Endpoint | Purpose |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `POST /api/analyze` `{url, api_key?}` | Start an analysis job, returns `{job_id}` |
|
|
142
|
+
| `GET /api/jobs/{id}` | Poll status + current pipeline stage |
|
|
143
|
+
| `GET /api/report/{id}` | Full structured report (JSON) |
|
|
144
|
+
| `POST /api/ask` `{job_id, question, api_key?}` | Ask the agent; answers cite files |
|
|
145
|
+
|
|
146
|
+
**Hybrid key model:** visitors without a key use the server's shared key under
|
|
147
|
+
per-IP daily limits (`REPOMIND_DAILY_ANALYZES`, default 5; `REPOMIND_DAILY_QUESTIONS`,
|
|
148
|
+
default 40). Pasting your own Gemini/OpenAI key in the UI bypasses the limits;
|
|
149
|
+
keys stay in the browser session and are never persisted server-side.
|
|
150
|
+
|
|
151
|
+
## Deployment
|
|
152
|
+
|
|
153
|
+
The included `Dockerfile` builds one container that serves the frontend, API,
|
|
154
|
+
and worker threads (Python 3.12 slim + git).
|
|
155
|
+
|
|
156
|
+
**Deploy to Render / Fly.io / Railway:**
|
|
157
|
+
|
|
158
|
+
1. Push this repository to GitHub.
|
|
159
|
+
2. Create a Web Service from the repo — the host detects the Dockerfile
|
|
160
|
+
(Render/Railway) or use `fly launch` (Fly.io).
|
|
161
|
+
3. Set environment variables on the host:
|
|
162
|
+
- `GEMINI_API_KEY` (or `OPENAI_API_KEY` + `OPENAI_BASE_URL`) — the shared key
|
|
163
|
+
- `GITHUB_TOKEN` (optional, raises GitHub API limits)
|
|
164
|
+
4. Deploy. The cache lives at `/tmp/repomind` inside the container and is
|
|
165
|
+
disposable — a cold cache simply means the next analysis re-clones.
|
|
166
|
+
|
|
167
|
+
**Continuous delivery:** tagging a release (`git tag v0.1.0 && git push --tags`)
|
|
168
|
+
triggers `.github/workflows/publish.yml`, which publishes the Python package to
|
|
169
|
+
PyPI (trusted publishing) and the npm launcher to npmjs.com. One-time setup:
|
|
170
|
+
add the PyPI trusted publisher for this repo (workflow `publish.yml`,
|
|
171
|
+
environment `pypi`) and store an npm automation token as the `NPM_TOKEN`
|
|
172
|
+
secret. CI (pytest on Linux/macOS/Windows × Python 3.11/3.12) runs on every
|
|
173
|
+
push via `.github/workflows/ci.yml`.
|
|
174
|
+
|
|
175
|
+
## Environment Variables
|
|
176
|
+
|
|
177
|
+
| Variable | Required | Default | Purpose |
|
|
178
|
+
|----------|----------|---------|---------|
|
|
179
|
+
| `LLM_PROVIDER` | No | `gemini` | `gemini` or `openai` (OpenAI/NVIDIA-compatible) |
|
|
180
|
+
| `EMBEDDING_PROVIDER` | No | *(= `LLM_PROVIDER`)* | Override the embedding provider separately (e.g. NVIDIA embeddings + Gemini chat) |
|
|
181
|
+
| `GEMINI_API_KEY` | For Gemini | — | Free key from [aistudio.google.com](https://aistudio.google.com) |
|
|
182
|
+
| `OPENAI_API_KEY` | For OpenAI | — | OpenAI or NVIDIA (`nvapi-...`) key |
|
|
183
|
+
| `OPENAI_BASE_URL` | For NVIDIA | `https://api.openai.com/v1` | Set to `https://integrate.api.nvidia.com/v1` for NVIDIA |
|
|
184
|
+
| `OPENAI_MODEL` | No | `gpt-4o-mini` | Chat model for the OpenAI client |
|
|
185
|
+
| `OPENAI_EMBEDDING_MODEL` | No | `text-embedding-3-small` | Embeddings for the OpenAI client (NVIDIA: `nvidia/nv-embed-v1`) |
|
|
186
|
+
| `GITHUB_TOKEN` | No | — | Raises GitHub API rate limits (60/hr → 5000/hr) |
|
|
187
|
+
| `REPOMIND_CACHE_DIR` | No | `~/.repomind` | Where clones/reports/vectors persist |
|
|
188
|
+
| `REPOMIND_MAX_REPO_MB` | No | `500` | Max repository size |
|
|
189
|
+
| `REPOMIND_MAX_FILES` | No | `200` | Max files analyzed per repo |
|
|
190
|
+
| `REPOMIND_TOP_K` | No | `8` | Semantic search result count |
|
|
191
|
+
| `REPOMIND_DAILY_ANALYZES` | No | `5` | Website: per-IP daily analyses on the shared key |
|
|
192
|
+
| `REPOMIND_DAILY_QUESTIONS` | No | `40` | Website: per-IP daily questions on the shared key |
|
|
193
|
+
|
|
194
|
+
> **Note on free tiers:** Gemini's free tier works reliably for chat but limits
|
|
195
|
+
> embedding requests (`gemini-embedding-001`, ~100 requests/min). NVIDIA's free
|
|
196
|
+
> tier authenticates and provides embeddings (`nvidia/nv-embed-v1`) but chat
|
|
197
|
+
> completions time out. A practical combination: **Gemini for chat + NVIDIA for
|
|
198
|
+
> embeddings** — set `EMBEDDING_PROVIDER=openai` with the NVIDIA key/base URL.
|
|
199
|
+
> **OpenCode Zen** (`https://opencode.ai/zen/v1`, `sk-...` key) also works as an
|
|
200
|
+
> OpenAI-compatible chat provider — e.g. `OPENAI_MODEL=hy3-free` (free models
|
|
201
|
+
> are rate-limited per account). The OpenAI client is also fully usable with a
|
|
202
|
+
> paid OpenAI key.
|
|
203
|
+
|
|
204
|
+
## Running Locally
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
streamlit run app.py
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Open the printed URL (default `http://localhost:8501`), paste a public GitHub
|
|
211
|
+
repository URL, and click **Analyze Repository**.
|
|
212
|
+
|
|
213
|
+
## Example Usage
|
|
214
|
+
|
|
215
|
+
1. Enter `https://github.com/psf/requests`
|
|
216
|
+
2. RepoMind clones it, builds the report (~1–3 min depending on repo size), and
|
|
217
|
+
shows the tabs.
|
|
218
|
+
3. In **💬 Ask RepoMind**, try:
|
|
219
|
+
- "What does this project do?"
|
|
220
|
+
- "Where is authentication implemented?"
|
|
221
|
+
- "Explain the architecture."
|
|
222
|
+
- "Which database is being used?"
|
|
223
|
+
- "What files should I read first if I'm new to this project?"
|
|
224
|
+
|
|
225
|
+
Answers cite evidence, e.g.:
|
|
226
|
+
|
|
227
|
+
> Authentication lives in `requests/auth.py` → `HTTPBasicAuth.__call__()`, which
|
|
228
|
+
> sets the `Authorization` header on each request.
|
|
229
|
+
|
|
230
|
+
If a claim cannot be supported by the repository, you'll see: *"I couldn't find
|
|
231
|
+
evidence for this in the repository."*
|
|
232
|
+
|
|
233
|
+
## Project Structure
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
├── app.py # Streamlit UI (desktop/local)
|
|
237
|
+
├── pyproject.toml # packaging; console script `repomind`
|
|
238
|
+
├── Dockerfile # web deployment container
|
|
239
|
+
├── .github/workflows/ # CI (pytest) + publish (PyPI/npm)
|
|
240
|
+
├── repomind/
|
|
241
|
+
│ ├── config.py # env vars, limits, paths
|
|
242
|
+
│ ├── github/github_client.py # URL validation, API, safe clone
|
|
243
|
+
│ ├── analyzers/
|
|
244
|
+
│ │ ├── repository_analyzer.py # orchestration, tree, ranking, mermaid
|
|
245
|
+
│ │ ├── dependency_analyzer.py # manifests & tech stack
|
|
246
|
+
│ │ └── code_analyzer.py # entry points, API routes, DB code
|
|
247
|
+
│ ├── retrieval/
|
|
248
|
+
│ │ ├── chunker.py # code-aware chunking
|
|
249
|
+
│ │ └── vector_store.py # ChromaDB persistence + search
|
|
250
|
+
│ ├── agents/repository_agent.py # tool registry + agent loop + report
|
|
251
|
+
│ ├── cli/ # terminal entry point (rich TUI)
|
|
252
|
+
│ ├── llm/gemini_client.py # Gemini wrapper, retries, embeddings
|
|
253
|
+
│ └── utils/helpers.py # logging, safe subprocess, file guards
|
|
254
|
+
├── server/
|
|
255
|
+
│ ├── main.py # FastAPI: analyze jobs, ask endpoint
|
|
256
|
+
│ ├── ratelimit.py # per-IP daily limits (shared key)
|
|
257
|
+
│ └── static/ # frontend (tokens.css / styles.css / app.js)
|
|
258
|
+
├── npm/ # `npx repomind-ai` launcher (bootstraps uv)
|
|
259
|
+
├── tests/ # pytest suite
|
|
260
|
+
└── docs/superpowers/specs/ # design specifications
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Testing
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
.venv\Scripts\python -m pytest -q
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Limitations
|
|
270
|
+
|
|
271
|
+
- Analyzes **public** repositories only (private repos are refused by design).
|
|
272
|
+
- Free-tier Gemini rate limits apply; a Pro model can be set via
|
|
273
|
+
`REPOMIND_CHAT_MODEL`.
|
|
274
|
+
- Repos over 500 MB (configurable) are refused before cloning.
|
|
275
|
+
- Heuristic detection of API endpoints and database code covers common
|
|
276
|
+
frameworks (FastAPI, Flask, Django, Express, Spring, etc.); exotic
|
|
277
|
+
frameworks may be partially detected.
|
|
278
|
+
- Analysis time scales with repository size (bounded by `REPOMIND_MAX_FILES`).
|
|
279
|
+
|
|
280
|
+
## Future Improvements
|
|
281
|
+
|
|
282
|
+
- GitHub PR / commit-history analysis
|
|
283
|
+
- Code-quality and security-vulnerability scanning
|
|
284
|
+
- Repository comparison and developer-onboarding mode
|
|
285
|
+
- Automatic documentation generation
|
|
286
|
+
- "Explain this code like I'm a beginner" mode
|
|
287
|
+
- Deeper architecture visualization (per-module diagrams)
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "repomind-ai"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Understand any GitHub repository with AI - analysis plus evidence-based agent chat."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "RepoMind" }]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"streamlit>=1.36",
|
|
15
|
+
"google-genai>=1.0",
|
|
16
|
+
"openai>=1.40",
|
|
17
|
+
"chromadb>=0.5",
|
|
18
|
+
"python-dotenv>=1.0",
|
|
19
|
+
"requests>=2.31",
|
|
20
|
+
"rich>=13.7",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest>=8.0", "httpx>=0.27"]
|
|
25
|
+
server = ["fastapi>=0.115", "uvicorn[standard]>=0.30"]
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
repomind = "repomind.cli.main:main"
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.packages.find]
|
|
31
|
+
include = ["repomind*"]
|
|
32
|
+
exclude = ["tests*", "docs*", "server*", "npm*"]
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
pythonpath = ["."]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Agent loop and tool registry for answering repository questions."""
|