feat(review): add /review leveraging Kimi's agent capabilities#832
Draft
chengluyu wants to merge 116 commits into
Draft
feat(review): add /review leveraging Kimi's agent capabilities#832chengluyu wants to merge 116 commits into
/review leveraging Kimi's agent capabilities#832chengluyu wants to merge 116 commits into
Conversation
Add an 'e' key to the full-screen reader that writes the review Markdown and flashes the path (or a failure note). The reader and /review export now share one exportReviewArtifact helper, and the footer shows the export hint only when an exporter is wired.
Append a gray line to the 'browsed' note shown when the reader closes, pointing the user to ask Kimi to fix the comments or discuss them in chat. Only shown when the review has comments.
Accept an optional directions[] on ReviewStartInput and use it as the fan-out axis for thorough (one reviewer per direction) and deep (directions x file groups) reviews. Falls back to the built-in default perspectives when no directions are supplied, so current behavior is unchanged until the pilot review starts providing them.
Render the file path gray and bold (in nested and single-comment forms), add a colon after 'Line N', and pad the 'Line N:' tags to a common width so the comment titles align across rows.
Indent the follow-up line to align with the heading text and prefix it with 'Tips:' in secondary gray (textDim).
Introduce a RunCodeReview builtin that the main agent calls after its pilot analysis to fan out reviewers. It carries the pilot's background briefing, directions, target, and intensity, and runs the orchestrator from inside the turn via a new Session.runReviewFanOut entry injected into the main agent as the reviewFanOut capability (gated on the code_review flag). The agent-authored background and change type are threaded into ReviewBackground so reviewers see them. Reviewer subagents nest under the tool call; cancellation rides the tool signal.
Remove the wave labelAnimation from the Deep Review intensity option and the now-unused review-side animation plumbing. The generic ChoicePicker animation support is left intact.
Render the comment band's body through the shared renderMarkdownLines (pi-tui Markdown + the chat markdown theme) instead of plain word-wrap, so bold/code/lists match the rest of the chat. The heading stays plain.
Order the full-screen browser's comments by severity (critical first), then file path, then line number. The comparator ignores state, so the order stays stable across reject/restore.
/review now seeds two main-agent turns instead of an out-of-band RPC: turn 1 the agent pilots the diff and writes a background briefing + review directions; turn 2 it calls RunCodeReview to fan out the reviewers. Session gains runPilotedReview (exposed over RPC and the node SDK), which sequences the turns via waitForCurrentTurn using system_trigger-origin prompts, and captures the fan-out result. The TUI drops the 'Review perspectives' confirmation dialog and the previewReviewPlan step. Because the pilot reasoning, tool call, and result are ordinary conversation records, the review now persists and replays. Interim: the review still renders via the existing compact block from the returned result; rendering the colored block from the persisted tool result on replay is the next step.
Extend ReviewCommit with optional filesChanged/additions/deletions (from git --shortstat) and hasBody, and parse them in listReviewCommits using a record/field-separated --format. Enables a richer commit picker.
Render each commit in the 'Select a commit' menu as two lines: an 8-char short hash (orange) + bold one-line subject (… when truncated, ↵ when the message has a body), then files changed with colored +/- and a relative time via Intl.RelativeTimeFormat. Adds an opt-in custom row renderer to ChoicePicker so options can draw multi-colored content.
The tool instance was registered when the code_review flag is on, but the main agent profile's tool allowlist (agent.yaml) didn't include it, so it was filtered out before the model saw it — the pilot turn ran but the agent had no RunCodeReview tool to call. Add it to the allowlist (harmless when the flag is off, since no instance is registered) and guard it with a profile test.
Resolve the display locale from LC_ALL/LC_MESSAGES/LANG/LANGUAGE (BCP-47), silently falling back to en for unset, C/POSIX, unsupported, or malformed locales. formatRelativeTime takes an optional locale (defaulting to the detected one) so callers and tests stay deterministic.
Now that the tool is allowlisted on the main agent, users can request a review verbally (without /review), where the tool description is the only guidance the agent has. Rewrite it to cover when to use the tool, how to resolve target without the scope picker, and how to choose intensity without the intensity picker.
Add a blank line above the follow-up tip when a rejected list precedes it, and render the tip in the tool-output dim gray (currentTheme.dim).
Display 'N kept' alongside the rejected count in the Code review browsed heading (rejected shown only when non-zero).
The post-review selector and /review read already cover reopening, so the compact Code review block no longer prints the reopen command line.
In the full-screen reader's comment band, render the severity (colored) and the title (bold) as a title bar, separated from the body by a ┠ rule.
Give the full-screen reader's left list more room: a severity line (with the reject status right-aligned and the severity color preserved), the wrapped title with the selection caret on its first line, and a path line in secondary gray.
Render the full-screen reader's status line in normal text with only the key characters (↑/↓, j/k, y, n, e, q) bold, instead of the whole hint in the primary accent color.
Apply abbreviatePath (40-col cap) to the paths shown in review tool activity labels (AddComment, MergeComments, ReadDiff, ReadFileVersion, GetComments), so deep paths elide their middle instead of overflowing the line.
truncateToWidth injects ANSI reset codes around its ellipsis, so coloring its result left the ellipsis (and trailing) uncolored. Add clipToWidth (plain truncation, no ANSI) and use it for the commit-picker and diff-view band titles; also make abbreviatePath's end-segment truncation reset-free.
Replace the fixed 40-col cap with a width-aware budget derived from process.stdout.columns (reserving room for the label chrome). Paths are left intact when they fit or when the width is unknown (non-TTY/tests), and only shortened to fit a genuinely narrow terminal.
Measure the widest file/+/- fields across the listed commits and pad each row to those widths, so the file count, additions and deletions line up in fixed columns with the numbers right-aligned.
Add %ae (author email), %D (branch/tag names), and the message body to listReviewCommits, exposed as ReviewCommit.authorEmail / refs / body, so the commit picker can search by any of them.
Replace pagination in the commit picker with a continuous scroll window (no page numbers, since only the 50 most recent are loaded and pagination would imply completeness), ending in a hint to refine the search. Add an opt-in ChoicePicker scroll mode + per-option searchText, and search commits by full/short hash, message, body, author, email, and branch/tag.
🦋 Changeset detectedLatest commit: 15e49f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Related Issue
Resolve #(issue_number)
Problem
What changed
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.