llm-reviewer 0.2.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.
- llm_reviewer-0.2.0/PKG-INFO +244 -0
- llm_reviewer-0.2.0/README.md +197 -0
- llm_reviewer-0.2.0/backend/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/agents/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/agents/graph.py +62 -0
- llm_reviewer-0.2.0/backend/agents/nodes.py +217 -0
- llm_reviewer-0.2.0/backend/agents/state.py +25 -0
- llm_reviewer-0.2.0/backend/api/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/api/main.py +115 -0
- llm_reviewer-0.2.0/backend/api/routes/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/api/routes/adr.py +89 -0
- llm_reviewer-0.2.0/backend/api/routes/advisor.py +65 -0
- llm_reviewer-0.2.0/backend/api/routes/agents.py +167 -0
- llm_reviewer-0.2.0/backend/api/routes/analyze.py +84 -0
- llm_reviewer-0.2.0/backend/api/routes/architecture.py +151 -0
- llm_reviewer-0.2.0/backend/api/routes/compress.py +58 -0
- llm_reviewer-0.2.0/backend/api/routes/deps.py +90 -0
- llm_reviewer-0.2.0/backend/api/routes/explain.py +62 -0
- llm_reviewer-0.2.0/backend/api/routes/github_app.py +320 -0
- llm_reviewer-0.2.0/backend/api/routes/graph.py +128 -0
- llm_reviewer-0.2.0/backend/api/routes/health.py +34 -0
- llm_reviewer-0.2.0/backend/api/routes/memory.py +171 -0
- llm_reviewer-0.2.0/backend/api/routes/onboarding.py +71 -0
- llm_reviewer-0.2.0/backend/api/routes/prompt.py +53 -0
- llm_reviewer-0.2.0/backend/api/routes/review.py +178 -0
- llm_reviewer-0.2.0/backend/api/routes/tracer.py +61 -0
- llm_reviewer-0.2.0/backend/ci/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/ci/gate.py +200 -0
- llm_reviewer-0.2.0/backend/core/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/adr/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/adr/generator.py +304 -0
- llm_reviewer-0.2.0/backend/core/advisor/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/advisor/advisor.py +205 -0
- llm_reviewer-0.2.0/backend/core/analyzer/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/analyzer/ast_parser.py +352 -0
- llm_reviewer-0.2.0/backend/core/analyzer/cache.py +139 -0
- llm_reviewer-0.2.0/backend/core/analyzer/dead_code.py +158 -0
- llm_reviewer-0.2.0/backend/core/analyzer/dependency.py +209 -0
- llm_reviewer-0.2.0/backend/core/analyzer/duplicates.py +79 -0
- llm_reviewer-0.2.0/backend/core/analyzer/reporter.py +359 -0
- llm_reviewer-0.2.0/backend/core/analyzer/security.py +208 -0
- llm_reviewer-0.2.0/backend/core/changelog/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/changelog/semantic.py +207 -0
- llm_reviewer-0.2.0/backend/core/compression/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/compression/budget.py +126 -0
- llm_reviewer-0.2.0/backend/core/compression/compressor.py +247 -0
- llm_reviewer-0.2.0/backend/core/compression/exporter.py +176 -0
- llm_reviewer-0.2.0/backend/core/deps/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/deps/risk.py +259 -0
- llm_reviewer-0.2.0/backend/core/deps/scanner.py +166 -0
- llm_reviewer-0.2.0/backend/core/diff/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/diff/comparator.py +181 -0
- llm_reviewer-0.2.0/backend/core/diff/snapshots.py +106 -0
- llm_reviewer-0.2.0/backend/core/dna/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/dna/extractor.py +491 -0
- llm_reviewer-0.2.0/backend/core/dna/generator.py +266 -0
- llm_reviewer-0.2.0/backend/core/explain/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/explain/generator.py +351 -0
- llm_reviewer-0.2.0/backend/core/graph/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/graph/builder.py +211 -0
- llm_reviewer-0.2.0/backend/core/graph/queries.py +183 -0
- llm_reviewer-0.2.0/backend/core/graph/serializer.py +52 -0
- llm_reviewer-0.2.0/backend/core/memory/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/memory/schema.py +50 -0
- llm_reviewer-0.2.0/backend/core/memory/store.py +298 -0
- llm_reviewer-0.2.0/backend/core/memory/vector_store.py +177 -0
- llm_reviewer-0.2.0/backend/core/onboarding/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/onboarding/generator.py +265 -0
- llm_reviewer-0.2.0/backend/core/prompt/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/prompt/generator.py +193 -0
- llm_reviewer-0.2.0/backend/core/session/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/session/tracker.py +250 -0
- llm_reviewer-0.2.0/backend/core/token_stats.py +160 -0
- llm_reviewer-0.2.0/backend/core/tracer/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/tracer/tracer.py +304 -0
- llm_reviewer-0.2.0/backend/core/watcher/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/core/watcher/watcher.py +172 -0
- llm_reviewer-0.2.0/backend/git/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/git/github.py +71 -0
- llm_reviewer-0.2.0/backend/git/gitlab.py +49 -0
- llm_reviewer-0.2.0/backend/llm/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/llm/prompts/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/llm/prompts/compress.md +25 -0
- llm_reviewer-0.2.0/backend/llm/prompts/context.md +57 -0
- llm_reviewer-0.2.0/backend/llm/prompts/dna_extract.md +15 -0
- llm_reviewer-0.2.0/backend/llm/prompts/response.md +76 -0
- llm_reviewer-0.2.0/backend/llm/prompts/smart_prompt.md +18 -0
- llm_reviewer-0.2.0/backend/llm/providers.py +96 -0
- llm_reviewer-0.2.0/backend/mcp/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/mcp/server.py +440 -0
- llm_reviewer-0.2.0/backend/vector/__init__.py +0 -0
- llm_reviewer-0.2.0/backend/vector/embeddings.py +21 -0
- llm_reviewer-0.2.0/backend/vector/store.py +82 -0
- llm_reviewer-0.2.0/backend/version.py +5 -0
- llm_reviewer-0.2.0/cli/__init__.py +0 -0
- llm_reviewer-0.2.0/cli/main.py +1682 -0
- llm_reviewer-0.2.0/pyproject.toml +98 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llm-reviewer
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The persistent memory layer for AI coding agents
|
|
5
|
+
Keywords: ai,llm,code-review,developer-tools,memory,context-compression
|
|
6
|
+
Author: Aarav Khanal
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Provides-Extra: huggingface
|
|
18
|
+
Requires-Dist: PyGithub (>=2.1.1,<3.0.0)
|
|
19
|
+
Requires-Dist: chromadb (>=0.6.3,<0.7.0)
|
|
20
|
+
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
21
|
+
Requires-Dist: fastapi (>=0.115.0,<0.116.0)
|
|
22
|
+
Requires-Dist: hf-xet (>=1.1.2,<2.0.0) ; extra == "huggingface"
|
|
23
|
+
Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
|
|
24
|
+
Requires-Dist: langchain (>=0.3.6,<0.4.0)
|
|
25
|
+
Requires-Dist: langchain-anthropic (>=0.3.10,<0.4.0)
|
|
26
|
+
Requires-Dist: langchain-chroma (>=0.2.1,<0.3.0)
|
|
27
|
+
Requires-Dist: langchain-community (>=0.3.5,<0.4.0)
|
|
28
|
+
Requires-Dist: langchain-core (>=0.3.0,<0.4.0)
|
|
29
|
+
Requires-Dist: langchain-huggingface (>=0.2.0,<0.3.0) ; extra == "huggingface"
|
|
30
|
+
Requires-Dist: langchain-ollama (>=0.3.2,<0.4.0)
|
|
31
|
+
Requires-Dist: langchain-openai (>=0.3.17,<0.4.0)
|
|
32
|
+
Requires-Dist: langchain-text-splitters (>=0.3.8,<0.4.0)
|
|
33
|
+
Requires-Dist: langgraph (>=1.0.0,<2.0.0)
|
|
34
|
+
Requires-Dist: mcp (>=1.0.0,<2.0.0)
|
|
35
|
+
Requires-Dist: networkx (>=3.4.2,<4.0.0)
|
|
36
|
+
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
37
|
+
Requires-Dist: python-gitlab (>=5.6.0,<6.0.0)
|
|
38
|
+
Requires-Dist: python-multipart (>=0.0.17,<0.0.18)
|
|
39
|
+
Requires-Dist: sqlmodel (>=0.0.22,<0.0.23)
|
|
40
|
+
Requires-Dist: uvicorn[standard] (>=0.32.0,<0.33.0)
|
|
41
|
+
Requires-Dist: watchdog (>=4.0.0,<5.0.0)
|
|
42
|
+
Project-URL: Documentation, https://github.com/Aaravkhanal/llm-reviewer#readme
|
|
43
|
+
Project-URL: Homepage, https://github.com/Aaravkhanal/llm-reviewer
|
|
44
|
+
Project-URL: Repository, https://github.com/Aaravkhanal/llm-reviewer
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# ProjectMind AI
|
|
48
|
+
|
|
49
|
+
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.
|
|
50
|
+
|
|
51
|
+
## What it does
|
|
52
|
+
|
|
53
|
+
Most AI coding tools start from zero every session. ProjectMind fixes that by:
|
|
54
|
+
|
|
55
|
+
- Extracting your project's DNA (language, frameworks, architecture, patterns)
|
|
56
|
+
- Running static analysis (circular deps, dead code, security issues, duplicates)
|
|
57
|
+
- Storing a persistent memory of decisions, errors, and patterns across sessions
|
|
58
|
+
- Compressing all of that into a token-efficient context that fits inside any LLM's window
|
|
59
|
+
- Generating enriched prompts that give agents everything they need upfront
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
| Feature | Description |
|
|
64
|
+
|---|---|
|
|
65
|
+
| **Project DNA Engine** | Detects language, frameworks, architecture pattern, DB, auth, deployment |
|
|
66
|
+
| **Architecture Analyzer** | AST-based static analysis — cyclomatic complexity, circular deps, dead code, security scan |
|
|
67
|
+
| **Persistent Memory** | SQLite-backed store for tasks, decisions, known errors, and patterns |
|
|
68
|
+
| **Vector Memory** | ChromaDB semantic search across all memory types (no external server) |
|
|
69
|
+
| **Token Compression** | Converts `.projectmind/` files into a compact JSON context — no LLM required |
|
|
70
|
+
| **Smart Prompt Generator** | Task + compressed context + relevant memories → enriched agent prompt |
|
|
71
|
+
| **GitLab MR Reviewer** | Two-stage LangChain review chain that posts directly to merge request comments |
|
|
72
|
+
| **REST API** | FastAPI backend with endpoints for all features |
|
|
73
|
+
| **CLI** | `projectmind` command for init, analyze, compress, generate-prompt, memory |
|
|
74
|
+
|
|
75
|
+
## Stack
|
|
76
|
+
|
|
77
|
+
- **Python 3.12** + Poetry
|
|
78
|
+
- **FastAPI** — REST API backend
|
|
79
|
+
- **LangChain** — LLM chains and RAG pipeline
|
|
80
|
+
- **SQLModel** — SQLite memory persistence
|
|
81
|
+
- **ChromaDB** — embedded vector store (no server needed)
|
|
82
|
+
- **NVIDIA NIM / OpenAI / Anthropic / Ollama** — LLM providers
|
|
83
|
+
- **Docker** — containerized deployment
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
### Prerequisites
|
|
88
|
+
|
|
89
|
+
- Python 3.12+
|
|
90
|
+
- [Poetry](https://python-poetry.org/)
|
|
91
|
+
|
|
92
|
+
### Install
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
git clone <your-repo-url>
|
|
96
|
+
cd projectmind
|
|
97
|
+
poetry install
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Configure
|
|
101
|
+
|
|
102
|
+
Copy `.env.local` and fill in your keys:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# LLM (NVIDIA NIM recommended — access to 50+ models)
|
|
106
|
+
API_URL=https://integrate.api.nvidia.com/v1
|
|
107
|
+
API_KEY=your-nvidia-api-key
|
|
108
|
+
CODE_MODEL=meta/llama-3.1-70b-instruct
|
|
109
|
+
CONVERSATION_MODEL=meta/llama-3.1-8b-instruct
|
|
110
|
+
LLM_PROVIDER=nvidia
|
|
111
|
+
|
|
112
|
+
# GitLab (only needed for MR reviewer)
|
|
113
|
+
GIT_TOKEN=your-gitlab-personal-access-token
|
|
114
|
+
GIT_BASE_URL=https://gitlab.com
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Initialize a project
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Analyze your project and build the .projectmind/ memory directory
|
|
121
|
+
projectmind init /path/to/your/project
|
|
122
|
+
|
|
123
|
+
# With LLM-enhanced architectural summary
|
|
124
|
+
projectmind init /path/to/your/project --llm --provider nvidia
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Run static analysis
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
projectmind analyze /path/to/your/project
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Output: circular dependencies, dead code, duplicate functions, security issues, health score.
|
|
134
|
+
|
|
135
|
+
### Compress context
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Get a token-efficient JSON summary of your project (no LLM needed)
|
|
139
|
+
projectmind compress /path/to/your/project
|
|
140
|
+
|
|
141
|
+
# With budget and text preview
|
|
142
|
+
projectmind compress /path/to/your/project --budget 6000 --show-text
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Generate an agent prompt
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
projectmind generate-prompt /path/to/your/project --task "add JWT authentication to the API"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Outputs a context-enriched prompt ready to paste into any AI coding agent.
|
|
152
|
+
|
|
153
|
+
### Manage memory
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# List stored memories
|
|
157
|
+
projectmind memory list /path/to/your/project
|
|
158
|
+
|
|
159
|
+
# Record a decision
|
|
160
|
+
projectmind memory add-decision /path/to/your/project
|
|
161
|
+
|
|
162
|
+
# Record a known error + fix
|
|
163
|
+
projectmind memory add-error /path/to/your/project
|
|
164
|
+
|
|
165
|
+
# Semantic search across all memories
|
|
166
|
+
projectmind memory search /path/to/your/project --query "authentication pattern"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Start the API server
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
projectmind serve
|
|
173
|
+
# or
|
|
174
|
+
poetry run serve
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
API docs available at `http://localhost:8000/docs`
|
|
178
|
+
|
|
179
|
+
## API Endpoints
|
|
180
|
+
|
|
181
|
+
| Method | Endpoint | Description |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| `POST` | `/analyze` | Extract project DNA and initialize `.projectmind/` |
|
|
184
|
+
| `POST` | `/architecture` | Run full static analysis |
|
|
185
|
+
| `POST` | `/compress` | Compress project context to token-efficient JSON |
|
|
186
|
+
| `POST` | `/prompt/generate` | Generate context-enriched agent prompt |
|
|
187
|
+
| `GET/POST` | `/memory/tasks` | Task memory CRUD |
|
|
188
|
+
| `GET/POST` | `/memory/errors` | Known error memory CRUD |
|
|
189
|
+
| `GET/POST` | `/memory/decisions` | Decision memory CRUD |
|
|
190
|
+
| `GET/POST` | `/memory/patterns` | Pattern memory CRUD |
|
|
191
|
+
| `GET` | `/memory/search` | Semantic search across memories |
|
|
192
|
+
| `POST` | `/review` | GitLab MR code review |
|
|
193
|
+
| `GET` | `/health` | Health check |
|
|
194
|
+
|
|
195
|
+
## Docker
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Start API + Redis
|
|
199
|
+
docker compose up --build
|
|
200
|
+
|
|
201
|
+
# API at http://localhost:8000
|
|
202
|
+
# API docs at http://localhost:8000/docs
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Project structure
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
projectmind/
|
|
209
|
+
├── backend/
|
|
210
|
+
│ ├── api/ # FastAPI app and routes
|
|
211
|
+
│ ├── core/
|
|
212
|
+
│ │ ├── analyzer/ # AST parser, dep graph, dead code, security
|
|
213
|
+
│ │ ├── compression/ # Token budget + compressor
|
|
214
|
+
│ │ ├── dna/ # Project DNA extractor + generator
|
|
215
|
+
│ │ ├── memory/ # SQLite + ChromaDB memory store
|
|
216
|
+
│ │ └── prompt/ # Smart prompt generator
|
|
217
|
+
│ ├── git/ # GitLab client
|
|
218
|
+
│ ├── llm/ # LLM provider abstraction + prompts
|
|
219
|
+
│ └── vector/ # Embeddings + vector store
|
|
220
|
+
├── cli/ # Click CLI (projectmind command)
|
|
221
|
+
├── .projectmind/ # Generated per-project memory directory
|
|
222
|
+
│ ├── architecture.md
|
|
223
|
+
│ ├── coding_style.md
|
|
224
|
+
│ ├── decisions.md
|
|
225
|
+
│ ├── memory.db
|
|
226
|
+
│ └── embeddings/
|
|
227
|
+
└── pyproject.toml
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## LLM Providers
|
|
231
|
+
|
|
232
|
+
| Provider | How to use |
|
|
233
|
+
|---|---|
|
|
234
|
+
| **NVIDIA NIM** | Set `LLM_PROVIDER=nvidia`, `API_KEY=nvapi-...` — access to Llama, Mistral, Phi, and more |
|
|
235
|
+
| **OpenAI** | Set `LLM_PROVIDER=openai`, `API_KEY=sk-...` |
|
|
236
|
+
| **Anthropic** | Set `LLM_PROVIDER=anthropic`, `ANTHROPIC_API_KEY=sk-ant-...` |
|
|
237
|
+
| **Ollama** | Set `LLM_PROVIDER=ollama`, `API_URL=http://localhost:11434` — fully local |
|
|
238
|
+
|
|
239
|
+
## Requirements
|
|
240
|
+
|
|
241
|
+
- No LLM key needed for: `init`, `analyze`, `compress`, `generate-prompt` (template mode)
|
|
242
|
+
- LLM key needed for: `--llm` flag on init/generate-prompt, GitLab MR reviewer
|
|
243
|
+
- GitLab token needed for: MR reviewer only
|
|
244
|
+
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# ProjectMind AI
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
Most AI coding tools start from zero every session. ProjectMind fixes that by:
|
|
8
|
+
|
|
9
|
+
- Extracting your project's DNA (language, frameworks, architecture, patterns)
|
|
10
|
+
- Running static analysis (circular deps, dead code, security issues, duplicates)
|
|
11
|
+
- Storing a persistent memory of decisions, errors, and patterns across sessions
|
|
12
|
+
- Compressing all of that into a token-efficient context that fits inside any LLM's window
|
|
13
|
+
- Generating enriched prompts that give agents everything they need upfront
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
| Feature | Description |
|
|
18
|
+
|---|---|
|
|
19
|
+
| **Project DNA Engine** | Detects language, frameworks, architecture pattern, DB, auth, deployment |
|
|
20
|
+
| **Architecture Analyzer** | AST-based static analysis — cyclomatic complexity, circular deps, dead code, security scan |
|
|
21
|
+
| **Persistent Memory** | SQLite-backed store for tasks, decisions, known errors, and patterns |
|
|
22
|
+
| **Vector Memory** | ChromaDB semantic search across all memory types (no external server) |
|
|
23
|
+
| **Token Compression** | Converts `.projectmind/` files into a compact JSON context — no LLM required |
|
|
24
|
+
| **Smart Prompt Generator** | Task + compressed context + relevant memories → enriched agent prompt |
|
|
25
|
+
| **GitLab MR Reviewer** | Two-stage LangChain review chain that posts directly to merge request comments |
|
|
26
|
+
| **REST API** | FastAPI backend with endpoints for all features |
|
|
27
|
+
| **CLI** | `projectmind` command for init, analyze, compress, generate-prompt, memory |
|
|
28
|
+
|
|
29
|
+
## Stack
|
|
30
|
+
|
|
31
|
+
- **Python 3.12** + Poetry
|
|
32
|
+
- **FastAPI** — REST API backend
|
|
33
|
+
- **LangChain** — LLM chains and RAG pipeline
|
|
34
|
+
- **SQLModel** — SQLite memory persistence
|
|
35
|
+
- **ChromaDB** — embedded vector store (no server needed)
|
|
36
|
+
- **NVIDIA NIM / OpenAI / Anthropic / Ollama** — LLM providers
|
|
37
|
+
- **Docker** — containerized deployment
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
### Prerequisites
|
|
42
|
+
|
|
43
|
+
- Python 3.12+
|
|
44
|
+
- [Poetry](https://python-poetry.org/)
|
|
45
|
+
|
|
46
|
+
### Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone <your-repo-url>
|
|
50
|
+
cd projectmind
|
|
51
|
+
poetry install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Configure
|
|
55
|
+
|
|
56
|
+
Copy `.env.local` and fill in your keys:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# LLM (NVIDIA NIM recommended — access to 50+ models)
|
|
60
|
+
API_URL=https://integrate.api.nvidia.com/v1
|
|
61
|
+
API_KEY=your-nvidia-api-key
|
|
62
|
+
CODE_MODEL=meta/llama-3.1-70b-instruct
|
|
63
|
+
CONVERSATION_MODEL=meta/llama-3.1-8b-instruct
|
|
64
|
+
LLM_PROVIDER=nvidia
|
|
65
|
+
|
|
66
|
+
# GitLab (only needed for MR reviewer)
|
|
67
|
+
GIT_TOKEN=your-gitlab-personal-access-token
|
|
68
|
+
GIT_BASE_URL=https://gitlab.com
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Initialize a project
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Analyze your project and build the .projectmind/ memory directory
|
|
75
|
+
projectmind init /path/to/your/project
|
|
76
|
+
|
|
77
|
+
# With LLM-enhanced architectural summary
|
|
78
|
+
projectmind init /path/to/your/project --llm --provider nvidia
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Run static analysis
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
projectmind analyze /path/to/your/project
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Output: circular dependencies, dead code, duplicate functions, security issues, health score.
|
|
88
|
+
|
|
89
|
+
### Compress context
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Get a token-efficient JSON summary of your project (no LLM needed)
|
|
93
|
+
projectmind compress /path/to/your/project
|
|
94
|
+
|
|
95
|
+
# With budget and text preview
|
|
96
|
+
projectmind compress /path/to/your/project --budget 6000 --show-text
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Generate an agent prompt
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
projectmind generate-prompt /path/to/your/project --task "add JWT authentication to the API"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Outputs a context-enriched prompt ready to paste into any AI coding agent.
|
|
106
|
+
|
|
107
|
+
### Manage memory
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# List stored memories
|
|
111
|
+
projectmind memory list /path/to/your/project
|
|
112
|
+
|
|
113
|
+
# Record a decision
|
|
114
|
+
projectmind memory add-decision /path/to/your/project
|
|
115
|
+
|
|
116
|
+
# Record a known error + fix
|
|
117
|
+
projectmind memory add-error /path/to/your/project
|
|
118
|
+
|
|
119
|
+
# Semantic search across all memories
|
|
120
|
+
projectmind memory search /path/to/your/project --query "authentication pattern"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Start the API server
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
projectmind serve
|
|
127
|
+
# or
|
|
128
|
+
poetry run serve
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
API docs available at `http://localhost:8000/docs`
|
|
132
|
+
|
|
133
|
+
## API Endpoints
|
|
134
|
+
|
|
135
|
+
| Method | Endpoint | Description |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `POST` | `/analyze` | Extract project DNA and initialize `.projectmind/` |
|
|
138
|
+
| `POST` | `/architecture` | Run full static analysis |
|
|
139
|
+
| `POST` | `/compress` | Compress project context to token-efficient JSON |
|
|
140
|
+
| `POST` | `/prompt/generate` | Generate context-enriched agent prompt |
|
|
141
|
+
| `GET/POST` | `/memory/tasks` | Task memory CRUD |
|
|
142
|
+
| `GET/POST` | `/memory/errors` | Known error memory CRUD |
|
|
143
|
+
| `GET/POST` | `/memory/decisions` | Decision memory CRUD |
|
|
144
|
+
| `GET/POST` | `/memory/patterns` | Pattern memory CRUD |
|
|
145
|
+
| `GET` | `/memory/search` | Semantic search across memories |
|
|
146
|
+
| `POST` | `/review` | GitLab MR code review |
|
|
147
|
+
| `GET` | `/health` | Health check |
|
|
148
|
+
|
|
149
|
+
## Docker
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Start API + Redis
|
|
153
|
+
docker compose up --build
|
|
154
|
+
|
|
155
|
+
# API at http://localhost:8000
|
|
156
|
+
# API docs at http://localhost:8000/docs
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Project structure
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
projectmind/
|
|
163
|
+
├── backend/
|
|
164
|
+
│ ├── api/ # FastAPI app and routes
|
|
165
|
+
│ ├── core/
|
|
166
|
+
│ │ ├── analyzer/ # AST parser, dep graph, dead code, security
|
|
167
|
+
│ │ ├── compression/ # Token budget + compressor
|
|
168
|
+
│ │ ├── dna/ # Project DNA extractor + generator
|
|
169
|
+
│ │ ├── memory/ # SQLite + ChromaDB memory store
|
|
170
|
+
│ │ └── prompt/ # Smart prompt generator
|
|
171
|
+
│ ├── git/ # GitLab client
|
|
172
|
+
│ ├── llm/ # LLM provider abstraction + prompts
|
|
173
|
+
│ └── vector/ # Embeddings + vector store
|
|
174
|
+
├── cli/ # Click CLI (projectmind command)
|
|
175
|
+
├── .projectmind/ # Generated per-project memory directory
|
|
176
|
+
│ ├── architecture.md
|
|
177
|
+
│ ├── coding_style.md
|
|
178
|
+
│ ├── decisions.md
|
|
179
|
+
│ ├── memory.db
|
|
180
|
+
│ └── embeddings/
|
|
181
|
+
└── pyproject.toml
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## LLM Providers
|
|
185
|
+
|
|
186
|
+
| Provider | How to use |
|
|
187
|
+
|---|---|
|
|
188
|
+
| **NVIDIA NIM** | Set `LLM_PROVIDER=nvidia`, `API_KEY=nvapi-...` — access to Llama, Mistral, Phi, and more |
|
|
189
|
+
| **OpenAI** | Set `LLM_PROVIDER=openai`, `API_KEY=sk-...` |
|
|
190
|
+
| **Anthropic** | Set `LLM_PROVIDER=anthropic`, `ANTHROPIC_API_KEY=sk-ant-...` |
|
|
191
|
+
| **Ollama** | Set `LLM_PROVIDER=ollama`, `API_URL=http://localhost:11434` — fully local |
|
|
192
|
+
|
|
193
|
+
## Requirements
|
|
194
|
+
|
|
195
|
+
- No LLM key needed for: `init`, `analyze`, `compress`, `generate-prompt` (template mode)
|
|
196
|
+
- LLM key needed for: `--llm` flag on init/generate-prompt, GitLab MR reviewer
|
|
197
|
+
- GitLab token needed for: MR reviewer only
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Multi-agent review graph (LangGraph).
|
|
3
|
+
|
|
4
|
+
Flow:
|
|
5
|
+
START → dispatcher (3 agents in parallel via ThreadPoolExecutor)
|
|
6
|
+
→ synthesizer (merges into unified review)
|
|
7
|
+
→ END
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from functools import lru_cache
|
|
13
|
+
|
|
14
|
+
from langgraph.graph import END, START, StateGraph
|
|
15
|
+
|
|
16
|
+
from backend.agents.nodes import dispatcher_node, synthesizer_node
|
|
17
|
+
from backend.agents.state import ReviewState
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@lru_cache(maxsize=1)
|
|
21
|
+
def build_graph():
|
|
22
|
+
builder = StateGraph(ReviewState)
|
|
23
|
+
|
|
24
|
+
builder.add_node("dispatcher", dispatcher_node)
|
|
25
|
+
builder.add_node("synthesizer", synthesizer_node)
|
|
26
|
+
|
|
27
|
+
builder.add_edge(START, "dispatcher")
|
|
28
|
+
builder.add_edge("dispatcher", "synthesizer")
|
|
29
|
+
builder.add_edge("synthesizer", END)
|
|
30
|
+
|
|
31
|
+
return builder.compile()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def run_review(
|
|
35
|
+
diff: str,
|
|
36
|
+
project_context: str = "",
|
|
37
|
+
pr_info: dict | None = None,
|
|
38
|
+
llm_provider: str = "openai",
|
|
39
|
+
api_key: str = "",
|
|
40
|
+
model_name: str = "gpt-4o-mini",
|
|
41
|
+
) -> dict:
|
|
42
|
+
"""
|
|
43
|
+
Convenience wrapper — runs the full multi-agent review synchronously.
|
|
44
|
+
|
|
45
|
+
Returns the final ReviewState dict with keys:
|
|
46
|
+
architect_review, security_review, quality_review, final_review, errors
|
|
47
|
+
"""
|
|
48
|
+
graph = build_graph()
|
|
49
|
+
initial: ReviewState = {
|
|
50
|
+
"diff": diff,
|
|
51
|
+
"pr_info": pr_info or {},
|
|
52
|
+
"project_context": project_context,
|
|
53
|
+
"llm_provider": llm_provider,
|
|
54
|
+
"api_key": api_key,
|
|
55
|
+
"model_name": model_name,
|
|
56
|
+
"architect_review": "",
|
|
57
|
+
"security_review": "",
|
|
58
|
+
"quality_review": "",
|
|
59
|
+
"final_review": "",
|
|
60
|
+
"errors": [],
|
|
61
|
+
}
|
|
62
|
+
return graph.invoke(initial)
|