mcp-vector-search 0.12.6__py3-none-any.whl → 1.1.22__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.
- mcp_vector_search/__init__.py +3 -3
- mcp_vector_search/analysis/__init__.py +111 -0
- mcp_vector_search/analysis/baseline/__init__.py +68 -0
- mcp_vector_search/analysis/baseline/comparator.py +462 -0
- mcp_vector_search/analysis/baseline/manager.py +621 -0
- mcp_vector_search/analysis/collectors/__init__.py +74 -0
- mcp_vector_search/analysis/collectors/base.py +164 -0
- mcp_vector_search/analysis/collectors/cohesion.py +463 -0
- mcp_vector_search/analysis/collectors/complexity.py +743 -0
- mcp_vector_search/analysis/collectors/coupling.py +1162 -0
- mcp_vector_search/analysis/collectors/halstead.py +514 -0
- mcp_vector_search/analysis/collectors/smells.py +325 -0
- mcp_vector_search/analysis/debt.py +516 -0
- mcp_vector_search/analysis/interpretation.py +685 -0
- mcp_vector_search/analysis/metrics.py +414 -0
- mcp_vector_search/analysis/reporters/__init__.py +7 -0
- mcp_vector_search/analysis/reporters/console.py +646 -0
- mcp_vector_search/analysis/reporters/markdown.py +480 -0
- mcp_vector_search/analysis/reporters/sarif.py +377 -0
- mcp_vector_search/analysis/storage/__init__.py +93 -0
- mcp_vector_search/analysis/storage/metrics_store.py +762 -0
- mcp_vector_search/analysis/storage/schema.py +245 -0
- mcp_vector_search/analysis/storage/trend_tracker.py +560 -0
- mcp_vector_search/analysis/trends.py +308 -0
- mcp_vector_search/analysis/visualizer/__init__.py +90 -0
- mcp_vector_search/analysis/visualizer/d3_data.py +534 -0
- mcp_vector_search/analysis/visualizer/exporter.py +484 -0
- mcp_vector_search/analysis/visualizer/html_report.py +2895 -0
- mcp_vector_search/analysis/visualizer/schemas.py +525 -0
- mcp_vector_search/cli/commands/analyze.py +1062 -0
- mcp_vector_search/cli/commands/chat.py +1455 -0
- mcp_vector_search/cli/commands/index.py +621 -5
- mcp_vector_search/cli/commands/index_background.py +467 -0
- mcp_vector_search/cli/commands/init.py +13 -0
- mcp_vector_search/cli/commands/install.py +597 -335
- mcp_vector_search/cli/commands/install_old.py +8 -4
- mcp_vector_search/cli/commands/mcp.py +78 -6
- mcp_vector_search/cli/commands/reset.py +68 -26
- mcp_vector_search/cli/commands/search.py +224 -8
- mcp_vector_search/cli/commands/setup.py +1184 -0
- mcp_vector_search/cli/commands/status.py +339 -5
- mcp_vector_search/cli/commands/uninstall.py +276 -357
- mcp_vector_search/cli/commands/visualize/__init__.py +39 -0
- mcp_vector_search/cli/commands/visualize/cli.py +292 -0
- mcp_vector_search/cli/commands/visualize/exporters/__init__.py +12 -0
- mcp_vector_search/cli/commands/visualize/exporters/html_exporter.py +33 -0
- mcp_vector_search/cli/commands/visualize/exporters/json_exporter.py +33 -0
- mcp_vector_search/cli/commands/visualize/graph_builder.py +647 -0
- mcp_vector_search/cli/commands/visualize/layout_engine.py +469 -0
- mcp_vector_search/cli/commands/visualize/server.py +600 -0
- mcp_vector_search/cli/commands/visualize/state_manager.py +428 -0
- mcp_vector_search/cli/commands/visualize/templates/__init__.py +16 -0
- mcp_vector_search/cli/commands/visualize/templates/base.py +234 -0
- mcp_vector_search/cli/commands/visualize/templates/scripts.py +4542 -0
- mcp_vector_search/cli/commands/visualize/templates/styles.py +2522 -0
- mcp_vector_search/cli/didyoumean.py +27 -2
- mcp_vector_search/cli/main.py +127 -160
- mcp_vector_search/cli/output.py +158 -13
- mcp_vector_search/config/__init__.py +4 -0
- mcp_vector_search/config/default_thresholds.yaml +52 -0
- mcp_vector_search/config/settings.py +12 -0
- mcp_vector_search/config/thresholds.py +273 -0
- mcp_vector_search/core/__init__.py +16 -0
- mcp_vector_search/core/auto_indexer.py +3 -3
- mcp_vector_search/core/boilerplate.py +186 -0
- mcp_vector_search/core/config_utils.py +394 -0
- mcp_vector_search/core/database.py +406 -94
- mcp_vector_search/core/embeddings.py +24 -0
- mcp_vector_search/core/exceptions.py +11 -0
- mcp_vector_search/core/git.py +380 -0
- mcp_vector_search/core/git_hooks.py +4 -4
- mcp_vector_search/core/indexer.py +632 -54
- mcp_vector_search/core/llm_client.py +756 -0
- mcp_vector_search/core/models.py +91 -1
- mcp_vector_search/core/project.py +17 -0
- mcp_vector_search/core/relationships.py +473 -0
- mcp_vector_search/core/scheduler.py +11 -11
- mcp_vector_search/core/search.py +179 -29
- mcp_vector_search/mcp/server.py +819 -9
- mcp_vector_search/parsers/python.py +285 -5
- mcp_vector_search/utils/__init__.py +2 -0
- mcp_vector_search/utils/gitignore.py +0 -3
- mcp_vector_search/utils/gitignore_updater.py +212 -0
- mcp_vector_search/utils/monorepo.py +66 -4
- mcp_vector_search/utils/timing.py +10 -6
- {mcp_vector_search-0.12.6.dist-info → mcp_vector_search-1.1.22.dist-info}/METADATA +184 -53
- mcp_vector_search-1.1.22.dist-info/RECORD +120 -0
- {mcp_vector_search-0.12.6.dist-info → mcp_vector_search-1.1.22.dist-info}/WHEEL +1 -1
- {mcp_vector_search-0.12.6.dist-info → mcp_vector_search-1.1.22.dist-info}/entry_points.txt +1 -0
- mcp_vector_search/cli/commands/visualize.py +0 -1467
- mcp_vector_search-0.12.6.dist-info/RECORD +0 -68
- {mcp_vector_search-0.12.6.dist-info → mcp_vector_search-1.1.22.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"""SQLite schema definitions for metrics storage.
|
|
2
|
+
|
|
3
|
+
This module defines the database schema for storing code metrics over time,
|
|
4
|
+
enabling trend analysis and historical comparisons.
|
|
5
|
+
|
|
6
|
+
Schema Design Principles:
|
|
7
|
+
- Normalized structure: Separate tables for files, projects, and smells
|
|
8
|
+
- Temporal tracking: All tables include timestamps for history
|
|
9
|
+
- Efficient queries: Indexes on frequently queried columns
|
|
10
|
+
- Migration support: Schema version tracking for future changes
|
|
11
|
+
|
|
12
|
+
Tables:
|
|
13
|
+
- schema_version: Track schema version for migrations
|
|
14
|
+
- file_metrics: Per-file metrics snapshots
|
|
15
|
+
- project_snapshots: Project-wide metric aggregates
|
|
16
|
+
- code_smells: Detected code smell instances
|
|
17
|
+
|
|
18
|
+
Performance Considerations:
|
|
19
|
+
- Composite indexes for common query patterns
|
|
20
|
+
- Foreign keys for referential integrity
|
|
21
|
+
- Cascading deletes for cleanup
|
|
22
|
+
|
|
23
|
+
Design Decision: SQLite for Simplicity
|
|
24
|
+
Rationale: Chosen SQLite over PostgreSQL/MySQL for:
|
|
25
|
+
- Zero configuration (no server setup)
|
|
26
|
+
- Single-file portability
|
|
27
|
+
- Adequate performance for ~10K files
|
|
28
|
+
- Built into Python standard library
|
|
29
|
+
|
|
30
|
+
Trade-offs:
|
|
31
|
+
- Concurrency: Limited to single writer (acceptable for CLI tool)
|
|
32
|
+
- Scale: Suitable for projects up to ~10K files
|
|
33
|
+
- Features: No advanced types (JSON columns, etc.)
|
|
34
|
+
|
|
35
|
+
Extension Points: Schema includes version tracking to enable migration
|
|
36
|
+
to PostgreSQL if concurrent access or >10K file scale becomes necessary.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# Schema version for migration tracking
|
|
40
|
+
SCHEMA_VERSION = "1.0"
|
|
41
|
+
|
|
42
|
+
# SQL statement to create schema version table
|
|
43
|
+
CREATE_SCHEMA_VERSION_TABLE = """
|
|
44
|
+
CREATE TABLE IF NOT EXISTS schema_version (
|
|
45
|
+
version TEXT PRIMARY KEY,
|
|
46
|
+
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
47
|
+
);
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
# SQL statement to initialize schema version
|
|
51
|
+
INIT_SCHEMA_VERSION = f"""
|
|
52
|
+
INSERT OR IGNORE INTO schema_version (version) VALUES ('{SCHEMA_VERSION}');
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
# SQL statement to create file_metrics table
|
|
56
|
+
CREATE_FILE_METRICS_TABLE = """
|
|
57
|
+
CREATE TABLE IF NOT EXISTS file_metrics (
|
|
58
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
59
|
+
file_path TEXT NOT NULL,
|
|
60
|
+
project_id INTEGER NOT NULL,
|
|
61
|
+
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
62
|
+
|
|
63
|
+
-- Line counts
|
|
64
|
+
total_lines INTEGER NOT NULL DEFAULT 0,
|
|
65
|
+
code_lines INTEGER NOT NULL DEFAULT 0,
|
|
66
|
+
comment_lines INTEGER NOT NULL DEFAULT 0,
|
|
67
|
+
blank_lines INTEGER NOT NULL DEFAULT 0,
|
|
68
|
+
|
|
69
|
+
-- Structure counts
|
|
70
|
+
function_count INTEGER NOT NULL DEFAULT 0,
|
|
71
|
+
class_count INTEGER NOT NULL DEFAULT 0,
|
|
72
|
+
method_count INTEGER NOT NULL DEFAULT 0,
|
|
73
|
+
|
|
74
|
+
-- Complexity metrics
|
|
75
|
+
cognitive_complexity INTEGER NOT NULL DEFAULT 0,
|
|
76
|
+
cyclomatic_complexity INTEGER NOT NULL DEFAULT 0,
|
|
77
|
+
total_complexity INTEGER NOT NULL DEFAULT 0,
|
|
78
|
+
avg_complexity REAL NOT NULL DEFAULT 0.0,
|
|
79
|
+
max_complexity INTEGER NOT NULL DEFAULT 0,
|
|
80
|
+
|
|
81
|
+
-- Code quality
|
|
82
|
+
smell_count INTEGER NOT NULL DEFAULT 0,
|
|
83
|
+
health_score REAL NOT NULL DEFAULT 1.0,
|
|
84
|
+
complexity_grade TEXT NOT NULL DEFAULT 'A',
|
|
85
|
+
|
|
86
|
+
-- Foreign key to project snapshot
|
|
87
|
+
FOREIGN KEY (project_id) REFERENCES project_snapshots(id) ON DELETE CASCADE,
|
|
88
|
+
|
|
89
|
+
-- Ensure file_path + project_id + timestamp is unique
|
|
90
|
+
UNIQUE(file_path, project_id, timestamp)
|
|
91
|
+
);
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
# SQL statements to create indexes on file_metrics (separate statements)
|
|
95
|
+
CREATE_FILE_METRICS_INDEXES = [
|
|
96
|
+
"""CREATE INDEX IF NOT EXISTS idx_file_metrics_file_path
|
|
97
|
+
ON file_metrics(file_path)""",
|
|
98
|
+
"""CREATE INDEX IF NOT EXISTS idx_file_metrics_project_id
|
|
99
|
+
ON file_metrics(project_id)""",
|
|
100
|
+
"""CREATE INDEX IF NOT EXISTS idx_file_metrics_timestamp
|
|
101
|
+
ON file_metrics(timestamp DESC)""",
|
|
102
|
+
"""CREATE INDEX IF NOT EXISTS idx_file_metrics_complexity
|
|
103
|
+
ON file_metrics(avg_complexity DESC)""",
|
|
104
|
+
"""CREATE INDEX IF NOT EXISTS idx_file_metrics_health
|
|
105
|
+
ON file_metrics(health_score ASC)""",
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
# SQL statement to create project_snapshots table
|
|
109
|
+
CREATE_PROJECT_SNAPSHOTS_TABLE = """
|
|
110
|
+
CREATE TABLE IF NOT EXISTS project_snapshots (
|
|
111
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
112
|
+
project_path TEXT NOT NULL,
|
|
113
|
+
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
114
|
+
|
|
115
|
+
-- Project totals
|
|
116
|
+
total_files INTEGER NOT NULL DEFAULT 0,
|
|
117
|
+
total_lines INTEGER NOT NULL DEFAULT 0,
|
|
118
|
+
total_functions INTEGER NOT NULL DEFAULT 0,
|
|
119
|
+
total_classes INTEGER NOT NULL DEFAULT 0,
|
|
120
|
+
|
|
121
|
+
-- Complexity aggregates
|
|
122
|
+
avg_complexity REAL NOT NULL DEFAULT 0.0,
|
|
123
|
+
max_complexity INTEGER NOT NULL DEFAULT 0,
|
|
124
|
+
total_complexity INTEGER NOT NULL DEFAULT 0,
|
|
125
|
+
|
|
126
|
+
-- Code quality
|
|
127
|
+
total_smells INTEGER NOT NULL DEFAULT 0,
|
|
128
|
+
avg_health_score REAL NOT NULL DEFAULT 1.0,
|
|
129
|
+
|
|
130
|
+
-- Grade distribution (JSON-encoded dict)
|
|
131
|
+
grade_distribution TEXT NOT NULL DEFAULT '{}',
|
|
132
|
+
|
|
133
|
+
-- Git metadata for traceability
|
|
134
|
+
git_commit TEXT,
|
|
135
|
+
git_branch TEXT,
|
|
136
|
+
git_remote TEXT,
|
|
137
|
+
|
|
138
|
+
-- Tool version for compatibility
|
|
139
|
+
tool_version TEXT,
|
|
140
|
+
|
|
141
|
+
-- Ensure project_path + timestamp is unique
|
|
142
|
+
UNIQUE(project_path, timestamp)
|
|
143
|
+
);
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
# SQL statements to create indexes on project_snapshots (separate statements)
|
|
147
|
+
CREATE_PROJECT_SNAPSHOTS_INDEXES = [
|
|
148
|
+
"""CREATE INDEX IF NOT EXISTS idx_project_snapshots_project_path
|
|
149
|
+
ON project_snapshots(project_path)""",
|
|
150
|
+
"""CREATE INDEX IF NOT EXISTS idx_project_snapshots_timestamp
|
|
151
|
+
ON project_snapshots(timestamp DESC)""",
|
|
152
|
+
"""CREATE INDEX IF NOT EXISTS idx_project_snapshots_complexity
|
|
153
|
+
ON project_snapshots(avg_complexity DESC)""",
|
|
154
|
+
"""CREATE INDEX IF NOT EXISTS idx_project_snapshots_git_commit
|
|
155
|
+
ON project_snapshots(git_commit)""",
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
# SQL statement to create code_smells table
|
|
159
|
+
CREATE_CODE_SMELLS_TABLE = """
|
|
160
|
+
CREATE TABLE IF NOT EXISTS code_smells (
|
|
161
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
162
|
+
file_id INTEGER NOT NULL,
|
|
163
|
+
snapshot_id INTEGER NOT NULL,
|
|
164
|
+
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
165
|
+
|
|
166
|
+
-- Smell classification
|
|
167
|
+
smell_type TEXT NOT NULL,
|
|
168
|
+
severity TEXT NOT NULL CHECK(severity IN ('low', 'medium', 'high', 'critical')),
|
|
169
|
+
|
|
170
|
+
-- Location in file (line number or range)
|
|
171
|
+
location TEXT,
|
|
172
|
+
|
|
173
|
+
-- Metric that triggered the smell
|
|
174
|
+
metric_name TEXT,
|
|
175
|
+
metric_value REAL,
|
|
176
|
+
threshold REAL,
|
|
177
|
+
|
|
178
|
+
-- Foreign keys
|
|
179
|
+
FOREIGN KEY (file_id) REFERENCES file_metrics(id) ON DELETE CASCADE,
|
|
180
|
+
FOREIGN KEY (snapshot_id) REFERENCES project_snapshots(id) ON DELETE CASCADE
|
|
181
|
+
);
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
# SQL statements to create indexes on code_smells (separate statements)
|
|
185
|
+
CREATE_CODE_SMELLS_INDEXES = [
|
|
186
|
+
"""CREATE INDEX IF NOT EXISTS idx_code_smells_file_id
|
|
187
|
+
ON code_smells(file_id)""",
|
|
188
|
+
"""CREATE INDEX IF NOT EXISTS idx_code_smells_snapshot_id
|
|
189
|
+
ON code_smells(snapshot_id)""",
|
|
190
|
+
"""CREATE INDEX IF NOT EXISTS idx_code_smells_smell_type
|
|
191
|
+
ON code_smells(smell_type)""",
|
|
192
|
+
"""CREATE INDEX IF NOT EXISTS idx_code_smells_severity
|
|
193
|
+
ON code_smells(severity)""",
|
|
194
|
+
"""CREATE INDEX IF NOT EXISTS idx_code_smells_timestamp
|
|
195
|
+
ON code_smells(timestamp DESC)""",
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
# Complete schema initialization (all CREATE statements)
|
|
199
|
+
# Flatten all statements into a single list
|
|
200
|
+
INIT_SCHEMA_SQL = (
|
|
201
|
+
[CREATE_SCHEMA_VERSION_TABLE, INIT_SCHEMA_VERSION]
|
|
202
|
+
+ [CREATE_PROJECT_SNAPSHOTS_TABLE]
|
|
203
|
+
+ CREATE_PROJECT_SNAPSHOTS_INDEXES
|
|
204
|
+
+ [CREATE_FILE_METRICS_TABLE]
|
|
205
|
+
+ CREATE_FILE_METRICS_INDEXES
|
|
206
|
+
+ [CREATE_CODE_SMELLS_TABLE]
|
|
207
|
+
+ CREATE_CODE_SMELLS_INDEXES
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def get_schema_version_query() -> str:
|
|
212
|
+
"""Get SQL query to retrieve current schema version.
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
SQL SELECT statement to fetch schema version
|
|
216
|
+
"""
|
|
217
|
+
return "SELECT version FROM schema_version ORDER BY applied_at DESC LIMIT 1"
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def get_migration_queries(from_version: str, to_version: str) -> list[str]:
|
|
221
|
+
"""Get migration SQL statements for schema upgrade.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
from_version: Current schema version
|
|
225
|
+
to_version: Target schema version
|
|
226
|
+
|
|
227
|
+
Returns:
|
|
228
|
+
List of SQL statements to apply migration
|
|
229
|
+
|
|
230
|
+
Future Extension: When schema changes, add migration logic here.
|
|
231
|
+
Example:
|
|
232
|
+
if from_version == "1.0" and to_version == "2.0":
|
|
233
|
+
return [
|
|
234
|
+
"ALTER TABLE file_metrics ADD COLUMN new_field INTEGER DEFAULT 0",
|
|
235
|
+
"UPDATE schema_version SET version = '2.0'",
|
|
236
|
+
]
|
|
237
|
+
"""
|
|
238
|
+
# Currently only version 1.0 exists, no migrations yet
|
|
239
|
+
if from_version == to_version:
|
|
240
|
+
return []
|
|
241
|
+
|
|
242
|
+
raise ValueError(
|
|
243
|
+
f"No migration path from version {from_version} to {to_version}. "
|
|
244
|
+
f"Current schema version: {SCHEMA_VERSION}"
|
|
245
|
+
)
|