feat(aireview): add AI code review support#38348
Open
mehrabix wants to merge 35 commits into
Open
Conversation
Implement AI code review feature for pull requests with provider-agnostic design supporting any OpenAI-compatible API (OpenRouter, OpenAI, etc.). - Config: [ai_review] section in app.ini (ENABLED, API_TOKEN, MODEL, etc.) - Provider interface with OpenAI-compatible implementation - Async queue-backed notifier hooks on PR open/synchronize - PR diff fetcher with per-file splitting and language detection - Review orchestrator that calls AI and posts review via pull_service.SubmitReview() Assisted-by: AI:opencode
Assisted-by: AI:opencode
Use pull_service.CreateCodeComment() with pendingReview=true for each AI finding that has a file + line number, then SubmitReview() to publish all inline comments with an overview summary. Findings without a valid inline location fall back to the review body. Assisted-by: AI:opencode
Adds a commit review cache to avoid re-reviewing unchanged PRs when new commits are pushed. Adds EXCLUDE_PATHS config option with filepath.Match glob support for skipping vendor, generated, and lock files. Assisted-by: AI:opencode
- Change ReviewRequest to accept all changed files in a single API call - Update buildReviewPrompt for multi-file diffs - Add SystemPrompt config field in AIRreview settings - Refactor reviewer.go to send one request with all non-excluded files - Remove FormatReviewOutput and sortedKeys (no longer used) Assisted-by: opencode:deepseek-v4-flash-free
- Add WalkthroughSection and Architecture fields to ReviewResponse - Update system prompt to request structured walkthrough with Mermaid diagrams - Render walkthrough as collapsible section, architecture as mermaid code block - Add per-repo config (.gitea/ai-review.yaml) with enabled, system_prompt, exclude_paths, and path_instructions settings - MergeRepoConfig merges per-repo config over global defaults - Tests for MergeRepoConfig and formatReviewBody Assisted-by: opencode:deepseek-v4-flash-free
- Add HandlePRComment to detect and respond to @AIReview mentions on PRs - Add Chat method to OpenAIProvider for conversational (non-JSON) responses - Store conversation history per PR in-memory for context - Wire CreateIssueComment notifier to trigger chat responses - Conversation includes full PR diff context Assisted-by: opencode:deepseek-v4-flash-free
Assisted-by: opencode:deepseek-v4-flash-free
- Add SuggestedFix struct (old_code / new_code) to ReviewComment - Update system prompt to request suggested fixes from AI - Render suggested fixes as collapsible before/after code blocks - Tests for SuggestedFix parsing and rendering Assisted-by: opencode:deepseek-v4-flash-free
- Add SortFilesByDependency using Kahn's algorithm on import graph - Detect Go, JS/TS, Python imports from diff patches - Import matching handles module paths (e.g. gitea.dev/services/core) - Files sorted so dependencies come before dependents - Stable ordering by path depth and alphabetically within same level Assisted-by: opencode:deepseek-v4-flash-free
- Add in-memory learning store per repo - Detect feedback patterns in chat messages (ignore, false positive, learn:) - Inject learnings into system prompt for future reviews - Wire chat bot to detect and store learnings from user feedback Assisted-by: opencode:deepseek-v4-flash-free
- Update system prompt to detect missing docstrings on public APIs - AI provides suggested_fix with docstrings to add - Reuses existing SuggestedFix infrastructure Assisted-by: opencode:deepseek-v4-flash-free
- Add StatusStore tracking review state per PR (pending/running/completed/issues_found/error) - Wire status updates into reviewer.go - Add GET /ai-review/status endpoint returning JSON with status and issue count Assisted-by: opencode:deepseek-v4-flash-free
- Chat commands: @AIReview re-run (clears cache and re-triggers review) - Chat commands: @AIReview dismiss file.go:42 (skips finding in future reviews) - Add Clear method to commitCache, DismissFinding/IsFindingDismissed to status store - Filter dismissed findings in reviewer.go before posting comments Assisted-by: opencode:deepseek-v4-flash-free
- Add BuildCodeGraph to extract exports and cross-file imports from diffs - Support Go (func/type/var), JS/TS (export), Python (def/class) - Inject code relationship graph into the review prompt - Helps AI understand cross-file impact of changes Assisted-by: opencode:deepseek-v4-flash-free
- Add CustomChecks to per-repo YAML config - Add CheckResult type to ReviewResponse - Append checks to user prompt for AI evaluation - Render pass/fail results in review body - Tests for custom checks in MergeRepoConfig Assisted-by: opencode:deepseek-v4-flash-free
Assisted-by: opencode:deepseek-v4-flash-free
- Detect common linter configs (.golangci.yml, .eslintrc, etc.) from repo - Include detected linter config info in review prompt - Helps AI align with project linting rules Assisted-by: opencode:deepseek-v4-flash-free
- Parse PR description for GitHub-style (Fixes go-gitea#123) and Jira-style (PROJ-123) references - Include referenced issue IDs in the review prompt for context Assisted-by: opencode:deepseek-v4-flash-free
- Add GenerateSprintReport to list open PRs with AI summarization - Chat-triggered report generation for quick standup summaries Assisted-by: opencode:deepseek-v4-flash-free
- Add ai-review CLI subcommand reading from stdin (git diff), file, or diff path - Uses configured AI provider to review local changes and print results - Integration with existing urfave/cli v3 framework Assisted-by: opencode:deepseek-v4-flash-free
Remove comments that merely describe what code does (narrate code) without explaining why. Keep Go-standard exported symbol docs and comments that explain rationale. Also fix indentation bug in reviewer.go and add build artifacts to .gitignore. Assisted-by: opencode:deepseek-v4-flash-free
Add provider implementations for: - Anthropic (Claude) - uses /v1/messages with x-api-key auth - Google Gemini - uses /v1beta/models with query param auth Promote Chat to the Provider interface so all providers support both review and conversational chat. chatMessage type consolidated into shared ChatMessage in provider.go. Add auto-detection (PROVIDER=auto) that maps API URLs: - anthropic.com -> anthropic - googleapis.com/generativelanguage -> gemini - anything else -> openai (covers all OpenAI-compatible APIs) Users can now freely use any provider by setting: PROVIDER = anthropic | gemini | openai | openrouter | auto API_URL = <provider endpoint> API_TOKEN = <your api key> MODEL = <model name> Assisted-by: opencode:deepseek-v4-flash-free
Assisted-by: opencode:deepseek-v4-flash-free
… return Add blank lines between internal and external import groups in aireview.go and config.go. Replace bare return with explicit values in MergeRepoConfig early return. Assisted-by: opnucp:opencode-v3
Also satisfy golangci-lint fmt requirement that all returns in named-return functions must be explicit. Assisted-by: opnucp:opencode-v3
- perfsprint: fmt.Errorf -> errors.New for static strings - perfsprint: fmt.Sprintf -> string concatenation where simpler - staticcheck QF1012: WriteString(fmt.Sprintf(...)) -> fmt.Fprintf(...) - govet: remove trailing newline from Println - depguard: encoding/json -> gitea.dev/modules/json - modernize: strings.Split -> strings.SplitSeq - modernize: string += in loops -> strings.Builder - modernize: map copy loop -> maps.Copy - modernize: omitempty on nested struct field - unused: remove defaultBranchForConfig const - nilnil: add nolint comments - errcheck: handle fmt.Sscanf return - mirror: bytes.HasSuffix -> strings.HasSuffix - wastedassign: remove unused initial assignment - staticcheck S1016: type conversion instead of struct literal Assisted-by: opnucp:opencode-v3
Assisted-by: opnucp:opencode-v3
…pic, config - Replace remaining WriteString(fmt.Sprintf(...)) with fmt.Fprintf(...) - Replace string += in loop with strings.Builder in anthropic.go - Add explanations to //nolint: nilnil directives Assisted-by: opnucp:opencode-v3
Adds a Vue component (AIRreviewStatus.vue) that fetches review status from the existing JSON endpoint and displays a compact badge with icon in the merge box area. Shows pending/running/completed/error states. Assisted-by: opnucp:opencode-v3
- Replace bare fetch() with GET() import from modules/fetch.ts - Replace .then() with await (unicorn/prefer-await) - Fix Tailwind color classes: tw-text-yellow-700 -> tw-text-orange, tw-text-gray -> tw-text-secondary Assisted-by: opencode:deepseek-v4-flash-free
- Add break to each case in iconClass computed to prevent fallthrough - Add v-if to SvgIcon to avoid passing empty string as SvgName type Assisted-by: opencode:deepseek-v4-flash-free
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.