nexus-dev 3.2.0__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.

Potentially problematic release.


This version of nexus-dev might be problematic. Click here for more details.

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 +1673 -0
  23. nexus_dev/config.py +253 -0
  24. nexus_dev/database.py +558 -0
  25. nexus_dev/embeddings.py +585 -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 +33 -0
  34. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/__init__.py +26 -0
  35. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/api_designer.yaml +26 -0
  36. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/code_reviewer.yaml +26 -0
  37. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/debug_detective.yaml +26 -0
  38. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/doc_writer.yaml +26 -0
  39. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/performance_optimizer.yaml +26 -0
  40. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/refactor_architect.yaml +26 -0
  41. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/security_auditor.yaml +26 -0
  42. nexus_dev-3.2.0.data/data/nexus_dev/agent_templates/test_engineer.yaml +26 -0
  43. nexus_dev-3.2.0.data/data/nexus_dev/templates/pre-commit-hook +33 -0
  44. nexus_dev-3.2.0.dist-info/METADATA +636 -0
  45. nexus_dev-3.2.0.dist-info/RECORD +48 -0
  46. nexus_dev-3.2.0.dist-info/WHEEL +4 -0
  47. nexus_dev-3.2.0.dist-info/entry_points.txt +12 -0
  48. nexus_dev-3.2.0.dist-info/licenses/LICENSE +21 -0
