nexus-dev 3.3.1__py3-none-any.whl

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.
Files changed (48) hide show
  1. nexus_dev/__init__.py +4 -0
  2. nexus_dev/agent_templates/__init__.py +26 -0
  3. nexus_dev/agent_templates/api_designer.yaml +26 -0
  4. nexus_dev/agent_templates/code_reviewer.yaml +26 -0
  5. nexus_dev/agent_templates/debug_detective.yaml +26 -0
  6. nexus_dev/agent_templates/doc_writer.yaml +26 -0
  7. nexus_dev/agent_templates/performance_optimizer.yaml +26 -0
  8. nexus_dev/agent_templates/refactor_architect.yaml +26 -0
  9. nexus_dev/agent_templates/security_auditor.yaml +26 -0
  10. nexus_dev/agent_templates/test_engineer.yaml +26 -0
  11. nexus_dev/agents/__init__.py +20 -0
  12. nexus_dev/agents/agent_config.py +97 -0
  13. nexus_dev/agents/agent_executor.py +197 -0
  14. nexus_dev/agents/agent_manager.py +104 -0
  15. nexus_dev/agents/prompt_factory.py +91 -0
  16. nexus_dev/chunkers/__init__.py +168 -0
  17. nexus_dev/chunkers/base.py +202 -0
  18. nexus_dev/chunkers/docs_chunker.py +291 -0
  19. nexus_dev/chunkers/java_chunker.py +343 -0
  20. nexus_dev/chunkers/javascript_chunker.py +312 -0
  21. nexus_dev/chunkers/python_chunker.py +308 -0
  22. nexus_dev/cli.py +2017 -0
  23. nexus_dev/config.py +261 -0
  24. nexus_dev/database.py +569 -0
  25. nexus_dev/embeddings.py +703 -0
  26. nexus_dev/gateway/__init__.py +10 -0
  27. nexus_dev/gateway/connection_manager.py +348 -0
  28. nexus_dev/github_importer.py +247 -0
  29. nexus_dev/mcp_client.py +281 -0
  30. nexus_dev/mcp_config.py +184 -0
  31. nexus_dev/schemas/mcp_config_schema.json +166 -0
  32. nexus_dev/server.py +1866 -0
  33. nexus_dev/templates/pre-commit-hook +56 -0
  34. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/__init__.py +26 -0
  35. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/api_designer.yaml +26 -0
  36. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/code_reviewer.yaml +26 -0
  37. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/debug_detective.yaml +26 -0
  38. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/doc_writer.yaml +26 -0
  39. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/performance_optimizer.yaml +26 -0
  40. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/refactor_architect.yaml +26 -0
  41. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/security_auditor.yaml +26 -0
  42. nexus_dev-3.3.1.data/data/nexus_dev/agent_templates/test_engineer.yaml +26 -0
  43. nexus_dev-3.3.1.data/data/nexus_dev/templates/pre-commit-hook +56 -0
  44. nexus_dev-3.3.1.dist-info/METADATA +668 -0
  45. nexus_dev-3.3.1.dist-info/RECORD +48 -0
  46. nexus_dev-3.3.1.dist-info/WHEEL +4 -0
  47. nexus_dev-3.3.1.dist-info/entry_points.txt +14 -0
  48. nexus_dev-3.3.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,668 @@
