()
| 68 | # ============================================================================ |
| 69 | |
| 70 | async def main(): |
| 71 | print("🔍 PR Age Chart Generator\n") |
| 72 | |
| 73 | # Determine the repository |
| 74 | args = parse_args() |
| 75 | repo = None |
| 76 | |
| 77 | if "repo" in args: |
| 78 | repo = args["repo"] |
| 79 | print(f"📦 Using specified repo: {repo}") |
| 80 | elif is_git_repo(): |
| 81 | detected = get_github_remote() |
| 82 | if detected: |
| 83 | repo = detected |
| 84 | print(f"📦 Detected GitHub repo: {repo}") |
| 85 | else: |
| 86 | print("⚠️ Git repo found but no GitHub remote detected.") |
| 87 | repo = prompt_for_repo() |
| 88 | else: |
| 89 | print("📁 Not in a git repository.") |
| 90 | repo = prompt_for_repo() |
| 91 | |
| 92 | if not repo or "/" not in repo: |
| 93 | print("❌ Invalid repo format. Expected: owner/repo") |
| 94 | sys.exit(1) |
| 95 | |
| 96 | owner, repo_name = repo.split("/", 1) |
| 97 | |
| 98 | # Create Copilot client |
| 99 | client = CopilotClient() |
| 100 | await client.start() |
| 101 | |
| 102 | session = await client.create_session(SessionConfig( |
| 103 | model="gpt-5", |
| 104 | system_message={ |
| 105 | "content": f""" |
| 106 | <context> |
| 107 | You are analyzing pull requests for the GitHub repository: {owner}/{repo_name} |
| 108 | The current working directory is: {os.getcwd()} |
| 109 | </context> |
| 110 | |
| 111 | <instructions> |
| 112 | - Use the GitHub MCP Server tools to fetch PR data |
| 113 | - Use your file and code execution tools to generate charts |
| 114 | - Save any generated images to the current working directory |
| 115 | - Be concise in your responses |
| 116 | </instructions> |
| 117 | """ |
| 118 | }, |
| 119 | on_permission_request=PermissionHandler.approve_all)) |
| 120 | |
| 121 | done = asyncio.Event() |
| 122 | |
| 123 | # Set up event handling |
| 124 | def handle_event(event: SessionEvent): |
| 125 | if event.type.value == "assistant.message": |
| 126 | print(f"\n🤖 {event.data.content}\n") |
| 127 | elif event.type.value == "tool.execution_start": |
no test coverage detected