nexus_dev/config.py ADDED
@@ -0,0 +1,253 @@
1
+ """Configuration management for Nexus-Dev."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import uuid
8
+ from dataclasses import dataclass, field
9
+ from pathlib import Path
10
+ from typing import Literal
11
+
12
+
13
+ @dataclass
14
+ class NexusConfig:
15
+ """Nexus-Dev project configuration.
16
+
17
+ Attributes:
18
+ project_id: Unique identifier for the project (UUID).
19
+ project_name: Human-readable project name.
20
+ embedding_provider: Embedding provider to use ("openai" or "ollama").
21
+ embedding_model: Model name for embeddings.
22
+ ollama_url: URL for local Ollama server.
23
+ db_path: Path to LanceDB database directory.
24
+ include_patterns: Glob patterns for files to index.
25
+ exclude_patterns: Glob patterns for files to exclude.
26
+ docs_folders: Folders containing documentation to index.
27
+ """
28
+
29
+ project_id: str
30
+ project_name: str
31
+ embedding_provider: Literal["openai", "ollama", "google", "aws", "voyage", "cohere"] = "openai"
32
+ embedding_model: str = "text-embedding-3-small"
33
+ ollama_url: str = "http://localhost:11434"
34
+ # Google Vertex AI configuration
35
+ google_project_id: str | None = None
36
+ google_location: str | None = None
37
+ # AWS Bedrock configuration
38
+ aws_region: str | None = None
39
+ aws_access_key_id: str | None = None
40
+ aws_secret_access_key: str | None = None
41
+ # Voyage AI configuration
42
+ voyage_api_key: str | None = None
43
+ # Cohere configuration
44
+ cohere_api_key: str | None = None
45
+ db_path: str = "~/.nexus-dev/db"
46
+ include_patterns: list[str] = field(
47
+ default_factory=lambda: ["**/*.py", "**/*.js", "**/*.ts", "**/*.java"]
48
+ )
49
+ exclude_patterns: list[str] = field(
50
+ default_factory=lambda: [
51
+ "**/node_modules/**",
52
+ "**/.venv/**",
53
+ "**/venv/**",
54
+ "**/__pycache__/**",
55
+ "**/dist/**",
56
+ "**/build/**",
57
+ "**/.git/**",
58
+ "**/.next/**",
59
+ ]
60
+ )
61
+ docs_folders: list[str] = field(
62
+ default_factory=lambda: ["docs/", "documentation/", "README.md"]
63
+ )
64
+
65
+ @classmethod
66
+ def create_new(
67
+ cls,
68
+ project_name: str,
69
+ embedding_provider: Literal[
70
+ "openai", "ollama", "google", "aws", "voyage", "cohere"
71
+ ] = "openai",
72
+ embedding_model: str | None = None,
73
+ ) -> NexusConfig:
74
+ """Create a new configuration with a generated project ID.
75
+
76
+ Args:
77
+ project_name: Human-readable project name.
78
+ embedding_provider: Embedding provider to use.
79
+ embedding_model: Optional model override.
80
+
81
+ Returns:
82
+ New NexusConfig instance.
83
+ """
84
+ # Default model based on provider
85
+ if embedding_model is None:
86
+ embedding_model = (
87
+ "text-embedding-3-small" if embedding_provider == "openai" else "nomic-embed-text"
88
+ )
89
+
90
+ # Set default models for other providers if not specified
91
+ if embedding_model is None:
92
+ defaults = {
93
+ "google": "text-embedding-004",
94
+ "aws": "amazon.titan-embed-text-v1",
95
+ "voyage": "voyage-large-2",
96
+ "cohere": "embed-multilingual-v3.0",
97
+ }
98
+ embedding_model = defaults.get(embedding_provider, embedding_model)
99
+
100
+ return cls(
101
+ project_id=str(uuid.uuid4()),
102
+ project_name=project_name,
103
+ embedding_provider=embedding_provider,
104
+ embedding_model=embedding_model,
105
+ )
106
+
107
+ @classmethod
108
+ def load(cls, path: str | Path = "nexus_config.json") -> NexusConfig:
109
+ """Load configuration from a JSON file.
110
+
111
+ Args:
112
+ path: Path to the configuration file.
113
+
114
+ Returns:
115
+ Loaded NexusConfig instance.
116
+
117
+ Raises:
118
+ FileNotFoundError: If config file doesn't exist.
119
+ ValueError: If config is invalid.
120
+ """
121
+ path = Path(path)
122
+ if not path.exists():
123
+ raise FileNotFoundError(f"Configuration file not found: {path}")
124
+
125
+ with open(path, encoding="utf-8") as f:
126
+ data = json.load(f)
127
+
128
+ # Validate required fields
129
+ if "project_id" not in data:
130
+ raise ValueError("Missing required field: project_id")
131
+ if "project_name" not in data:
132
+ raise ValueError("Missing required field: project_name")
133
+
134
+ return cls(
135
+ project_id=data["project_id"],
136
+ project_name=data["project_name"],
137
+ embedding_provider=data.get("embedding_provider", "openai"),
138
+ embedding_model=data.get("embedding_model", "text-embedding-3-small"),
139
+ ollama_url=data.get("ollama_url", "http://localhost:11434"),
140
+ google_project_id=data.get("google_project_id"),
141
+ google_location=data.get("google_location"),
142
+ aws_region=data.get("aws_region"),
143
+ aws_access_key_id=data.get("aws_access_key_id"),
144
+ aws_secret_access_key=data.get("aws_secret_access_key"),
145
+ voyage_api_key=data.get("voyage_api_key"),
146
+ cohere_api_key=data.get("cohere_api_key"),
147
+ db_path=data.get("db_path", "~/.nexus-dev/db"),
148
+ include_patterns=data.get(
149
+ "include_patterns", ["**/*.py", "**/*.js", "**/*.ts", "**/*.java"]
150
+ ),
151
+ exclude_patterns=data.get(
152
+ "exclude_patterns",
153
+ [
154
+ "**/node_modules/**",
155
+ "**/.venv/**",
156
+ "**/venv/**",
157
+ "**/__pycache__/**",
158
+ ],
159
+ ),
160
+ docs_folders=data.get("docs_folders", ["docs/", "documentation/", "README.md"]),
161
+ )
162
+
163
+ @classmethod
164
+ def load_or_default(cls, path: str | Path = "nexus_config.json") -> NexusConfig | None:
165
+ """Load configuration if it exists, otherwise return None.
166
+
167
+ Args:
168
+ path: Path to the configuration file.
169
+
170
+ Returns:
171
+ NexusConfig instance or None if file doesn't exist.
172
+ """
173
+ try:
174
+ return cls.load(path)
175
+ except FileNotFoundError:
176
+ return None
177
+
178
+ def save(self, path: str | Path = "nexus_config.json") -> None:
179
+ """Save configuration to a JSON file.
180
+
181
+ Args:
182
+ path: Path to save the configuration file.
183
+ """
184
+ path = Path(path)
185
+
186
+ data = {
187
+ "project_id": self.project_id,
188
+ "project_name": self.project_name,
189
+ "embedding_provider": self.embedding_provider,
190
+ "embedding_model": self.embedding_model,
191
+ "ollama_url": self.ollama_url,
192
+ "google_project_id": self.google_project_id,
193
+ "google_location": self.google_location,
194
+ "aws_region": self.aws_region,
195
+ "aws_access_key_id": self.aws_access_key_id,
196
+ "aws_secret_access_key": self.aws_secret_access_key,
197
+ "voyage_api_key": self.voyage_api_key,
198
+ "cohere_api_key": self.cohere_api_key,
199
+ "db_path": self.db_path,
200
+ "include_patterns": self.include_patterns,
201
+ "exclude_patterns": self.exclude_patterns,
202
+ "docs_folders": self.docs_folders,
203
+ }
204
+
205
+ with open(path, "w", encoding="utf-8") as f:
206
+ json.dump(data, f, indent=2)
207
+
208
+ def get_db_path(self) -> Path:
209
+ """Get the expanded database path.
210
+
211
+ Returns:
212
+ Expanded Path to the database directory.
213
+ """
214
+ # Expand ~ and environment variables
215
+ expanded = os.path.expanduser(self.db_path)
216
+ expanded = os.path.expandvars(expanded)
217
+ return Path(expanded)
218
+
219
+ def get_embedding_dimensions(self) -> int:
220
+ """Get the embedding dimensions for the configured model.
221
+
222
+ Returns:
223
+ Number of dimensions for the embedding model.
224
+ """
225
+ # Known dimensions for common models
226
+ dimensions_map = {
227
+ # OpenAI
228
+ "text-embedding-3-small": 1536,
229
+ "text-embedding-3-large": 3072,
230
+ "text-embedding-ada-002": 1536,
231
+ # Ollama
232
+ "nomic-embed-text": 768,
233
+ "mxbai-embed-large": 1024,
234
+ "all-minilm": 384,
235
+ # Google
236
+ "text-embedding-004": 768,
237
+ "text-multilingual-embedding-002": 768,
238
+ "textembedding-gecko@003": 768,
239
+ "textembedding-gecko-multilingual@001": 768,
240
+ # AWS Bedrock
241
+ "amazon.titan-embed-text-v1": 1536,
242
+ "amazon.titan-embed-text-v2:0": 1024,
243
+ # Voyage
244
+ "voyage-large-2": 1536,
245
+ "voyage-code-2": 1536,
246
+ "voyage-2": 1024,
247
+ # Cohere
248
+ "embed-english-v3.0": 1024,
249
+ "embed-multilingual-v3.0": 1024,
250
+ "embed-english-light-v3.0": 384,
251
+ "embed-multilingual-light-v3.0": 384,
252
+ }
253
+ return dimensions_map.get(self.embedding_model, 1536)