1
+ Metadata-Version: 2.4
2
+ Name: nexus-dev
3
+ Version: 3.3.1
4
+ Summary: MCP server for persistent AI coding assistant memory with local RAG
5
+ Project-URL: Homepage, https://github.com/mmornati/nexus-dev
6
+ Project-URL: Repository, https://github.com/mmornati/nexus-dev
7
+ Project-URL: Issues, https://github.com/mmornati/nexus-dev/issues
8
+ Author-email: Marco Mornati <marco@mornati.net>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,assistant,coding,lancedb,mcp,rag,vector-database
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.13
18
+ Requires-Dist: click>=8.1.0
19
+ Requires-Dist: httpx>=0.28.0
20
+ Requires-Dist: jsonschema>=4.18.0
21
+ Requires-Dist: lancedb>=0.26.0
22
+ Requires-Dist: mcp>=1.25.0
23
+ Requires-Dist: openai>=1.60.0
24
+ Requires-Dist: pandas>=2.0.0
25
+ Requires-Dist: pyarrow>=18.0.0
26
+ Requires-Dist: pydantic>=2.10.0
27
+ Requires-Dist: pyyaml>=6.0.0
28
+ Requires-Dist: tree-sitter-language-pack>=0.7.0
29
+ Requires-Dist: tree-sitter>=0.24.0
30
+ Provides-Extra: all
31
+ Requires-Dist: boto3>=1.34.0; extra == 'all'
32
+ Requires-Dist: cohere>=4.37.0; extra == 'all'
33
+ Requires-Dist: google-cloud-aiplatform>=1.38.0; extra == 'all'
34
+ Requires-Dist: voyageai>=0.1.0; extra == 'all'
35
+ Provides-Extra: aws
36
+ Requires-Dist: boto3>=1.34.0; extra == 'aws'
37
+ Provides-Extra: cohere
38
+ Requires-Dist: cohere>=4.37.0; extra == 'cohere'
39
+ Provides-Extra: dev
40
+ Requires-Dist: mypy>=1.14.0; extra == 'dev'
41
+ Requires-Dist: pytest-asyncio>=0.25.0; extra == 'dev'
42
+ Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
43
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
44
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'
45
+ Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
46
+ Provides-Extra: google
47
+ Requires-Dist: google-cloud-aiplatform>=1.38.0; extra == 'google'
48
+ Provides-Extra: voyage
49
+ Requires-Dist: voyageai>=0.1.0; extra == 'voyage'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # Nexus-Dev
53
+
54
+ [![CI](https://github.com/mmornati/nexus-dev/actions/workflows/ci.yml/badge.svg)](https://github.com/mmornati/nexus-dev/actions/workflows/ci.yml)
55
+ [![codecov](https://codecov.io/gh/mmornati/nexus-dev/graph/badge.svg)](https://codecov.io/gh/mmornati/nexus-dev)
56
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
57
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
58
+ [![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
59
+
60
+ **Persistent Memory for AI Coding Agents**
61
+
62
+ Nexus-Dev is an open-source MCP (Model Context Protocol) server that provides a local RAG (Retrieval-Augmented Generation) system for AI coding assistants like GitHub Copilot, Cursor, and Windsurf. It learns from your codebase and mistakes, enabling cross-project knowledge sharing.
63
+
64
+ ## Features
65
+
66
+ - 🧠 **Persistent Memory**: Index your code and documentation for semantic search
67
+ - 📚 **Lesson Learning**: Record problems and solutions that the AI can recall later
68
+ - 🐙 **GitHub Integration**: Import Issues and Pull Requests into your knowledge base (see [docs/github-import.md](docs/github-import.md))
69
+ - 🌐 **Multi-Language Support**: Python, JavaScript/TypeScript, Java (extensible via tree-sitter)
70
+ - 📖 **Documentation Indexing**: Parse and index Markdown/RST documentation
71
+ - 🔄 **Cross-Project Learning**: Share knowledge across all your projects
72
+ - 🏠 **Local-First**: All data stays on your machine with LanceDB
73
+
74
+ ## Installation
75
+
76
+ ### Isolated Global Installation (Recommended)
77
+
78
+ To avoid conflicts with project-specific virtual environments, install Nexus-Dev globally using `pipx` or `uv tool`.
79
+
80
+ ```bash
81
+ # Using pipx
82
+ pipx install nexus-dev
83
+
84
+ # Using uv
85
+ uv tool install nexus-dev
86
+ ```
87
+
88
+ ### Development Installation
89
+
90
+ If you are contributing to Nexus-Dev, you can install it in editable mode:
91
+
92
+ ```bash
93
+ # Using pip
94
+ pip install -e .
95
+
96
+ # Using uv
97
+ uv pip install -e .
98
+ ```
99
+
100
+ ## Quick Start
101
+
102
+ ### 1. Initialize a Project
103
+
104
+ ```bash
105
+ cd your-project
106
+ nexus-init --project-name "my-project" --embedding-provider openai
107
+ ```
108
+
109
+ This creates:
110
+ - `nexus_config.json` - Project configuration
111
+ - `.nexus/lessons/` - Directory for learned lessons
112
+
113
+ ### 2. Set Your API Key (OpenAI only)
114
+
115
+ The CLI commands require the API key in your environment:
116
+
117
+ ```bash
118
+ export OPENAI_API_KEY="sk-..."
119
+ ```
120
+
121
+ > **Tip**: Add this to your shell profile (`~/.zshrc`, `~/.bashrc`) so it's always available.
122
+ >
123
+ > If using **Ollama**, no API key is needed—just ensure Ollama is running locally.
124
+
125
+ ### 3. Index Your Code
126
+
127
+ ```bash
128
+ # Index directories recursively (recommended)
129
+ nexus-index src/ -r
130
+
131
+ # Index multiple directories
132
+ nexus-index src/ docs/ -r
133
+
134
+ # Index specific files (no -r needed)
135
+ nexus-index main.py utils.py
136
+ ```
137
+
138
+ > **Note**: The `-r` flag is required to recursively index subdirectories. Without it, only files directly inside the given folder are indexed.
139
+
140
+ ### 4. Configure Your AI Agent
141
+
142
+ Add to your MCP client configuration (e.g., Claude Desktop):
143
+
144
+ ```json
145
+ {
146
+ "mcpServers": {
147
+ "nexus-dev": {
148
+ "command": "nexus-dev",
149
+ "args": []
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ ### 5. Verify Your Setup
156
+
157
+ **Check indexed content** via CLI:
158
+ ```bash
159
+ nexus-status
160
+ ```
161
+
162
+ **Test in your AI agent** — copy and paste this prompt:
163
+
164
+ ```
165
+ Search the Nexus-Dev knowledge base for functions related to "embeddings"
166
+ and show me the project statistics.
167
+ ```
168
+
169
+ If the AI uses the `search_code` or `get_project_context` tools and returns results, your setup is complete! 🎉
170
+
171
+ ## MCP Tools
172
+
173
+ Nexus-Dev exposes 7 tools to AI agents:
174
+
175
+ ### Search Tools
176
+
177
+ | Tool | Description |
178
+ |------|-------------|
179
+ | `search_knowledge` | Search all content (code, docs, lessons) with optional `content_type` filter |
180
+ | `search_code` | Search specifically in indexed code (functions, classes, methods) |
181
+ | `search_docs` | Search specifically in documentation (Markdown, RST, text) |
182
+ | `search_lessons` | Search in recorded lessons (problems & solutions) |
183
+
184
+ ### Indexing Tools
185
+
186
+ | Tool | Description |
187
+ |------|-------------|
188
+ | `index_file` | Index a file into the knowledge base |
189
+ | `record_lesson` | Store a problem/solution pair for future reference |
190
+ | `get_project_context` | Get project statistics and recent lessons |
191
+
192
+ ## MCP Gateway Mode
193
+
194
+ Nexus-Dev can act as a gateway to other MCP servers, reducing tool count for AI agents.
195
+
196
+ ### Setup
197
+
198
+ 1. Initialize MCP configuration:
199
+ ```bash
200
+ nexus-mcp init --from-global
201
+ ```
202
+
203
+ 2. Index tools from configured servers:
204
+ ```bash
205
+ nexus-index-mcp --all
206
+ ```
207
+
208
+ ### Usage
209
+
210
+ Instead of configuring 10 MCP servers (50+ tools), configure only Nexus-Dev:
211
+
212
+ ```json
213
+ {
214
+ "mcpServers": {
215
+ "nexus-dev": {
216
+ "command": "nexus-dev"
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ AI uses these Nexus-Dev tools to access other servers:
223
+
224
+ | Tool | Description |
225
+ |------|-------------|
226
+ | `search_tools` | Find the right tool for a task |
227
+ | `invoke_tool` | Execute a tool on any configured server |
228
+ | `list_servers` | Show available MCP servers |
229
+
230
+ ### Workflow
231
+
232
+ 1. AI searches: `search_tools("create GitHub issue")`
233
+ 2. Nexus-Dev returns: `github.create_issue` with schema
234
+ 3. AI invokes: `invoke_tool("github", "create_issue", {...})`
235
+ 4. Nexus-Dev proxies to GitHub MCP
236
+
237
+ ### Server Configuration
238
+
239
+ You can configure downstream MCP servers in `.nexus/mcp_config.json` using either **Stdio** (local process) or **SSE** (HTTP remote) transports.
240
+
241
+ **Local Server (Stdio):**
242
+ ```json
243
+ {
244
+ "servers": {
245
+ "github-local": {
246
+ "transport": "stdio",
247
+ "command": "npx",
248
+ "args": ["-y", "@modelcontextprotocol/server-github"],
249
+ "env": {
250
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "..."
251
+ }
252
+ }
253
+ }
254
+ }
255
+ ```
256
+
257
+ **Remote Server (SSE):**
258
+ ```json
259
+ {
260
+ "servers": {
261
+ "github-remote": {
262
+ "transport": "sse",
263
+ "url": "https://api.githubcopilot.com/mcp/",
264
+ "headers": {
265
+ "Authorization": "Bearer ..."
266
+ }
267
+ }
268
+ }
269
+ }
270
+ ```
271
+
272
+ ## Configuration
273
+
274
+ `nexus_config.json` example:
275
+
276
+ ```json
277
+ {
278
+ "project_id": "550e8400-e29b-41d4-a716-446655440000",
279
+ "project_name": "my-project",
280
+ "embedding_provider": "openai",
281
+ "embedding_model": "text-embedding-3-small",
282
+ "docs_folders": ["docs/", "README.md"],
283
+ "include_patterns": ["**/*.py", "**/*.js", "**/*.java"],
284
+ "exclude_patterns": ["**/node_modules/**", "**/__pycache__/**"]
285
+ }
286
+ ```
287
+
288
+ ### Project Context & Startup
289
+
290
+ Nexus-Dev needs to know *which* project to load on startup. It determines this in two ways:
291
+
292
+ 1. **Automatic Detection (Recommended)**: If the MCP server process is started with your project root as its **current working directory (cwd)**, it automatically loads `nexus_config.json` and `.nexus/mcp_config.json`.
293
+ 2. **Environment Variable**: Setting `NEXUS_PROJECT_ROOT=/path/to/project` explicitly tells the server where to look.
294
+
295
+ **When to use `refresh_agents`:**
296
+ If the server starts in a generic location (like a global Docker container or default system path) without a project context, it starts "empty". You must then use the `refresh_agents` tool. This tool asks your IDE for the active workspace path and re-initializes the server with that context.
297
+
298
+ > **Pro Tip**: Configure your MCP client (Cursor, Claude Desktop) to set `cwd` or `NEXUS_PROJECT_ROOT` to your project path. This matches the server's lifecycle to your open project and avoids the need for manual refreshing.
299
+ ```
300
+
301
+ 📖 See [docs/adding-mcp-servers.md](docs/adding-mcp-servers.md) for a guide on adding custom MCP servers.
302
+
303
+ ### Supported Embedding Providers
304
+
305
+ Nexus-Dev supports multiple embedding providers. Choose the one that best fits your needs.
306
+
307
+ #### 1. OpenAI (Default)
308
+ - **Best for:** General purpose, ease of use.
309
+ - **Provider:** `openai`
310
+ - **Default Model:** `text-embedding-3-small`
311
+ - **Configuration:**
312
+ ```json
313
+ {
314
+ "embedding_provider": "openai",
315
+ "embedding_model": "text-embedding-3-small"
316
+ }
317
+ ```
318
+ - **Environment:** Set `OPENAI_API_KEY`.
319
+
320
+ #### 2. Local Ollama (Privacy / Offline)
321
+ - **Best for:** Privacy, local execution, cost savings.
322
+ - **Provider:** `ollama`
323
+ - **Default Model:** `nomic-embed-text`
324
+ - **Configuration:**
325
+ ```json
326
+ {
327
+ "embedding_provider": "ollama",
328
+ "embedding_model": "nomic-embed-text",
329
+ "ollama_url": "http://localhost:11434"
330
+ }
331
+ ```
332
+
333
+ #### 3. Google Vertex AI (Enterprise)
334
+ - **Best for:** Enterprise GCP users, high scalability.
335
+ - **Provider:** `google`
336
+ - **Install:** `pip install nexus-dev[google]`
337
+ - **Default Model:** `text-embedding-004`
338
+ - **Configuration:**
339
+ ```json
340
+ {
341
+ "embedding_provider": "google",
342
+ "google_project_id": "your-project-id",
343
+ "google_location": "us-central1"
344
+ }
345
+ ```
346
+ - **Environment:** Uses standard Google Cloud credentials (ADC).
347
+
348
+ #### 4. AWS Bedrock (Enterprise)
349
+ - **Best for:** Enterprise AWS users.
350
+ - **Provider:** `aws`
351
+ - **Install:** `pip install nexus-dev[aws]`
352
+ - **Default Model:** `amazon.titan-embed-text-v1`
353
+ - **Configuration:**
354
+ ```json
355
+ {
356
+ "embedding_provider": "aws",
357
+ "aws_region": "us-east-1"
358
+ }
359
+ ```
360
+
361
+ #### 5. Voyage AI (High Performance)
362
+ - **Best for:** State-of-the-art retrieval quality (RAG specialist).
363
+ - **Provider:** `voyage`
364
+ - **Install:** `pip install nexus-dev[voyage]`
365
+ - **Default Model:** `voyage-large-2`
366
+ - **Configuration:**
367
+ ```json
368
+ {
369
+ "embedding_provider": "voyage",
370
+ "voyage_api_key": "your-key"
371
+ }
372
+ ```
373
+
374
+ #### 6. Cohere (Multilingual)
375
+ - **Best for:** Multilingual search and reranking.
376
+ - **Provider:** `cohere`
377
+ - **Install:** `pip install nexus-dev[cohere]`
378
+ - **Default Model:** `embed-multilingual-v3.0`
379
+ - **Configuration:**
380
+ ```json
381
+ {
382
+ "embedding_provider": "cohere",
383
+ "cohere_api_key": "your-key"
384
+ }
385
+ ```
386
+
387
+ > ⚠️ **Warning**: Embeddings are NOT portable between providers. Changing providers requires re-indexing all documents.
388
+
389
+ ## Optional: Pre-commit Hook
390
+
391
+ Install automatic indexing on commits:
392
+
393
+ ```bash
394
+ nexus-init --project-name "my-project" --install-hook
395
+ ```
396
+
397
+ Or manually add to `.git/hooks/pre-commit`:
398
+
399
+ ```bash
400
+ #!/bin/bash
401
+ MODIFIED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(py|js|ts|java)$')
402
+ if [ -n "$MODIFIED" ]; then
403
+ nexus-index $MODIFIED
404
+ fi
405
+ ```
406
+
407
+ ## Multi-Repository Projects
408
+
409
+ Nexus-Dev supports multi-repository setups where a parent folder contains the nexus configuration and multiple sub-folders contain independent git repositories.
410
+
411
+ ### Quick Setup
412
+
413
+ ```bash
414
+ # Initialize parent project
415
+ cd /path/to/parent-project
416
+ nexus-init --project-name "My Multi-Repo Project"
417
+
418
+ # Install hooks in all sub-repositories
419
+ nexus-init --discover-repos
420
+ ```
421
+
422
+ Or install hooks manually in each repository:
423
+
424
+ ```bash
425
+ cd sub-repo-1
426
+ nexus-init --link-hook
427
+
428
+ cd ../sub-repo-2
429
+ nexus-init --link-hook
430
+ ```
431
+
432
+ All repositories:
433
+ - Share a single project ID and knowledge base
434
+ - Index to the parent project's database
435
+ - Store lessons centrally in parent `.nexus/lessons/`
436
+
437
+ 📖 See [Multi-Repository Projects](docs/advanced/multi-repo-projects.md) for detailed guide.
438
+
439
+ ## Configuring AI Agents
440
+
441
+ To maximize Nexus-Dev's value, configure your AI coding assistant to use its tools automatically.
442
+
443
+ ### Add AGENTS.md to Your Project
444
+
445
+ Copy our template to your project:
446
+
447
+ ```bash
448
+ cp path/to/nexus-dev/docs/AGENTS_TEMPLATE.md your-project/AGENTS.md
449
+ ```
450
+
451
+ This instructs AI agents to:
452
+ - **Search first** before implementing features
453
+ - **Record lessons** after solving bugs
454
+ - Use `get_project_context()` at session start
455
+
456
+ ### Add Workflow Files (Optional)
457
+
458
+ ```bash
459
+ cp -r path/to/nexus-dev/.agent/workflows your-project/.agent/
460
+ ```
461
+
462
+ This adds slash commands: `/start-session`, `/search-first`, `/record-lesson`, `/index-code`
463
+
464
+ 📖 See [docs/configuring-agents.md](docs/configuring-agents.md) for detailed setup instructions.
465
+
466
+ ## Architecture
467
+
468
+ ```mermaid
469
+ flowchart TB
470
+ subgraph Agent["🤖 AI Agent"]
471
+ direction TB
472
+ Cursor["Cursor / Copilot / Windsurf"]
473
+ end
474
+
475
+ subgraph MCP["📡 Nexus-Dev (Gateway)"]
476
+ direction TB
477
+
478
+ subgraph Tools["MCP Tools"]
479
+ direction TB
480
+ search_knowledge["search_knowledge"]
481
+ search_code["search_code"]
482
+ search_docs["search_docs"]
483
+ index_file["index_file"]
484
+ gateway_tools["gateway_tools (new)"]
485
+ end
486
+
487
+ subgraph Chunkers["🔧 RAG Pipeline"]
488
+ Python["Chunkers"]
489
+ Embeddings["Embeddings"]
490
+ DB["LanceDB"]
491
+ end
492
+ end
493
+
494
+ subgraph External["🌍 External MCP Servers"]
495
+ GH["GitHub"]
496
+ PG["PostgreSQL"]
497
+ Other["..."]
498
+ end
499
+
500
+ Agent -->|"stdio"| Tools
501
+ Tools --> Chunkers
502
+ gateway_tools -.->|"invoke_tool"| External
503
+ ```
504
+
505
+ ### Data Flow
506
+
507
+ ```mermaid
508
+ sequenceDiagram
509
+ participant AI as AI Agent
510
+ participant MCP as Nexus-Dev
511
+ participant Embed as Embeddings
512
+ participant DB as LanceDB
513
+
514
+ Note over AI,DB: Indexing Flow
515
+ AI->>MCP: index_file(path)
516
+ MCP->>MCP: Parse with Chunker
517
+ MCP->>Embed: Generate embeddings
518
+ Embed-->>MCP: Vectors
519
+ MCP->>DB: Store chunks + vectors
520
+ DB-->>MCP: OK
521
+ MCP-->>AI: ✅ Indexed
522
+
523
+ Note over AI,DB: Search Flow
524
+ AI->>MCP: search_knowledge(query)
525
+ MCP->>Embed: Embed query
526
+ Embed-->>MCP: Query vector
527
+ MCP->>DB: Vector similarity search
528
+ DB-->>MCP: Results
529
+ MCP-->>AI: Formatted results
530
+ ```
531
+
532
+ ## Development Setup
533
+
534
+ Since Nexus-Dev is not yet published to PyPI/Docker Hub, developers must build from source.
535
+
536
+ ### Option 1: Local Python Installation (Recommended for Development)
537
+
538
+ ```bash
539
+ # Clone repository
540
+ git clone https://github.com/mmornati/nexus-dev.git
541
+ cd nexus-dev
542
+
543
+ # Option A: Use the Makefile (handles pyenv + venv)
544
+ make setup
545
+ source .venv/bin/activate
546
+
547
+ # Option B: Manual setup
548
+ pyenv install 3.13 # or use your preferred Python 3.13+ manager
549
+ python3 -m venv .venv
550
+ source .venv/bin/activate
551
+ pip install -e ".[dev]" # Editable install with dev dependencies
552
+ ```
553
+
554
+ After installation, CLI commands are available:
555
+
556
+ ```bash
557
+ nexus-init --help # Initialize a project
558
+ nexus-index --help # Index files
559
+ nexus-dev # Run MCP server
560
+ ```
561
+
562
+ ### Option 2: Docker Build
563
+
564
+ ```bash
565
+ # Build the image
566
+ make docker-build
567
+ # or: docker build -t nexus-dev:latest .
568
+
569
+ # Run with volume mounts
570
+ docker run -it --rm \
571
+ -v /path/to/your-project:/workspace:ro \
572
+ -v nexus-dev-data:/data/nexus-dev \
573
+ -e OPENAI_API_KEY=$OPENAI_API_KEY \
574
+ nexus-dev:latest
575
+
576
+ # Or use Makefile shortcuts
577
+ make docker-run # Run container
578
+ make docker-logs # View logs
579
+ make docker-stop # Stop container
580
+ ```
581
+
582
+ ### Makefile Commands
583
+
584
+ | Command | Description |
585
+ |---------|-------------|
586
+ | `make setup` | Full dev environment setup (pyenv + venv + deps) |
587
+ | `make install-dev` | Install package with dev dependencies |
588
+ | `make lint` | Run ruff linter |
589
+ | `make format` | Format code + auto-fix lint issues |
590
+ | `make check` | Run all CI checks (lint + format + type-check) |
591
+ | `make test` | Run tests |
592
+ | `make test-cov` | Run tests with coverage report |
593
+ | `make docker-build` | Build Docker image |
594
+ | `make docker-run` | Run Docker container |
595
+ | `make help` | Show all available commands |
596
+
597
+ ### MCP Configuration (Development Mode)
598
+
599
+ Configure your AI agent to use the locally-built server. **This single configuration works for ALL your indexed projects!**
600
+
601
+ **For Claude Desktop / Cursor / Windsurf:**
602
+
603
+ ```json
604
+ {
605
+ "mcpServers": {
606
+ "nexus-dev": {
607
+ "command": "/path/to/nexus-dev/.venv/bin/python",
608
+ "args": ["-m", "nexus_dev.server"],
609
+ "env": {
610
+ "OPENAI_API_KEY": "sk-..."
611
+ }
612
+ }
613
+ }
614
+ }
615
+ ```
616
+
617
+ > **How it works**: The server now defaults to searching **all indexed projects** when no specific project context is active. You don't need to configure `cwd` or create separate MCP entries for each project.
618
+
619
+ > **Tip**: If `OPENAI_API_KEY` is already in your shell profile (`.zshrc`, `.bashrc`), some clients inherit it automatically. Check your client's documentation.
620
+
621
+ **Using Docker:**
622
+
623
+ The `/workspace` mount is the server's working directory. It looks for `nexus_config.json` and `.nexus/lessons/` there. Mount your project (or parent directory) to `/workspace`:
624
+
625
+ ```json
626
+ {
627
+ "mcpServers": {
628
+ "nexus-dev": {
629
+ "command": "docker",
630
+ "args": [
631
+ "run", "-i", "--rm",
632
+ "-v", "/path/to/project:/workspace:ro",
633
+ "-v", "nexus-dev-data:/data/nexus-dev",
634
+ "-e", "OPENAI_API_KEY",
635
+ "nexus-dev:latest"
636
+ ]
637
+ }
638
+ }
639
+ }
640
+ ```
641
+
642
+ **Multi-Project Setup:**
643
+
644
+ For multiple projects, you have two options:
645
+
646
+ 1. **Mount parent directory** containing all projects:
647
+ ```json
648
+ "-v", "/Users/you/Projects:/workspace:ro"
649
+ ```
650
+ Then index paths like `/workspace/project-a/src/`, `/workspace/project-b/src/`. Each project needs its own `nexus_config.json` with a unique `project_id`.
651
+
652
+ 2. **Use local Python install** (recommended): MCP clients automatically set the working directory to the project root, so no path configuration is needed.
653
+
654
+ ### Running Tests
655
+
656
+ ```bash
657
+ make test # Run all tests
658
+ make test-cov # Run with coverage report
659
+ pytest tests/unit/ -v # Run specific test directory
660
+ ```
661
+
662
+ ## Adding Language Support
663
+
664
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on adding new language chunkers.
665
+
666
+ ## License
667
+
668
+ MIT License - see [LICENSE](LICENSE) for details.