diff --git a/.github/workflows/ai_review.yml b/.github/workflows/ai_review.yml index 9c73b8b..dfb3194 100644 --- a/.github/workflows/ai_review.yml +++ b/.github/workflows/ai_review.yml @@ -1,5 +1,8 @@ name: AI PR Reviewer - +permissions: + issues: write + pull-requests: write + contents: read on: pull_request: # Restricts the agent to specific testing branches or main @@ -39,7 +42,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install PyGithub google-generativeai + pip install PyGithub google-genai + - name: Run Review Agent env: @@ -49,4 +53,4 @@ jobs: run: | # Use the input PR number if triggered manually, otherwise use the event context PR_NUM=${{ github.event.inputs.pr_number || github.event.pull_request.number }} - python scripts/ai_reviewer/review_agent.py $PR_NUM + python scripts/ai_reviewer/review-agent.py $PR_NUM diff --git a/docs/ai-standards.md b/docs/ai-standards.md index 7ea72b6..ad037d9 100644 --- a/docs/ai-standards.md +++ b/docs/ai-standards.md @@ -35,4 +35,7 @@ You are a Senior Flutter Architect. Your mission is to ensure that all Dart code * **Resource Resilience:** Ensure that CLI or native tool interactions (via `Process.run`) handle timeouts and provide meaningful error messages for missing SDKs. ## 6. Testing & Quality Assurance -* ** \ No newline at end of file +* ** + +## 6. Nit Picking +* **Foo:** Use of foo or Bar as keywords is offensive to the FooBar people and should be avoided at all costs. diff --git a/lib/test_view.dart b/lib/test_view.dart index 2d269a7..0ef8525 100644 --- a/lib/test_view.dart +++ b/lib/test_view.dart @@ -4,6 +4,11 @@ class TestView extends StatefulWidget { // Violation 1: Missing 'const' on constructor for a stateless-style widget TestView({Key? key}) : super(key: key); + // stupid comment. okease delete + // todo + + // some other commit + @override // ignore: library_private_types_in_public_api _TestViewState createState() => _TestViewState(); diff --git a/scripts/ai_reviewer/review-agent.py b/scripts/ai_reviewer/review-agent.py index 4b0de3e..67fbd96 100644 --- a/scripts/ai_reviewer/review-agent.py +++ b/scripts/ai_reviewer/review-agent.py @@ -1,8 +1,10 @@ import os import json import sys -from github import Github -import google.generativeai as genai +from github import Auth, Github + +from google.genai import Client + # --- 1. Initialization & Environment Check --- print("🚀 Starting AI Review Agent...") @@ -20,10 +22,19 @@ # --- 2. GitHub & AI Setup --- try: - genai.configure(api_key=GEMINI_API_KEY) - gh = Github(GITHUB_TOKEN) - # Update this string to your actual repo path (e.g., "flutter/flutter-intellij") - repo = gh.get_repo("flutter/flutter-intellij") + + # The client automatically picks up the API key from the environment variable. + # Ensure you have set GEMINI_API_KEY or GOOGLE_API_KEY + # If using Vertex AI, you can initialize with client = Client(vertexai=True) + client = Client() + + + for model in client.models.list(): + print(f"Name: {model.name}") + print(f"Description: {model.description}\n") + + gh = Github(auth=Auth.Token(GITHUB_TOKEN)) + repo = gh.get_repo("cj-radcliff/SimpleFlutterFlashcards") pr = repo.get_pull(PR_NUMBER) print(f"✅ Connected to Repo: {repo.full_name}") except Exception as e: @@ -36,7 +47,7 @@ def get_line_specific_review(): comparison = repo.compare(pr.base.sha, pr.head.sha) is_flutter = any(f.filename.endswith('.dart') for f in comparison.files) - standards_path = "docs/ai-flutter-standards.md" if is_flutter else "docs/ai-standards.md" + standards_path = "docs/ai-standards.md" print(f"📖 Loading standards from: {standards_path}") with open(standards_path, "r") as f: @@ -68,8 +79,10 @@ def get_line_specific_review(): """ print("🤖 Sending request to Gemini...") - model = genai.GenerativeModel('gemini-1.5-pro') - response = model.generate_content(prompt) + response = client.models.generate_content( + model='gemini-2.5-flash', + contents=prompt, + ) print("✨ Received response from Gemini.") return response.text, latest_commit @@ -102,7 +115,7 @@ def apply_feedback(raw_response, commit): if "READY_FOR_HUMAN_REVIEW" in raw_response: print("👤 Triggering handoff: Reassigning to human...") # REPLACE WITH YOUR ACTUAL GITHUB USERNAME - MY_USERNAME = "your-github-username" + MY_USERNAME = "cj-radcliff" pr.add_to_assignees(MY_USERNAME) pr.create_issue_comment(f"✅ AI Review complete. Reassigning to @{MY_USERNAME} for final review.")