-
Notifications
You must be signed in to change notification settings - Fork 0
Restore Code AI and PR Review Options #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SayanthRock
merged 1 commit into
main
from
jules-restore-ai-features-12448723504427470280
Aug 8, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
81 changes: 81 additions & 0 deletions
81
app/src/main/java/com/sayanthrock/freeairock/data/ai/AiCodeAnalyzer.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package com.sayanthrock.freeairock.data.ai | ||
|
|
||
| class AiCodeAnalyzer(private val pollinationsApiService: PollinationsApiService) { | ||
|
|
||
| suspend fun analyzeCode(fileName: String, rawCode: String): String { | ||
| val safeFileName = fileName.ifBlank { "selected-file" } | ||
| val prompt = buildString { | ||
| appendLine("You are an expert software developer.") | ||
| appendLine("Analyze the file named '$safeFileName'.") | ||
| appendLine("Explain its core functionality, architecture role, important methods, risks, and improvement ideas.") | ||
| appendLine("Keep the explanation clear for a junior developer.") | ||
| appendLine() | ||
| appendLine("Code:") | ||
| appendLine("```") | ||
| appendLine(rawCode.take(MAX_CODE_CHARS)) | ||
| appendLine("```") | ||
| } | ||
|
|
||
| return generateText(prompt, "No explanation generated.") | ||
| } | ||
|
|
||
| suspend fun summarizePullRequest(diffCode: String): String { | ||
| val prompt = buildString { | ||
| appendLine("You are an expert lead developer reviewing a pull request.") | ||
| appendLine("Analyze the following Git diff.") | ||
| appendLine("Do not read line-by-line changes back to the user.") | ||
| appendLine("Explain the high-level purpose, likely bug fix or feature, architecture impact, risk, and testing notes.") | ||
| appendLine("Keep the explanation approachable for a junior developer.") | ||
| appendLine() | ||
| appendLine("Git diff:") | ||
| appendLine("```diff") | ||
| appendLine(diffCode.take(MAX_DIFF_CHARS)) | ||
| appendLine("```") | ||
| } | ||
|
|
||
| return generateText(prompt, "No pull request explanation generated.") | ||
| } | ||
|
|
||
| suspend fun summarizePullRequest(owner: String, repo: String, pullNumber: Int, diffText: String): String { | ||
| val safeOwner = owner.ifBlank { "owner" } | ||
| val safeRepo = repo.ifBlank { "repo" } | ||
| val prompt = buildString { | ||
| appendLine("You are a senior code reviewer.") | ||
| appendLine("Summarize pull request #$pullNumber in $safeOwner/$safeRepo using the Git diff below.") | ||
| appendLine("Focus on developer impact, affected files, behavior changes, risks, testing notes, and release notes.") | ||
| appendLine("Use clear plain English. Avoid repeating every line of the diff.") | ||
| appendLine() | ||
| appendLine("Return this structure:") | ||
| appendLine("1. Summary") | ||
| appendLine("2. Key changes") | ||
| appendLine("3. Risk level") | ||
| appendLine("4. Testing checklist") | ||
| appendLine("5. Suggested release note") | ||
| appendLine() | ||
| appendLine("Git diff:") | ||
| appendLine("```diff") | ||
| appendLine(diffText.take(MAX_DIFF_CHARS)) | ||
| appendLine("```") | ||
| } | ||
|
|
||
| return generateText(prompt, "No pull request summary generated.") | ||
| } | ||
|
|
||
| private suspend fun generateText(prompt: String, fallback: String): String { | ||
| return try { | ||
| val response = pollinationsApiService.generateText( | ||
| PollinationsRequest( | ||
| messages = listOf(PollinationsMessage(role = "user", content = prompt)) | ||
| ) | ||
| ) | ||
| response.takeIf { it.isNotBlank() } ?: fallback | ||
| } catch (error: Exception) { | ||
| "AI analysis failed: ${error.localizedMessage ?: "Unknown error"}" | ||
| } | ||
|
SayanthRock marked this conversation as resolved.
SayanthRock marked this conversation as resolved.
|
||
| } | ||
|
|
||
| companion object { | ||
| private const val MAX_CODE_CHARS = 12000 | ||
| private const val MAX_DIFF_CHARS = 18000 | ||
| } | ||
| } | ||
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/sayanthrock/freeairock/data/ai/CodeAnalysisState.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.sayanthrock.freeairock.data.ai | ||
|
|
||
| sealed interface CodeAnalysisState { | ||
| data object Idle : CodeAnalysisState | ||
| data object Loading : CodeAnalysisState | ||
| data class Success(val result: String) : CodeAnalysisState | ||
| data class Error(val message: String) : CodeAnalysisState | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.