feat(controller): Integrate py_get_definition for on-demand lookup

This commit is contained in:
2026-03-07 15:03:03 -05:00
parent 953e9e040c
commit c6f9dc886f
4 changed files with 62 additions and 24 deletions

View File

@@ -46,6 +46,13 @@ def parse_symbols(text: str) -> list[str]:
"""
return re.findall(r"@([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)", text)
def get_symbol_definition(symbol: str, files: list[str]) -> tuple[str, str] | None:
for file_path in files:
result = mcp_client.py_get_definition(file_path, symbol)
if 'not found' not in result.lower():
return (file_path, result)
return None
class GenerateRequest(BaseModel):
prompt: str
auto_add_history: bool = True

View File

@@ -409,7 +409,7 @@ def py_get_definition(path: str, name: str) -> str:
start = cast(int, getattr(node, "lineno")) - 1
end = cast(int, getattr(node, "end_lineno"))
return "".join(lines[start:end])
return f"ERROR: could not find definition '{name}' in {path}"
return f"ERROR: definition '{name}' not found in {path}"
except Exception as e:
return f"ERROR retrieving definition '{name}' from '{path}': {e}"