mcp-vector-search 0.15.7__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 mcp-vector-search might be problematic. Click here for more details.
- mcp_vector_search/__init__.py +10 -0
- mcp_vector_search/cli/__init__.py +1 -0
- mcp_vector_search/cli/commands/__init__.py +1 -0
- mcp_vector_search/cli/commands/auto_index.py +397 -0
- mcp_vector_search/cli/commands/chat.py +534 -0
- mcp_vector_search/cli/commands/config.py +393 -0
- mcp_vector_search/cli/commands/demo.py +358 -0
- mcp_vector_search/cli/commands/index.py +762 -0
- mcp_vector_search/cli/commands/init.py +658 -0
- mcp_vector_search/cli/commands/install.py +869 -0
- mcp_vector_search/cli/commands/install_old.py +700 -0
- mcp_vector_search/cli/commands/mcp.py +1254 -0
- mcp_vector_search/cli/commands/reset.py +393 -0
- mcp_vector_search/cli/commands/search.py +796 -0
- mcp_vector_search/cli/commands/setup.py +1133 -0
- mcp_vector_search/cli/commands/status.py +584 -0
- mcp_vector_search/cli/commands/uninstall.py +404 -0
- mcp_vector_search/cli/commands/visualize/__init__.py +39 -0
- mcp_vector_search/cli/commands/visualize/cli.py +265 -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 +29 -0
- mcp_vector_search/cli/commands/visualize/graph_builder.py +709 -0
- mcp_vector_search/cli/commands/visualize/layout_engine.py +469 -0
- mcp_vector_search/cli/commands/visualize/server.py +201 -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 +218 -0
- mcp_vector_search/cli/commands/visualize/templates/scripts.py +3670 -0
- mcp_vector_search/cli/commands/visualize/templates/styles.py +779 -0
- mcp_vector_search/cli/commands/visualize.py.original +2536 -0
- mcp_vector_search/cli/commands/watch.py +287 -0
- mcp_vector_search/cli/didyoumean.py +520 -0
- mcp_vector_search/cli/export.py +320 -0
- mcp_vector_search/cli/history.py +295 -0
- mcp_vector_search/cli/interactive.py +342 -0
- mcp_vector_search/cli/main.py +484 -0
- mcp_vector_search/cli/output.py +414 -0
- mcp_vector_search/cli/suggestions.py +375 -0
- mcp_vector_search/config/__init__.py +1 -0
- mcp_vector_search/config/constants.py +24 -0
- mcp_vector_search/config/defaults.py +200 -0
- mcp_vector_search/config/settings.py +146 -0
- mcp_vector_search/core/__init__.py +1 -0
- mcp_vector_search/core/auto_indexer.py +298 -0
- mcp_vector_search/core/config_utils.py +394 -0
- mcp_vector_search/core/connection_pool.py +360 -0
- mcp_vector_search/core/database.py +1237 -0
- mcp_vector_search/core/directory_index.py +318 -0
- mcp_vector_search/core/embeddings.py +294 -0
- mcp_vector_search/core/exceptions.py +89 -0
- mcp_vector_search/core/factory.py +318 -0
- mcp_vector_search/core/git_hooks.py +345 -0
- mcp_vector_search/core/indexer.py +1002 -0
- mcp_vector_search/core/llm_client.py +453 -0
- mcp_vector_search/core/models.py +294 -0
- mcp_vector_search/core/project.py +350 -0
- mcp_vector_search/core/scheduler.py +330 -0
- mcp_vector_search/core/search.py +952 -0
- mcp_vector_search/core/watcher.py +322 -0
- mcp_vector_search/mcp/__init__.py +5 -0
- mcp_vector_search/mcp/__main__.py +25 -0
- mcp_vector_search/mcp/server.py +752 -0
- mcp_vector_search/parsers/__init__.py +8 -0
- mcp_vector_search/parsers/base.py +296 -0
- mcp_vector_search/parsers/dart.py +605 -0
- mcp_vector_search/parsers/html.py +413 -0
- mcp_vector_search/parsers/javascript.py +643 -0
- mcp_vector_search/parsers/php.py +694 -0
- mcp_vector_search/parsers/python.py +502 -0
- mcp_vector_search/parsers/registry.py +223 -0
- mcp_vector_search/parsers/ruby.py +678 -0
- mcp_vector_search/parsers/text.py +186 -0
- mcp_vector_search/parsers/utils.py +265 -0
- mcp_vector_search/py.typed +1 -0
- mcp_vector_search/utils/__init__.py +42 -0
- mcp_vector_search/utils/gitignore.py +250 -0
- mcp_vector_search/utils/gitignore_updater.py +212 -0
- mcp_vector_search/utils/monorepo.py +339 -0
- mcp_vector_search/utils/timing.py +338 -0
- mcp_vector_search/utils/version.py +47 -0
- mcp_vector_search-0.15.7.dist-info/METADATA +884 -0
- mcp_vector_search-0.15.7.dist-info/RECORD +86 -0
- mcp_vector_search-0.15.7.dist-info/WHEEL +4 -0
- mcp_vector_search-0.15.7.dist-info/entry_points.txt +3 -0
- mcp_vector_search-0.15.7.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"""Watch command for MCP Vector Search CLI."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import signal
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
from loguru import logger
|
|
10
|
+
|
|
11
|
+
from ...core.database import ChromaVectorDatabase
|
|
12
|
+
from ...core.embeddings import create_embedding_function
|
|
13
|
+
from ...core.exceptions import ProjectNotFoundError
|
|
14
|
+
from ...core.indexer import SemanticIndexer
|
|
15
|
+
from ...core.project import ProjectManager
|
|
16
|
+
from ...core.watcher import FileWatcher
|
|
17
|
+
from ..output import (
|
|
18
|
+
console,
|
|
19
|
+
print_error,
|
|
20
|
+
print_info,
|
|
21
|
+
print_success,
|
|
22
|
+
print_warning,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
app = typer.Typer(name="watch", help="Watch for file changes and update index")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@app.command("main")
|
|
29
|
+
def watch_main(
|
|
30
|
+
project_root: Path = typer.Argument(
|
|
31
|
+
Path.cwd(),
|
|
32
|
+
help="Project root directory to watch",
|
|
33
|
+
exists=True,
|
|
34
|
+
file_okay=False,
|
|
35
|
+
dir_okay=True,
|
|
36
|
+
readable=True,
|
|
37
|
+
),
|
|
38
|
+
config: Path | None = typer.Option(
|
|
39
|
+
None,
|
|
40
|
+
"--config",
|
|
41
|
+
"-c",
|
|
42
|
+
help="Configuration file to use",
|
|
43
|
+
exists=True,
|
|
44
|
+
file_okay=True,
|
|
45
|
+
dir_okay=False,
|
|
46
|
+
readable=True,
|
|
47
|
+
),
|
|
48
|
+
verbose: bool = typer.Option(
|
|
49
|
+
False,
|
|
50
|
+
"--verbose",
|
|
51
|
+
"-v",
|
|
52
|
+
help="Enable verbose output",
|
|
53
|
+
),
|
|
54
|
+
) -> None:
|
|
55
|
+
"""Watch for file changes and automatically update the search index.
|
|
56
|
+
|
|
57
|
+
This command starts a file watcher that monitors your project directory
|
|
58
|
+
for changes to code files. When files are created, modified, or deleted,
|
|
59
|
+
the search index is automatically updated to reflect the changes.
|
|
60
|
+
|
|
61
|
+
The watcher will:
|
|
62
|
+
- Monitor all files with configured extensions
|
|
63
|
+
- Debounce rapid changes to avoid excessive indexing
|
|
64
|
+
- Update the index incrementally for better performance
|
|
65
|
+
- Ignore common build/cache directories
|
|
66
|
+
|
|
67
|
+
Press Ctrl+C to stop watching.
|
|
68
|
+
|
|
69
|
+
Examples:
|
|
70
|
+
mcp-vector-search watch
|
|
71
|
+
mcp-vector-search watch /path/to/project --verbose
|
|
72
|
+
mcp-vector-search watch --config custom-config.json
|
|
73
|
+
"""
|
|
74
|
+
if verbose:
|
|
75
|
+
logger.remove()
|
|
76
|
+
logger.add(sys.stderr, level="DEBUG")
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
asyncio.run(_watch_async(project_root, config))
|
|
80
|
+
except KeyboardInterrupt:
|
|
81
|
+
print_info("Watch stopped by user")
|
|
82
|
+
except Exception as e:
|
|
83
|
+
print_error(f"Watch failed: {e}")
|
|
84
|
+
raise typer.Exit(1)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
async def _watch_async(project_root: Path, config_path: Path | None) -> None:
|
|
88
|
+
"""Async implementation of watch command."""
|
|
89
|
+
# Load project configuration
|
|
90
|
+
try:
|
|
91
|
+
project_manager = ProjectManager(project_root)
|
|
92
|
+
if not project_manager.is_initialized():
|
|
93
|
+
print_error(
|
|
94
|
+
f"Project not initialized at {project_root}. "
|
|
95
|
+
"Run 'mcp-vector-search init' first."
|
|
96
|
+
)
|
|
97
|
+
raise typer.Exit(1)
|
|
98
|
+
|
|
99
|
+
config = project_manager.load_config()
|
|
100
|
+
print_info(f"Loaded configuration from {project_root}")
|
|
101
|
+
|
|
102
|
+
except ProjectNotFoundError:
|
|
103
|
+
print_error(
|
|
104
|
+
f"No MCP Vector Search project found at {project_root}. "
|
|
105
|
+
"Run 'mcp-vector-search init' to initialize."
|
|
106
|
+
)
|
|
107
|
+
raise typer.Exit(1)
|
|
108
|
+
|
|
109
|
+
# Setup database and indexer
|
|
110
|
+
try:
|
|
111
|
+
embedding_function, _ = create_embedding_function(config.embedding_model)
|
|
112
|
+
database = ChromaVectorDatabase(
|
|
113
|
+
persist_directory=config.index_path,
|
|
114
|
+
embedding_function=embedding_function,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
indexer = SemanticIndexer(
|
|
118
|
+
database=database,
|
|
119
|
+
project_root=project_root,
|
|
120
|
+
config=config,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
print_info(f"Initialized database at {config.index_path}")
|
|
124
|
+
|
|
125
|
+
except Exception as e:
|
|
126
|
+
print_error(f"Failed to initialize database: {e}")
|
|
127
|
+
raise typer.Exit(1)
|
|
128
|
+
|
|
129
|
+
# Start watching
|
|
130
|
+
try:
|
|
131
|
+
async with database:
|
|
132
|
+
watcher = FileWatcher(
|
|
133
|
+
project_root=project_root,
|
|
134
|
+
config=config,
|
|
135
|
+
indexer=indexer,
|
|
136
|
+
database=database,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
print_success("š Starting file watcher...")
|
|
140
|
+
print_info(f"š Watching: {project_root}")
|
|
141
|
+
print_info(f"š Extensions: {', '.join(config.file_extensions)}")
|
|
142
|
+
print_info("Press Ctrl+C to stop watching")
|
|
143
|
+
|
|
144
|
+
async with watcher:
|
|
145
|
+
# Set up signal handlers for graceful shutdown
|
|
146
|
+
stop_event = asyncio.Event()
|
|
147
|
+
|
|
148
|
+
def signal_handler():
|
|
149
|
+
print_info("\nā¹ļø Stopping file watcher...")
|
|
150
|
+
stop_event.set()
|
|
151
|
+
|
|
152
|
+
# Handle SIGINT (Ctrl+C) and SIGTERM
|
|
153
|
+
if sys.platform != "win32":
|
|
154
|
+
loop = asyncio.get_running_loop()
|
|
155
|
+
for sig in (signal.SIGINT, signal.SIGTERM):
|
|
156
|
+
loop.add_signal_handler(sig, signal_handler)
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
# Wait for stop signal
|
|
160
|
+
await stop_event.wait()
|
|
161
|
+
except KeyboardInterrupt:
|
|
162
|
+
signal_handler()
|
|
163
|
+
|
|
164
|
+
print_success("ā
File watcher stopped")
|
|
165
|
+
|
|
166
|
+
except Exception as e:
|
|
167
|
+
print_error(f"File watching failed: {e}")
|
|
168
|
+
raise typer.Exit(1)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@app.command("status")
|
|
172
|
+
def watch_status(
|
|
173
|
+
project_root: Path = typer.Argument(
|
|
174
|
+
Path.cwd(),
|
|
175
|
+
help="Project root directory",
|
|
176
|
+
exists=True,
|
|
177
|
+
file_okay=False,
|
|
178
|
+
dir_okay=True,
|
|
179
|
+
readable=True,
|
|
180
|
+
),
|
|
181
|
+
) -> None:
|
|
182
|
+
"""Check if file watching is enabled for a project.
|
|
183
|
+
|
|
184
|
+
This command checks the project configuration to see if file watching
|
|
185
|
+
is enabled and provides information about the watch settings.
|
|
186
|
+
"""
|
|
187
|
+
try:
|
|
188
|
+
project_manager = ProjectManager(project_root)
|
|
189
|
+
if not project_manager.is_initialized():
|
|
190
|
+
print_error(f"Project not initialized at {project_root}")
|
|
191
|
+
raise typer.Exit(1)
|
|
192
|
+
|
|
193
|
+
config = project_manager.load_config()
|
|
194
|
+
|
|
195
|
+
console.print("\n[bold]File Watch Status[/bold]")
|
|
196
|
+
console.print(f"Project: {project_root}")
|
|
197
|
+
console.print(f"Watch Files: {'ā' if config.watch_files else 'ā'}")
|
|
198
|
+
|
|
199
|
+
if config.watch_files:
|
|
200
|
+
console.print(f"Extensions: {', '.join(config.file_extensions)}")
|
|
201
|
+
print_info("File watching is enabled for this project")
|
|
202
|
+
else:
|
|
203
|
+
print_warning("File watching is disabled for this project")
|
|
204
|
+
print_info("Enable with: mcp-vector-search config set watch_files true")
|
|
205
|
+
|
|
206
|
+
except ProjectNotFoundError:
|
|
207
|
+
print_error(f"No MCP Vector Search project found at {project_root}")
|
|
208
|
+
raise typer.Exit(1)
|
|
209
|
+
except Exception as e:
|
|
210
|
+
print_error(f"Failed to check watch status: {e}")
|
|
211
|
+
raise typer.Exit(1)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@app.command("enable")
|
|
215
|
+
def watch_enable(
|
|
216
|
+
project_root: Path = typer.Argument(
|
|
217
|
+
Path.cwd(),
|
|
218
|
+
help="Project root directory",
|
|
219
|
+
exists=True,
|
|
220
|
+
file_okay=False,
|
|
221
|
+
dir_okay=True,
|
|
222
|
+
readable=True,
|
|
223
|
+
),
|
|
224
|
+
) -> None:
|
|
225
|
+
"""Enable file watching for a project.
|
|
226
|
+
|
|
227
|
+
This command enables the watch_files setting in the project configuration.
|
|
228
|
+
After enabling, you can use 'mcp-vector-search watch' to start monitoring.
|
|
229
|
+
"""
|
|
230
|
+
try:
|
|
231
|
+
project_manager = ProjectManager(project_root)
|
|
232
|
+
if not project_manager.is_initialized():
|
|
233
|
+
print_error(f"Project not initialized at {project_root}")
|
|
234
|
+
raise typer.Exit(1)
|
|
235
|
+
|
|
236
|
+
config = project_manager.load_config()
|
|
237
|
+
config.watch_files = True
|
|
238
|
+
project_manager.save_config(config)
|
|
239
|
+
|
|
240
|
+
print_success("ā
File watching enabled")
|
|
241
|
+
print_info("Start watching with: mcp-vector-search watch")
|
|
242
|
+
|
|
243
|
+
except ProjectNotFoundError:
|
|
244
|
+
print_error(f"No MCP Vector Search project found at {project_root}")
|
|
245
|
+
raise typer.Exit(1)
|
|
246
|
+
except Exception as e:
|
|
247
|
+
print_error(f"Failed to enable file watching: {e}")
|
|
248
|
+
raise typer.Exit(1)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
@app.command("disable")
|
|
252
|
+
def watch_disable(
|
|
253
|
+
project_root: Path = typer.Argument(
|
|
254
|
+
Path.cwd(),
|
|
255
|
+
help="Project root directory",
|
|
256
|
+
exists=True,
|
|
257
|
+
file_okay=False,
|
|
258
|
+
dir_okay=True,
|
|
259
|
+
readable=True,
|
|
260
|
+
),
|
|
261
|
+
) -> None:
|
|
262
|
+
"""Disable file watching for a project.
|
|
263
|
+
|
|
264
|
+
This command disables the watch_files setting in the project configuration.
|
|
265
|
+
"""
|
|
266
|
+
try:
|
|
267
|
+
project_manager = ProjectManager(project_root)
|
|
268
|
+
if not project_manager.is_initialized():
|
|
269
|
+
print_error(f"Project not initialized at {project_root}")
|
|
270
|
+
raise typer.Exit(1)
|
|
271
|
+
|
|
272
|
+
config = project_manager.load_config()
|
|
273
|
+
config.watch_files = False
|
|
274
|
+
project_manager.save_config(config)
|
|
275
|
+
|
|
276
|
+
print_success("ā
File watching disabled")
|
|
277
|
+
|
|
278
|
+
except ProjectNotFoundError:
|
|
279
|
+
print_error(f"No MCP Vector Search project found at {project_root}")
|
|
280
|
+
raise typer.Exit(1)
|
|
281
|
+
except Exception as e:
|
|
282
|
+
print_error(f"Failed to disable file watching: {e}")
|
|
283
|
+
raise typer.Exit(1)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if __name__ == "__main__":
|
|
287
|
+
app()
|