checkpoint
This commit is contained in:
@@ -31,6 +31,7 @@ so the AI doesn't wander outside the project workspace.
|
||||
|
||||
from pathlib import Path
|
||||
import summarize
|
||||
import outline_tool
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
from html.parser import HTMLParser
|
||||
@@ -261,6 +262,25 @@ def get_python_skeleton(path: str) -> str:
|
||||
return f"ERROR generating skeleton for '{path}': {e}"
|
||||
|
||||
|
||||
def get_code_outline(path: str) -> str:
|
||||
"""
|
||||
Returns a hierarchical outline of a code file (classes, functions, methods with line ranges).
|
||||
"""
|
||||
p, err = _resolve_and_check(path)
|
||||
if err:
|
||||
return err
|
||||
if not p.exists():
|
||||
return f"ERROR: file not found: {path}"
|
||||
if not p.is_file():
|
||||
return f"ERROR: not a file: {path}"
|
||||
|
||||
try:
|
||||
code = p.read_text(encoding="utf-8")
|
||||
return outline_tool.get_outline(p, code)
|
||||
except Exception as e:
|
||||
return f"ERROR generating outline for '{path}': {e}"
|
||||
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ web tools
|
||||
|
||||
@@ -387,7 +407,7 @@ def get_ui_performance() -> str:
|
||||
# ------------------------------------------------------------------ tool dispatch
|
||||
|
||||
|
||||
TOOL_NAMES = {"read_file", "list_directory", "search_files", "get_file_summary", "get_python_skeleton", "web_search", "fetch_url", "get_ui_performance"}
|
||||
TOOL_NAMES = {"read_file", "list_directory", "search_files", "get_file_summary", "get_python_skeleton", "get_code_outline", "web_search", "fetch_url", "get_ui_performance"}
|
||||
|
||||
|
||||
def dispatch(tool_name: str, tool_input: dict) -> str:
|
||||
@@ -404,6 +424,8 @@ def dispatch(tool_name: str, tool_input: dict) -> str:
|
||||
return get_file_summary(tool_input.get("path", ""))
|
||||
if tool_name == "get_python_skeleton":
|
||||
return get_python_skeleton(tool_input.get("path", ""))
|
||||
if tool_name == "get_code_outline":
|
||||
return get_code_outline(tool_input.get("path", ""))
|
||||
if tool_name == "web_search":
|
||||
return web_search(tool_input.get("query", ""))
|
||||
if tool_name == "fetch_url":
|
||||
@@ -511,6 +533,24 @@ MCP_TOOL_SPECS = [
|
||||
"required": ["path"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "get_code_outline",
|
||||
"description": (
|
||||
"Get a hierarchical outline of a code file. "
|
||||
"This returns classes, functions, and methods with their line ranges and brief docstrings. "
|
||||
"Use this to quickly map out a file's structure before reading specific sections."
|
||||
),
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Path to the code file (currently supports .py).",
|
||||
}
|
||||
},
|
||||
"required": ["path"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "web_search",
|
||||
"description": "Search the web using DuckDuckGo. Returns the top 5 search results with titles, URLs, and snippets. Chain this with fetch_url to read specific pages.",
|
||||
|
||||
Reference in New Issue
Block a user