-
Notifications
You must be signed in to change notification settings - Fork 3k
Feat/local review mode #5400
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
Merged
Feat/local review mode #5400
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7bbd02c
Add local review mode to cli and vscode
5a49128
add changeset
4153e33
fix tests
bd446d9
Merge branch 'main' into feat/local-review-mode
chrarnoldus 72e3350
Update packages/types/src/vscode-extension-host.ts
Sureshkumars 08c5c55
Update packages/types/src/vscode-extension-host.ts
Sureshkumars 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "kilo-code": major | ||
| "@kilocode/cli": patch | ||
| --- | ||
|
|
||
| Add Local review mode |
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
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
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
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
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,168 @@ | ||
| // kilocode_change - new file | ||
|
|
||
| /** | ||
| * Review Service | ||
| * | ||
| * Lightweight service for gathering review scope information. | ||
| * The actual review is done dynamically by the agent using tools. | ||
| */ | ||
|
|
||
| import type { ReviewSummary, ReviewScopeInfo, ReviewServiceOptions, FileSummary, FileStatus } from "./types" | ||
| import { | ||
| getCurrentBranch, | ||
| detectBaseBranch, | ||
| hasUncommittedChanges, | ||
| getUncommittedFiles, | ||
| getBranchFilesChanged, | ||
| isOnBaseBranch, | ||
| type GitFileChange, | ||
| } from "../../utils/git" | ||
|
|
||
| /** | ||
| * Converts git status code to FileStatus | ||
| */ | ||
| function gitStatusToFileStatus(status: string): FileStatus { | ||
| const upper = status.toUpperCase() | ||
| if (upper === "A" || upper === "?") return "A" | ||
|
Sureshkumars marked this conversation as resolved.
|
||
| if (upper === "M") return "M" | ||
| if (upper === "D") return "D" | ||
| if (upper === "R") return "R" | ||
| if (upper === "C") return "C" | ||
| if (upper === "U") return "U" | ||
| return "M" // Default to modified | ||
| } | ||
|
|
||
| /** | ||
| * Converts GitFileChange array to FileSummary array | ||
| */ | ||
| function toFileSummaries(files: GitFileChange[]): FileSummary[] { | ||
| return files.map((file) => ({ | ||
| path: file.path, | ||
| status: gitStatusToFileStatus(file.status), | ||
| oldPath: file.oldPath, | ||
| })) | ||
| } | ||
|
|
||
| /** | ||
| * ReviewService - Provides review scope information for the UI | ||
| * and lightweight summaries for the agent to start reviews | ||
| */ | ||
| export class ReviewService { | ||
| private cwd: string | ||
|
|
||
| constructor(options: ReviewServiceOptions) { | ||
| this.cwd = options.cwd | ||
| } | ||
|
|
||
| /** | ||
| * Gets information about available review scopes | ||
| * Used by UI to show preview before user selects | ||
| */ | ||
| async getScopeInfo(): Promise<ReviewScopeInfo> { | ||
| try { | ||
| // Get current branch | ||
| const currentBranch = (await getCurrentBranch(this.cwd)) || "HEAD" | ||
|
|
||
| // Check uncommitted changes | ||
| const hasUncommitted = await hasUncommittedChanges(this.cwd) | ||
| const uncommittedFiles = hasUncommitted ? await getUncommittedFiles(this.cwd) : [] | ||
|
|
||
| // Check branch diff - available as long as not on base branch | ||
| const onBaseBranch = await isOnBaseBranch(this.cwd) | ||
| const baseBranch = await detectBaseBranch(this.cwd) | ||
| const branchFiles = !onBaseBranch ? await getBranchFilesChanged(this.cwd, baseBranch) : [] | ||
|
|
||
| const result = { | ||
| uncommitted: { | ||
| available: hasUncommitted, | ||
| fileCount: uncommittedFiles.length, | ||
| filePreview: uncommittedFiles.slice(0, 5).map((f) => f.path), | ||
| }, | ||
| branch: { | ||
| available: !onBaseBranch, | ||
| currentBranch, | ||
| baseBranch, | ||
| fileCount: branchFiles.length, | ||
| filePreview: branchFiles.slice(0, 5).map((f) => f.path), | ||
| }, | ||
| } | ||
|
|
||
| return result | ||
| } catch (error) { | ||
| console.error("Error getting scope info:", error) | ||
| return { | ||
| uncommitted: { | ||
| available: false, | ||
| fileCount: 0, | ||
| }, | ||
| branch: { | ||
| available: false, | ||
| currentBranch: "unknown", | ||
| baseBranch: "main", | ||
| fileCount: 0, | ||
| }, | ||
| error: error instanceof Error ? error.message : String(error), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets a lightweight review summary for the selected scope | ||
| * This provides minimal context - the agent will explore details with tools | ||
| */ | ||
| async getReviewSummary(scope: "uncommitted" | "branch"): Promise<ReviewSummary> { | ||
| try { | ||
| const currentBranch = (await getCurrentBranch(this.cwd)) || "HEAD" | ||
|
|
||
| if (scope === "uncommitted") { | ||
| return this.getUncommittedSummary(currentBranch) | ||
| } else { | ||
| return this.getBranchSummary(currentBranch) | ||
| } | ||
| } catch (error) { | ||
| console.error(`Error getting review summary for ${scope}:`, error) | ||
| return { | ||
| scope, | ||
| currentBranch: "unknown", | ||
| files: [], | ||
| totalFiles: 0, | ||
| hasChanges: false, | ||
| error: error instanceof Error ? error.message : String(error), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets summary for uncommitted changes | ||
| */ | ||
| private async getUncommittedSummary(currentBranch: string): Promise<ReviewSummary> { | ||
| const gitFiles = await getUncommittedFiles(this.cwd) | ||
| const files = toFileSummaries(gitFiles) | ||
|
|
||
| return { | ||
| scope: "uncommitted", | ||
| currentBranch, | ||
| files, | ||
| totalFiles: files.length, | ||
| hasChanges: files.length > 0, | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets summary for branch comparison | ||
| */ | ||
| private async getBranchSummary(currentBranch: string): Promise<ReviewSummary> { | ||
| const baseBranch = await detectBaseBranch(this.cwd) | ||
| const gitFiles = await getBranchFilesChanged(this.cwd, baseBranch) | ||
| const files = toFileSummaries(gitFiles) | ||
|
|
||
| return { | ||
| scope: "branch", | ||
| currentBranch, | ||
| baseBranch, | ||
| files, | ||
| totalFiles: files.length, | ||
| hasChanges: files.length > 0, | ||
| } | ||
| } | ||
| } | ||
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.