Metadata-Version: 2.4
Name: llm-reviewer
Version: 0.2.0
Summary: The persistent memory layer for AI coding agents
Keywords: ai,llm,code-review,developer-tools,memory,context-compression
Author: Aarav Khanal
Requires-Python: >=3.11,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Quality Assurance
Provides-Extra: huggingface
Requires-Dist: PyGithub (>=2.1.1,<3.0.0)
Requires-Dist: chromadb (>=0.6.3,<0.7.0)
Requires-Dist: click (>=8.1.7,<9.0.0)
Requires-Dist: fastapi (>=0.115.0,<0.116.0)
Requires-Dist: hf-xet (>=1.1.2,<2.0.0) ; extra == "huggingface"
Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
Requires-Dist: langchain (>=0.3.6,<0.4.0)
Requires-Dist: langchain-anthropic (>=0.3.10,<0.4.0)
Requires-Dist: langchain-chroma (>=0.2.1,<0.3.0)
Requires-Dist: langchain-community (>=0.3.5,<0.4.0)
Requires-Dist: langchain-core (>=0.3.0,<0.4.0)
Requires-Dist: langchain-huggingface (>=0.2.0,<0.3.0) ; extra == "huggingface"
Requires-Dist: langchain-ollama (>=0.3.2,<0.4.0)
Requires-Dist: langchain-openai (>=0.3.17,<0.4.0)
Requires-Dist: langchain-text-splitters (>=0.3.8,<0.4.0)
Requires-Dist: langgraph (>=1.0.0,<2.0.0)
Requires-Dist: mcp (>=1.0.0,<2.0.0)
Requires-Dist: networkx (>=3.4.2,<4.0.0)
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
Requires-Dist: python-gitlab (>=5.6.0,<6.0.0)
Requires-Dist: python-multipart (>=0.0.17,<0.0.18)
Requires-Dist: sqlmodel (>=0.0.22,<0.0.23)
Requires-Dist: uvicorn[standard] (>=0.32.0,<0.33.0)
Requires-Dist: watchdog (>=4.0.0,<5.0.0)
Project-URL: Documentation, https://github.com/Aaravkhanal/llm-reviewer#readme
Project-URL: Homepage, https://github.com/Aaravkhanal/llm-reviewer
Project-URL: Repository, https://github.com/Aaravkhanal/llm-reviewer
Description-Content-Type: text/markdown

# ProjectMind AI

A persistent memory layer for AI coding agents. ProjectMind analyzes your codebase, builds a structured knowledge base, and generates context-enriched prompts — so every AI interaction starts with full project awareness instead of a blank slate.

## What it does

Most AI coding tools start from zero every session. ProjectMind fixes that by:

- Extracting your project's DNA (language, frameworks, architecture, patterns)
- Running static analysis (circular deps, dead code, security issues, duplicates)
- Storing a persistent memory of decisions, errors, and patterns across sessions
- Compressing all of that into a token-efficient context that fits inside any LLM's window
- Generating enriched prompts that give agents everything they need upfront

## Features

| Feature | Description |
|---|---|
| **Project DNA Engine** | Detects language, frameworks, architecture pattern, DB, auth, deployment |
| **Architecture Analyzer** | AST-based static analysis — cyclomatic complexity, circular deps, dead code, security scan |
| **Persistent Memory** | SQLite-backed store for tasks, decisions, known errors, and patterns |
| **Vector Memory** | ChromaDB semantic search across all memory types (no external server) |
| **Token Compression** | Converts `.projectmind/` files into a compact JSON context — no LLM required |
| **Smart Prompt Generator** | Task + compressed context + relevant memories → enriched agent prompt |
| **GitLab MR Reviewer** | Two-stage LangChain review chain that posts directly to merge request comments |
| **REST API** | FastAPI backend with endpoints for all features |
| **CLI** | `projectmind` command for init, analyze, compress, generate-prompt, memory |

## Stack

- **Python 3.12** + Poetry
- **FastAPI** — REST API backend
- **LangChain** — LLM chains and RAG pipeline
- **SQLModel** — SQLite memory persistence
- **ChromaDB** — embedded vector store (no server needed)
- **NVIDIA NIM / OpenAI / Anthropic / Ollama** — LLM providers
- **Docker** — containerized deployment

## Quick Start

### Prerequisites

