standardize hyphon

This commit is contained in:
2025-11-13 17:52:25 +00:00
parent be1d66a784
commit 94ed34e449
+24 -24
View File
@@ -2041,10 +2041,10 @@ def find_brace_block_end(lines: List[str], start_idx: int) -> Optional[int]:
# ----------------------------- # -----------------------------
@mcp.tool() @mcp.tool()
def health_check() -> str: def health_check() -> str:
"""What it does Quick JSON status of the RAG server (ready, indexed path, chunk count, age). """What it does - Quick JSON status of the RAG server (ready, indexed path, chunk count, age).
When to use Before any other query, to confirm the index is current. When to use - Before any other query, to confirm the index is current.
When not to use After you already know the server is healthy; it adds no value. When not to use - After you already know the server is healthy; it adds no value.
Example health_check() → { "status":"ready","total_chunks":11234,"index_age_hours":4.7 }""" Example - health_check() → { "status":"ready","total_chunks":11234,"index_age_hours":4.7 }"""
try: try:
with _startup_lock: with _startup_lock:
status = { status = {
@@ -2081,11 +2081,11 @@ Example health_check() → { "status":"ready","total_chunks":11234,"index_ag
@mcp.tool() @mcp.tool()
def search_codebase(query: str, top_k: int = 5, rerank: bool = True) -> str: def search_codebase(query: str, top_k: int = 5, rerank: bool = True) -> str:
"""What it does Hybrid RAG search that returns semantically ranked snippets with file/line info from natural language queries. """What it does - Hybrid RAG search that returns semantically ranked snippets with file/line info from natural language queries.
When to use For openended questions or unknown patterns (“how does auth work?”). Natural language and verbose queries ONLY. When to use - For open-ended questions or unknown patterns (“how does auth work?”). Natural language and verbose queries ONLY.
When not to use For a single symbol or exact phrase; use find_code_references then read instead to avoid a large result set. When not to use - For a single symbol or exact phrase; use find_code_references then read instead to avoid a large result set.
Rerank false is good enough for 65% of searches and is VERY fast, rerank true is much slower but good enough for 95% of searches. Best to use rerank true if rerank false didn't quite help enough. Rerank false is good enough for 65% of searches and is VERY fast, rerank true is much slower but good enough for 95% of searches. Best to use rerank true if rerank false didn't quite help enough.
Example search_codebase("user authentication python", top_k=5, rerank=True) → 5 relevant snippets.""" Example - search_codebase("user authentication python", top_k=5, rerank=True) → 5 relevant snippets."""
try: try:
hy = hybrid_search(query, k=max(top_k, RERANK_TOP_N)) hy = hybrid_search(query, k=max(top_k, RERANK_TOP_N))
@@ -2189,10 +2189,10 @@ def _format_toon_results(results: List[Dict], query: str, result_type: str) -> s
@mcp.tool() @mcp.tool()
def find_code_references(symbol: str, top_k: int = 20) -> str: def find_code_references(symbol: str, top_k: int = 20) -> str:
"""What it does Fast, unranked lookup of all file/line occurrences of a symbol. """What it does - Fast, unranked lookup of all file/line occurrences of a symbol.
When to use After identifying a symbol in a search hit, or when you need every use of a class/method. When to use - After identifying a symbol in a search hit, or when you need every use of a class/method.
When not to use When you need contextrich code; use read_file_lines_tool after getting the locations. When not to use - When you need context-rich code; use read_file_lines_tool after getting the locations.
Example find_code_references("AuthService") → list of references.""" Example - find_code_references("AuthService") → list of references."""
matches = search_symbol(symbol, CODEBASE_PATH) matches = search_symbol(symbol, CODEBASE_PATH)
if not matches: if not matches:
@@ -2240,24 +2240,24 @@ def _format_reference_results(results: List[Dict], symbol: str) -> str:
@mcp.tool() @mcp.tool()
def read_file_lines_tool(path: str, start: int = 1, end: Optional[int] = None) -> str: def read_file_lines_tool(path: str, start: int = 1, end: Optional[int] = None) -> str:
"""What it does Reads a requested line range and autoexpands to include surrounding context (function body, docstring, comments). """What it does - Reads a requested line range and auto-expands to include surrounding context (function body, docstring, comments).
When to use To inspect a specific hit from find_code_references or a snippet from search_codebase. When to use - To inspect a specific hit from find_code_references or a snippet from search_codebase.
When not to use For browsing the entire file or unrelated sections; use search_codebase first to pinpoint relevant parts. When not to use - For browsing the entire file or unrelated sections; use search_codebase first to pinpoint relevant parts.
Example read_file_lines_tool("src/auth/login.py", start=45, end=60) → full function with context. Example - read_file_lines_tool("src/auth/login.py", start=45, end=60) → full function with context.
Note: This tool treats / as '/home/popertots/Crussell/' so adjust paths accordingly""" Note: This tool treats / as '/home/popertots/Crussell/' so adjust paths accordingly"""
return EnhancedToon.file_content_results(read_file_lines(path, start, end), path) return EnhancedToon.file_content_results(read_file_lines(path, start, end), path)
@mcp.tool() @mcp.tool()
def init_repo(git_url: str) -> str: def init_repo(git_url: str) -> str:
"""What it does Initialise the RAG stack with a brandnew Git repository or update an existing one. """What it does - Initialise the RAG stack with a brand-new Git repository or update an existing one.
The function will: The function will:
1. Clone the repo if it does not already exist locally, 1. Clone the repo if it does not already exist locally,
2. Pull the latest changes if it does, 2. Pull the latest changes if it does,
3. Reset the global `CODEBASE_PATH` to the local clone, 3. Reset the global `CODEBASE_PATH` to the local clone,
4. Remove any stale index artefacts, 4. Remove any stale index artefacts,
5. Rebuild the vector/BM25 indexes with the same lockprotected flow used by `rebuild_index`, 5. Re-build the vector/BM25 indexes with the same lock-protected flow used by `rebuild_index`,
6. Return a humanreadable status message. 6. Return a human-readable status message.
Next steps: Next steps:
• Call `health_check` to confirm that the server is ready. • Call `health_check` to confirm that the server is ready.
@@ -2314,7 +2314,7 @@ def init_repo(git_url: str) -> str:
except Exception as e: except Exception as e:
logger.warning(f"Could not delete {artefact_path}: {e}") logger.warning(f"Could not delete {artefact_path}: {e}")
# ----- 5. Rebuild the index (protected by the startup lock) ------------ # ----- 5. Re-build the index (protected by the startup lock) ------------
try: try:
rebuild_index() rebuild_index()
except Exception as e: except Exception as e:
@@ -2335,10 +2335,10 @@ def init_repo(git_url: str) -> str:
@mcp.tool() @mcp.tool()
def rebuild_index() -> str: def rebuild_index() -> str:
"""What it does Recreates all embeddings, BM25, and metadata indexes after major code changes. """What it does - Re-creates all embeddings, BM25, and metadata indexes after major code changes.
When to use When the codebase has been pulled or refactored and you suspect stale search results, and only after explicit instruction to do so. When to use - When the codebase has been pulled or refactored and you suspect stale search results, and only after explicit instruction to do so.
When not to use On every query; its expensive and unnecessary if the index is already uptodate. When not to use - On every query; its expensive and unnecessary if the index is already up-to-date.
Example rebuild_index() → '✅ Index rebuilt (13.2s); 11,234 chunks'""" Example - rebuild_index() → '✅ Index rebuilt (13.2s); 11,234 chunks'"""
with _startup_lock: with _startup_lock:
try: try:
# Clear LRU caches # Clear LRU caches