1818UNIT_TESTS_INFO_HEADER = "\n \n >>> Here are the Unit Tests Information:\n "
1919LINT_INFO_HEADER = "\n \n >>> Here is the Lint Information:\n "
2020SPEC_INFO_HEADER = "\n \n >>> Here is the Specification Information:\n "
21+ IMPORT_DEPENDENCIES_HEADER = "\n \n >>> Here are the Import Dependencies:\n "
2122# prefix components:
2223space = " "
2324branch = "│ "
@@ -208,7 +209,9 @@ def ignore_cycles(graph: dict) -> list[str]:
208209 return ignore_cycles (graph )
209210
210211
211- def topological_sort_based_on_dependencies (pkg_paths : list [str ]) -> list [str ]:
212+ def topological_sort_based_on_dependencies (
213+ pkg_paths : list [str ],
214+ ) -> tuple [list [str ], dict ]:
212215 """Topological sort based on dependencies."""
213216 module_set = ModuleSet ([str (p ) for p in pkg_paths ])
214217
@@ -224,7 +227,7 @@ def topological_sort_based_on_dependencies(pkg_paths: list[str]) -> list[str]:
224227
225228 import_dependencies_files = ignore_cycles (import_dependencies )
226229
227- return import_dependencies_files
230+ return import_dependencies_files , import_dependencies
228231
229232
230233def get_target_edit_files (
@@ -233,7 +236,7 @@ def get_target_edit_files(
233236 test_dir : str ,
234237 latest_commit : str ,
235238 reference_commit : str ,
236- ) -> list [str ]:
239+ ) -> tuple [ list [str ], dict ]:
237240 """Find the files with functions with the pass statement."""
238241 target_dir = str (local_repo .working_dir )
239242 files = _find_files_to_edit (target_dir , src_dir , test_dir )
@@ -248,7 +251,9 @@ def get_target_edit_files(
248251 # Change to reference commit to get the correct dependencies
249252 local_repo .git .checkout (reference_commit )
250253
251- topological_sort_files = topological_sort_based_on_dependencies (filtered_files )
254+ topological_sort_files , import_dependencies = (
255+ topological_sort_based_on_dependencies (filtered_files )
256+ )
252257 if len (topological_sort_files ) != len (filtered_files ):
253258 if len (topological_sort_files ) < len (filtered_files ):
254259 # Find the missing elements
@@ -271,7 +276,14 @@ def get_target_edit_files(
271276 file .replace (target_dir , "" ).lstrip ("/" ) for file in topological_sort_files
272277 ]
273278
274- return topological_sort_files
279+ # Remove the base_dir prefix from import dependencies
280+ import_dependencies_without_prefix = {}
281+ for key , value in import_dependencies .items ():
282+ key_without_prefix = key .replace (target_dir , "" ).lstrip ("/" )
283+ value_without_prefix = [v .replace (target_dir , "" ).lstrip ("/" ) for v in value ]
284+ import_dependencies_without_prefix [key_without_prefix ] = value_without_prefix
285+
286+ return topological_sort_files , import_dependencies_without_prefix
275287
276288
277289def get_message (
@@ -331,6 +343,20 @@ def get_message(
331343 return message_to_agent
332344
333345
346+ def update_message_with_dependencies (message : str , dependencies : list [str ]) -> str :
347+ """Update the message with the dependencies."""
348+ if len (dependencies ) == 0 :
349+ return message
350+ import_dependencies_info = f"\n { IMPORT_DEPENDENCIES_HEADER } "
351+ for dependency in dependencies :
352+ with open (dependency , "r" ) as file :
353+ import_dependencies_info += (
354+ f"\n Here is the content of the file { dependency } :\n { file .read ()} "
355+ )
356+ message += import_dependencies_info
357+ return message
358+
359+
334360def get_specification (specification_pdf_path : Path ) -> str :
335361 """Get the reference for a given specification PDF path."""
336362 # TODO: after pdf_to_text is available, use it to extract the text from the PDF
0 commit comments