Repository navigation
feat(review): add --summary flag for project-level comment consolidation - #916
Closed
lizhengfeng101 wants to merge 5 commits into
Closed
lizhengfeng101 wants to merge 5 commits into
lizhengfeng101 wants to merge 5 commits into
Conversation
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 5 selected item(s). |
Collaborator
|
The mechanics check out. Two small suggestions below:
Also, the |
lizhengfeng101
added a commit
that referenced
this pull request
Aug 19, 2026
- Update stale ProjectSummary() comment in shared.go (no longer claims empty for review mode) - Add tests for review-mode maybeRunProjectSummary and buildSummaryCommentsList in internal/agent/coverage_test.go - Document --summary flag in cli-reference.md for all four locales (en, zh, ja, ru)
yingjiexu2002
previously approved these changes
Aug 20, 2026
yingjiexu2002
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. All feedback addressed — tests added, docs updated across four locales, and the rune-boundary truncation fix is a nice catch.
Add a new --summary flag to `ocr review` that generates a project-level summary after all per-file comments are collected. When enabled, an extra LLM call synthesizes the review findings into a structured markdown overview (Top Issues, Cross-Cutting Concerns, Quick Wins, Overall Assessment). Implementation details: - Add PROJECT_SUMMARY_TASK to the review Template struct with dedicated prompt files (system + user) embedded via task_template.json - Add maybeRunProjectSummary() to the review Agent, mirroring the scan agent's existing pattern - Guard against budget-exceeded and context-cancelled states before the summary LLM call - Use rune-based truncation in buildSummaryCommentsList to safely handle multi-byte characters (CJK, emoji) - Output layer requires no changes: existing ProjectSummary() plumbing in text and JSON formats handles the new content automatically When no comments are produced, no summary is generated and existing "Looks good to me" behavior is preserved unchanged.
- Update stale ProjectSummary() comment in shared.go (no longer claims empty for review mode) - Add tests for review-mode maybeRunProjectSummary and buildSummaryCommentsList in internal/agent/coverage_test.go - Document --summary flag in cli-reference.md for all four locales (en, zh, ja, ru)
verify-english-only.go flagged the Japanese character in the 280-rune truncation fixture. The character is deliberate: an ASCII fixture would be 300 bytes and 300 runes alike, so it could not tell rune-based truncation from byte-based. Add the marker comment the script documents as the first choice for an encoding fixture, matching the nine existing precedents such as manifest_test.go:695.
buildSummaryCommentsList capped content with oneLine[:280], slicing the byte string. When byte 280 landed mid-character the prompt received invalid UTF-8, and the budget was spent three times too fast on CJK content: 280 bytes holds 93 characters, so a comment budgeted 280 characters arrived with 93 plus a broken trailing byte. Count runes instead, matching the copy this PR adds in internal/agent. The existing test could not catch this — its fixture is 400 ASCII characters, where byte and rune truncation agree — so add one that repeats a multibyte character and asserts both valid UTF-8 and the rune count.
…failure The --summary call was the only LLM request on the review path missing llm.WithRequestMeta, so the retry observer dropped it and its retries and failures never reached the run's retry report. It also had no telemetry span, and reported failure only to stdout — which --format json and --audience agent replace with io.Discard, so a summary the user paid for and did not get vanished with no trace in the warnings array either. - attach RequestMeta from the record the call created, matching plan and review-filter - wrap the call in a project_summary.execute span plus an LLM span, with the span starting after the gates so an off-by-default flag does not add an empty span to every review - record a project_summary_error warning on transport failure and on an empty model response - skip the summary when dispatch returned a hard error, so a failed run does not spend one more request on a summary of results it never produced - cover the failure, empty-body, budget-exceeded, cancelled-context and missing-template paths, and pin the request identity
lizhengfeng101
force-pushed
the
feat/review-summary
branch
from
August 20, 2026 10:55
d401edc to
6200689
Compare
8 tasks done
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.
Summary
Adds a
--summaryflag toocr reviewthat generates a project-level summary consolidating all per-file review comments into a structured overview.When enabled, after all per-file reviews complete, an extra LLM call synthesizes the findings into a markdown document with sections for Top Issues, Cross-Cutting Concerns, Quick Wins, and Overall Assessment. The summary is appended after per-file comments in text mode and included in the
project_summaryfield for JSON output.Changes
PROJECT_SUMMARY_TASKto the reviewTemplatestruct with dedicated prompt files (project_summary_task_system.md,project_summary_task_user.md)maybeRunProjectSummary()on the review Agent, with guards for budget-exceeded and context-cancelled states--summaryboolean flag and wired it through toagent.Args.SummaryEnabledbuildSummaryCommentsListto handle multi-byte characters (CJK, emoji) without producing invalid UTF-8Design Decisions
task_template.jsonso users can customize via--tool-configProjectSummary()plumbing inemitRunResulthandles text and JSON formats automaticallyTest Plan
go build ./...compiles cleanlygo test ./...— all packages passocr review --helpshows the new--summaryflagocr review --summary --format jsonproducesproject_summaryfieldocr review --summaryshows "Project Summary" section in terminalocr review --summarywith no changes produces no summary (LGTM only)