- Python 3.12+
- [Poetry](https://python-poetry.org/)

### Install

```bash
git clone <your-repo-url>
cd projectmind
poetry install
```

### Configure

Copy `.env.local` and fill in your keys:

```bash
# LLM (NVIDIA NIM recommended — access to 50+ models)
API_URL=https://integrate.api.nvidia.com/v1
API_KEY=your-nvidia-api-key
CODE_MODEL=meta/llama-3.1-70b-instruct
CONVERSATION_MODEL=meta/llama-3.1-8b-instruct
LLM_PROVIDER=nvidia

# GitLab (only needed for MR reviewer)
GIT_TOKEN=your-gitlab-personal-access-token
GIT_BASE_URL=https://gitlab.com
```

### Initialize a project

```bash
# Analyze your project and build the .projectmind/ memory directory
projectmind init /path/to/your/project

# With LLM-enhanced architectural summary
projectmind init /path/to/your/project --llm --provider nvidia
```

### Run static analysis

```bash
projectmind analyze /path/to/your/project
```

Output: circular dependencies, dead code, duplicate functions, security issues, health score.

### Compress context

```bash
# Get a token-efficient JSON summary of your project (no LLM needed)
projectmind compress /path/to/your/project

# With budget and text preview
projectmind compress /path/to/your/project --budget 6000 --show-text
```

### Generate an agent prompt

```bash
projectmind generate-prompt /path/to/your/project --task "add JWT authentication to the API"
```

Outputs a context-enriched prompt ready to paste into any AI coding agent.

### Manage memory

```bash
# List stored memories
projectmind memory list /path/to/your/project

# Record a decision
projectmind memory add-decision /path/to/your/project

# Record a known error + fix
projectmind memory add-error /path/to/your/project

# Semantic search across all memories
projectmind memory search /path/to/your/project --query "authentication pattern"
```

### Start the API server

```bash
projectmind serve
# or
poetry run serve
```

API docs available at `http://localhost:8000/docs`

## API Endpoints

| Method | Endpoint | Description |
|---|---|---|
| `POST` | `/analyze` | Extract project DNA and initialize `.projectmind/` |
| `POST` | `/architecture` | Run full static analysis |
| `POST` | `/compress` | Compress project context to token-efficient JSON |
| `POST` | `/prompt/generate` | Generate context-enriched agent prompt |
| `GET/POST` | `/memory/tasks` | Task memory CRUD |
| `GET/POST` | `/memory/errors` | Known error memory CRUD |
| `GET/POST` | `/memory/decisions` | Decision memory CRUD |
| `GET/POST` | `/memory/patterns` | Pattern memory CRUD |
| `GET` | `/memory/search` | Semantic search across memories |
| `POST` | `/review` | GitLab MR code review |
| `GET` | `/health` | Health check |

## Docker

```bash
# Start API + Redis
docker compose up --build

# API at http://localhost:8000
# API docs at http://localhost:8000/docs
```

## Project structure

```
projectmind/
├── backend/
│   ├── api/              # FastAPI app and routes
│   ├── core/
│   │   ├── analyzer/     # AST parser, dep graph, dead code, security
│   │   ├── compression/  # Token budget + compressor
│   │   ├── dna/          # Project DNA extractor + generator
│   │   ├── memory/       # SQLite + ChromaDB memory store
│   │   └── prompt/       # Smart prompt generator
│   ├── git/              # GitLab client
│   ├── llm/              # LLM provider abstraction + prompts
│   └── vector/           # Embeddings + vector store
├── cli/                  # Click CLI (projectmind command)
├── .projectmind/         # Generated per-project memory directory
│   ├── architecture.md
│   ├── coding_style.md
│   ├── decisions.md
│   ├── memory.db
│   └── embeddings/
└── pyproject.toml
```

## LLM Providers

| Provider | How to use |
|---|---|
| **NVIDIA NIM** | Set `LLM_PROVIDER=nvidia`, `API_KEY=nvapi-...` — access to Llama, Mistral, Phi, and more |
| **OpenAI** | Set `LLM_PROVIDER=openai`, `API_KEY=sk-...` |
| **Anthropic** | Set `LLM_PROVIDER=anthropic`, `ANTHROPIC_API_KEY=sk-ant-...` |
| **Ollama** | Set `LLM_PROVIDER=ollama`, `API_URL=http://localhost:11434` — fully local |

## Requirements

- No LLM key needed for: `init`, `analyze`, `compress`, `generate-prompt` (template mode)
- LLM key needed for: `--llm` flag on init/generate-prompt, GitLab MR reviewer
- GitLab token needed for: MR reviewer only

