| 238 | |
| 239 | |
| 240 | class AnalyzeRelationships(Node): |
| 241 | def prep(self, shared): |
| 242 | abstractions = shared[ |
| 243 | "abstractions" |
| 244 | ] # Now contains 'files' list of indices, name/description potentially translated |
| 245 | files_data = shared["files"] |
| 246 | project_name = shared["project_name"] # Get project name |
| 247 | language = shared.get("language", "english") # Get language |
| 248 | use_cache = shared.get("use_cache", True) # Get use_cache flag, default to True |
| 249 | |
| 250 | # Get the actual number of abstractions directly |
| 251 | num_abstractions = len(abstractions) |
| 252 | |
| 253 | # Create context with abstraction names, indices, descriptions, and relevant file snippets |
| 254 | context = "Identified Abstractions:\\n" |
| 255 | all_relevant_indices = set() |
| 256 | abstraction_info_for_prompt = [] |
| 257 | for i, abstr in enumerate(abstractions): |
| 258 | # Use 'files' which contains indices directly |
| 259 | file_indices_str = ", ".join(map(str, abstr["files"])) |
| 260 | # Abstraction name and description might be translated already |
| 261 | info_line = f"- Index {i}: {abstr['name']} (Relevant file indices: [{file_indices_str}])\\n Description: {abstr['description']}" |
| 262 | context += info_line + "\\n" |
| 263 | abstraction_info_for_prompt.append( |
| 264 | f"{i} # {abstr['name']}" |
| 265 | ) # Use potentially translated name here too |
| 266 | all_relevant_indices.update(abstr["files"]) |
| 267 | |
| 268 | context += "\\nRelevant File Snippets (Referenced by Index and Path):\\n" |
| 269 | # Get content for relevant files using helper |
| 270 | relevant_files_content_map = get_content_for_indices( |
| 271 | files_data, sorted(list(all_relevant_indices)) |
| 272 | ) |
| 273 | # Format file content for context |
| 274 | file_context_str = "\\n\\n".join( |
| 275 | f"--- File: {idx_path} ---\\n{content}" |
| 276 | for idx_path, content in relevant_files_content_map.items() |
| 277 | ) |
| 278 | context += file_context_str |
| 279 | |
| 280 | return ( |
| 281 | context, |
| 282 | "\n".join(abstraction_info_for_prompt), |
| 283 | num_abstractions, # Pass the actual count |
| 284 | project_name, |
| 285 | language, |
| 286 | use_cache, |
| 287 | ) # Return use_cache |
| 288 | |
| 289 | def exec(self, prep_res): |
| 290 | ( |
| 291 | context, |
| 292 | abstraction_listing, |
| 293 | num_abstractions, # Receive the actual count |
| 294 | project_name, |
| 295 | language, |
| 296 | use_cache, |
| 297 | ) = prep_res # Unpack use_cache |
no outgoing calls
no test coverage detected