@@ -46,90 +46,72 @@ def __init__(self, cfg: AnalyzerAgentConfig) -> None:
4646
4747 async def run (self ):
4848 Logger .info ("Starting analyzer agent" )
49- tasks = []
49+
5050 analysis_files = []
51+ agent_tasks = {}
5152
5253 if not self ._config .exclude_code_structure :
53- analysis_files .append (
54- self ._config .repo_path / ".ai" / "docs" / "structure_analysis.md" ,
55- )
56- tasks .append (
57- self ._run_agent (
58- agent = self ._structure_analyzer_agent ,
59- user_prompt = self ._render_prompt ("agents.structure_analyzer.user_prompt" ),
60- file_path = self ._config .repo_path / ".ai" / "docs" / "structure_analysis.md" ,
61- )
54+ agent = self ._structure_analyzer_agent
55+ analysis_files .append (self ._config .repo_path / ".ai" / "docs" / "structure_analysis.md" )
56+ agent_tasks [agent .name ] = self ._run_agent (
57+ agent = agent ,
58+ user_prompt = self ._render_prompt ("agents.structure_analyzer.user_prompt" ),
59+ file_path = self ._config .repo_path / ".ai" / "docs" / "structure_analysis.md" ,
6260 )
6361
6462 if not self ._config .exclude_dependencies :
65- analysis_files .append (
66- self ._config .repo_path / ".ai" / "docs" / "dependency_analysis.md" ,
67- )
68- tasks .append (
69- self ._run_agent (
70- agent = self ._dependency_analyzer_agent ,
71- user_prompt = self ._render_prompt ("agents.dependency_analyzer.user_prompt" ),
72- file_path = self ._config .repo_path / ".ai" / "docs" / "dependency_analysis.md" ,
73- )
63+ agent = self ._dependency_analyzer_agent
64+ analysis_files .append (self ._config .repo_path / ".ai" / "docs" / "dependency_analysis.md" )
65+ agent_tasks [agent .name ] = self ._run_agent (
66+ agent = agent ,
67+ user_prompt = self ._render_prompt ("agents.dependency_analyzer.user_prompt" ),
68+ file_path = self ._config .repo_path / ".ai" / "docs" / "dependency_analysis.md" ,
7469 )
7570
7671 if not self ._config .exclude_data_flow :
77- analysis_files .append (
78- self ._config .repo_path / ".ai" / "docs" / "data_flow_analysis.md" ,
79- )
80- tasks .append (
81- self ._run_agent (
82- agent = self ._data_flow_analyzer_agent ,
83- user_prompt = self ._render_prompt ("agents.data_flow_analyzer.user_prompt" ),
84- file_path = self ._config .repo_path / ".ai" / "docs" / "data_flow_analysis.md" ,
85- )
72+ agent = self ._data_flow_analyzer_agent
73+ analysis_files .append (self ._config .repo_path / ".ai" / "docs" / "data_flow_analysis.md" )
74+ agent_tasks [agent .name ] = self ._run_agent (
75+ agent = agent ,
76+ user_prompt = self ._render_prompt ("agents.data_flow_analyzer.user_prompt" ),
77+ file_path = self ._config .repo_path / ".ai" / "docs" / "data_flow_analysis.md" ,
8678 )
8779
8880 if not self ._config .exclude_request_flow :
89- analysis_files .append (
90- self ._config .repo_path / ".ai" / "docs" / "request_flow_analysis.md" ,
91- )
92- tasks .append (
93- self ._run_agent (
94- agent = self ._request_flow_analyzer_agent ,
95- user_prompt = self ._render_prompt ("agents.request_flow_analyzer.user_prompt" ),
96- file_path = self ._config .repo_path / ".ai" / "docs" / "request_flow_analysis.md" ,
97- )
81+ agent = self ._request_flow_analyzer_agent
82+ analysis_files .append (self ._config .repo_path / ".ai" / "docs" / "request_flow_analysis.md" )
83+ agent_tasks [agent .name ] = self ._run_agent (
84+ agent = agent ,
85+ user_prompt = self ._render_prompt ("agents.request_flow_analyzer.user_prompt" ),
86+ file_path = self ._config .repo_path / ".ai" / "docs" / "request_flow_analysis.md" ,
9887 )
9988
10089 if not self ._config .exclude_api_analysis :
101- analysis_files .append (
102- self ._config .repo_path / ".ai" / "docs" / "api_analysis.md" ,
103- )
104- tasks .append (
105- self ._run_agent (
106- agent = self ._api_analyzer_agent ,
107- user_prompt = self ._render_prompt ("agents.api_analyzer.user_prompt" ),
108- file_path = self ._config .repo_path / ".ai" / "docs" / "api_analysis.md" ,
109- )
90+ agent = self ._api_analyzer_agent
91+ analysis_files .append (self ._config .repo_path / ".ai" / "docs" / "api_analysis.md" )
92+ agent_tasks [agent .name ] = self ._run_agent (
93+ agent = agent ,
94+ user_prompt = self ._render_prompt ("agents.api_analyzer.user_prompt" ),
95+ file_path = self ._config .repo_path / ".ai" / "docs" / "api_analysis.md" ,
11096 )
11197
11298 Logger .debug ("Running all agents" )
11399
114- # Run all agents concurrently, continue even if some fail
115- results = await asyncio .gather (* tasks , return_exceptions = True )
100+ # Run all agents concurrently
101+ results = await asyncio .gather (* agent_tasks . values () , return_exceptions = True )
116102
117103 Logger .debug ("All agents finished" )
118104
119- # Log results for each agent
120- for i , result in enumerate ( results ):
105+ # Log results with agent names
106+ for agent_name , result in zip ( agent_tasks . keys (), results ):
121107 if isinstance (result , Exception ):
122- Logger .error (
123- f"Agent #{ i } failed: { result } " ,
124- exc_info = True ,
125- )
108+ Logger .error (f"Agent { agent_name } failed: { result } " , exc_info = True )
126109 else :
127- Logger .info (
128- f"Agent #{ i } completed successfully" ,
129- )
110+ Logger .info (f"Agent { agent_name } completed successfully" )
130111
131112 self .validate_succession (analysis_files )
132113
114+
133115 def validate_succession (self , analysis_files : List [Path ]):
134116 missing_files = []
135117 for file in analysis_files :
0 commit comments