Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/ai_review.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
5 changes: 4 additions & 1 deletion docs/ai-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* **
* **

## 6. Nit Picking
* **Foo:** Use of foo or Bar as keywords is offensive to the FooBar people and should be avoided at all costs.
Comment on lines +38 to +41
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bullet point on line 38 is incomplete, and the 'Nit Picking' section (lines 40-41) is unprofessional and unnecessary for a technical standards document. It is recommended to remove these lines.

5 changes: 5 additions & 0 deletions lib/test_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Violation of 1. Widget Performance & Lifecycle - Const Constructors: The TestView constructor should be marked const as it only takes a Key? key parameter, which is a constant expression. Marking constructors const for widgets with immutable parameters allows Flutter to optimize rebuilds.


// stupid comment. okease delete
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment ('// stupid comment. okease delete') is unprofessional and adds no value to the codebase. Please remove it entirely.

// todo

// some other commit
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment ('// some other commit') appears to be a leftover from development or version control and should be removed to maintain code clarity and professionalism.


Comment on lines +7 to +11
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These comments appear to be temporary notes or placeholders. They should be removed to maintain the professionalism and cleanliness of the codebase.

@override
// ignore: library_private_types_in_public_api
_TestViewState createState() => _TestViewState();
Expand Down
33 changes: 23 additions & 10 deletions scripts/ai_reviewer/review-agent.py
Original file line number Diff line number Diff line change
@@ -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...")
Expand All @@ -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")
Comment on lines +32 to +34
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This loop prints all available models to the console. This is likely debug code and should be removed from the production script to keep the output clean.


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:
Expand All @@ -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:
Expand Down Expand Up @@ -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',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The model name 'gemini-2.5-flash' appears to be incorrect. Valid model names currently include 'gemini-1.5-flash' or 'gemini-2.0-flash'. Using an invalid model name will cause the script to fail.

Suggested change
model='gemini-2.5-flash',
model='gemini-2.0-flash',

contents=prompt,
)
print("✨ Received response from Gemini.")
return response.text, latest_commit

Expand Down Expand Up @@ -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.")

Expand Down