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