File size: 1,171 Bytes
7e2f74d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from tools.base_tool import BaseTool
from services.repositoryMemory import memory_service
from typing import Any

class GraphQueryTool(BaseTool):
    @property
    def name(self) -> str:
        return "graph_query"

    @property
    def description(self) -> str:
        return "Queries the repository code dependency graph, entry points, workflows, and concepts. Inputs: repo_id (str)."

    def execute(self, **kwargs) -> Any:
        repo_id = kwargs.get("repo_id")
        if not repo_id:
            return {"error": "Missing required parameter: repo_id."}
            
        data = memory_service.retrieve(repo_id)
        if not data or "graph" not in data:
            return {"error": f"No architecture graph found for repository {repo_id}."}
            
        graph = data["graph"]
        return {
            "entry_points": graph.get("entry_points", []),
            "business_flows": graph.get("business_flows", []),
            "critical_paths": graph.get("critical_paths", []),
            "concepts": graph.get("concepts", []),
            "node_count": len(graph.get("nodes", [])),
            "edge_count": len(graph.get("edges", []))
        }