Commit Graph

143 Commits

Author SHA1 Message Date
Li Liu c634075bf8 feat(providers): add Gemini CLI session support and session naming
- Gemini CLI: full session persistence via -o json/stream-json and
  --resume <uuid>, NDJSON parsing for streaming session_id capture
- Claude Code & Gemini CLI: session naming via [name] prefix in first
  message, visible in gemini --list-sessions and claude --resume
- Provider interface: startSession() now accepts optional name parameter
- Codex CLI: include stderr in error messages for better diagnostics

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 20:59:35 +08:00
Li Liu 76e0031527 fix: add PR number validation to prevent command injection
Validates that PR numbers are numeric-only in postPRReview and
getPRHeadSha before passing them to shell commands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 20:00:27 +08:00
Li Liu c0e22271b8 feat: integrate review history tracking and add stats command
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:56:04 +08:00
Li Liu 989ec24e9f feat: add review history tracking with incremental diff
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:53:13 +08:00
Li Liu d73504889c feat(review): add post-processing interactive comment flow
Add human-in-the-loop review for each issue before posting to GitHub.
After structured issues are displayed, users can review each issue and
choose to post as-is, edit, discuss with the original reviewer, skip,
or stop. Approved comments are batched and posted via the GitHub API.

- Add getReviewers() method to DebateOrchestrator
- Add interactiveCommentReview function with per-issue actions (p/e/d/s/q)
- Add discuss mode: back-and-forth with the AI reviewer who raised the issue
- Wire post-processing prompt into PR review flow after issue table display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:50:14 +08:00
Li Liu 1625347559 feat: add GitHub PR comment posting utility
Add commenter module that builds GitHub PR review payloads from merged
issues. Issues with file+line become inline review comments, issues
without line info go into the review body. Includes gh CLI wrappers for
posting reviews and fetching PR head SHA.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:46:11 +08:00
Li Liu 339f3a1b4d feat: add structured call chain context for reviewers
Add formatCallChainForReviewer to display exact code snippets at each
call site, giving reviewers precise context about how changed symbols
are used across the codebase. Raw references are now stored in
GatheredContext and formatted into the reviewer prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:43:39 +08:00
Li Liu d3a3be9a19 feat: add dynamic focus broadcast from analyzer to reviewers
Add parseFocusAreas to extract suggested review focus from analyzer
output and inject them as hints into each reviewer's first-round
prompt. Focus areas are suggestions, not constraints — reviewers are
explicitly told to also flag anything else they notice.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:40:24 +08:00
Li Liu 81e57495a9 perf: parallelize analyzer and context gatherer execution
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:37:33 +08:00
Li Liu a0467cfb0b feat: display structured issue table after review conclusion
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:36:12 +08:00
Li Liu a2755090d2 feat: integrate issue parsing and dedup into orchestrator
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:34:20 +08:00
Li Liu c368a1009f feat: update reviewer prompt to request structured JSON output
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:31:53 +08:00
Li Liu eccc867e6a feat: add issue parser with deduplication
Add parseReviewerOutput to extract structured issues from reviewer
JSON blocks and deduplicateIssues to merge similar issues across
multiple reviewers using Jaccard similarity on title words.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:27:17 +08:00
Li Liu e0b6f53ceb feat: add ReviewIssue, ReviewerOutput, MergedIssue types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:21:23 +08:00
Li Liu 3343d178a7 docs: update README with context gatherer feature
- Add contextGatherer config section with all options
- Add --skip-context, --plan-only, --reanalyze CLI options
- Update workflow diagram to include context gathering step
- Add Context Gathering feature description

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 16:45:59 +08:00
Li Liu a4f34b94c0 feat(config): add default context gatherer settings 2026-01-29 14:28:02 +08:00
Li Liu a198f9a178 feat(review): add context gathering to review command 2026-01-29 14:27:30 +08:00
Li Liu 5a547e05f6 feat(orchestrator): integrate ContextGatherer 2026-01-29 14:25:40 +08:00
Li Liu 99d70ad989 feat(orchestrator): add context gatherer types to options 2026-01-29 14:24:19 +08:00
Li Liu b9fbb8d6fb feat(config): add context gatherer config types 2026-01-29 14:23:40 +08:00
Li Liu f02dd88a62 feat(context-gatherer): add module index
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:23:05 +08:00
Li Liu 7b3084f341 feat(context-gatherer): add main ContextGatherer class
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:22:18 +08:00
Li Liu 63dd4a3715 feat(context-gatherer): add prompts index 2026-01-29 14:20:46 +08:00
Li Liu 70efd80aca feat(context-gatherer): add AI analysis prompt 2026-01-29 14:20:15 +08:00
Li Liu d834df8a71 feat(context-gatherer): add collectors index
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:19:10 +08:00
Li Liu 362f3595ee feat(context-gatherer): add docs collector
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:18:16 +08:00
Li Liu 8860e6e66c feat(context-gatherer): add history collector
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:16:57 +08:00
Li Liu f5854d0d02 feat(context-gatherer): add reference collector
Add reference collector module that:
- Extracts function/class symbols from git diffs
- Uses ripgrep to find where symbols are referenced in the codebase

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:15:06 +08:00
Li Liu 094c541e66 feat(context-gatherer): add type definitions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:13:26 +08:00
Li Liu 6093673173 feat: show convergence judgment reasoning and fix markdown rendering
- Add onConvergenceJudgment callback to display why judge ruled converged/not
- Increase joke rotation interval from 8s to 15s
- Fix markdown rendering issues from LLMs like Codex:
  - Add fixMarkdown() to convert indented lists to standard format
  - Increase terminal width from 80 to 120

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:40:41 +08:00
Kiyor Cai 71ad32394d docs: add discuss command documentation to README
Add documentation for the new discuss feature including:
- CLI options and flags
- Usage examples (basic, devil's advocate, interactive)
- Session management (list/resume)
- Feature highlights
2026-01-29 13:12:17 +08:00
Li Liu 579e15aba8 fix: require at least 2 rounds before convergence can be declared
The previous convergence check had two issues:
1. It could declare convergence after round 1, when reviewers hadn't
   seen each other's opinions yet (independent reviews)
2. The parsing logic was too loose - any response containing "CONVERGED"
   would pass, even if it was part of a sentence

Changes:
- Require at least 2 completed rounds before checking convergence
- Add stricter consensus criteria (critical issues must be cross-validated)
- Fix parsing to only accept exact "CONVERGED" as first word
- Clarify that silence on another's point is NOT agreement

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:29:15 +08:00
Li Liu d55b9f381d fix: stop spinner before reviewer selection to allow interactive input
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:57:59 +08:00
Li Liu 76c37a3620 fix: interactive mode readline issues and add follow-up Q&A
- Fix readline stdin state issue causing immediate exit in -i mode
- Fix analysis content not displaying before interactive prompt
- Add follow-up Q&A after Final Conclusion in review command
- Refactor selectReviewers to accept optional shared readline instance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 10:19:38 +08:00
Kiyor Cai 32850ba974 feat: add interactive discuss command for multi-reviewer discussions
Adds a new `discuss` command that enables interactive discussion sessions
with multiple AI reviewers, including session persistence and context loading.
2026-01-28 09:54:06 +08:00
xiaofanluan 7cccacdc51 feat: add repository-wide code review with feature analysis
Implement full repository review mode that detects logical features/modules
and reviews them systematically with session persistence for pause/resume
capability.

Key additions:
- RepoScanner: scans codebase and estimates tokens/cost
- FeatureAnalyzer: AI-powered detection of logical modules
- FeaturePlanner: creates review execution plan
- StateManager: persists sessions for resume capability
- RepoOrchestrator: executes feature-by-feature reviews
- MarkdownReporter: generates review reports

New CLI options: --repo, --quick, --deep, --list-sessions, --session,
--export, --path, --ignore, --plan-only, --reanalyze

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 22:58:22 +08:00
Li Liu 75bf857371 feat: show parallel execution status with timing
- Add ReviewerStatus type for tracking reviewer state
- Track start/end time and duration for each reviewer
- Display live status during parallel execution:
  ✓ done (with duration) | ⋯ thinking | ○ pending
- Update spinner in real-time as reviewers complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 20:56:16 +08:00
Li Liu 8885763d60 fix: convergence detection and codex-cli consistency
- Fix convergence check: NOT_CONVERGED was incorrectly matching CONVERGED
- Allow convergence after round 1 (was requiring 2 rounds minimum)
- Unify codex-cli streaming/non-streaming to use same bypass flag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 20:38:09 +08:00
Li Liu c08ee3819a docs: update README with new features
- Add Fair Debate Model and Parallel Execution to core concepts
- Update max_rounds default from 2 to 5
- Document new CLI options: --reviewers, --all/-a, --git-remote
- Add Reviewer Selection section with interactive/CLI examples
- Rewrite Workflow to show Round 1 independent → Round 2+ debate model
- Add Fair Debate Model explanation section
- Add Parallel Execution section with example output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 19:07:34 +08:00
Li Liu de75d4f165 feat: parallel execution for reviewers in same round
Each round now executes all reviewers in parallel using Promise.all:
1. Build messages for all reviewers (same info)
2. Execute all chatStream calls concurrently
3. Collect all responses
4. Display results after all complete

Benefits:
- Faster execution (N reviewers run simultaneously)
- Semantically correct (same round = simultaneous)
- Same total API usage, just concurrent

Display shows: "Round N: All reviewers thinking (parallel)"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 19:04:40 +08:00
Li Liu 1ad9d0f04e feat: each round sees only previous rounds, not current round peers
Changed debate model:
- Round N: each reviewer sees only rounds 1 to N-1
- Reviewers in same round have identical information (fair)
- No anchoring bias from earlier reviewers in same round

Example with 3 reviewers:
  Round 2: claude sees [gemini_r1, codex_r1]
           gemini sees [claude_r1, codex_r1]  <- same info level
           codex  sees [claude_r1, gemini_r1] <- same info level

Also increased default max_rounds from 3 to 5 since convergence
may take longer with this fairer model.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 18:57:32 +08:00
Li Liu 9615efec17 fix: session mode round 2 must include all others' round 1 messages
Bug: Round 1 is independent (no one sees others), so session doesn't
have other reviewers' messages. When entering Round 2 debate phase,
we were only sending messages after lastSeen, missing others' Round 1.

Fix: Check if reviewer just finished Round 1 (myMessageCount === 1).
If so, send ALL other reviewers' messages, not just incremental.

Round 3+ continues to use incremental (lastSeen + 1) since debate
context is already established in session.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 18:50:01 +08:00
Li Liu 24bfb596e3 feat: round 1 independent opinions, round 2+ full context debate
Round 1: Each reviewer gives independent assessment
- Only sees analysis, not other reviewers' opinions
- Avoids anchoring bias from first reviewer

Round 2+: Full debate mode
- Sees all previous discussion
- Can agree/disagree with specific points from [reviewer_id]

This ensures diverse initial perspectives before debate begins.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 18:44:20 +08:00
Li Liu 4d83dd97c2 feat: enable danger mode for all CLI providers
- claude-code: add --dangerously-skip-permissions
- codex-cli: use --dangerously-bypass-approvals-and-sandbox
- gemini-cli: already has -y (yolo mode)

This allows CLI tools to access network (e.g., gh commands to fetch PR)
without permission prompts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 18:09:37 +08:00
Li Liu 18f64e5fcf feat: add reviewer selection - default interactive, --all to skip
Usage:
- Default: shows interactive menu to select reviewers
  [0] All reviewers
  [1] claude
  [2] gemini
  ...

- --all (-a): use all reviewers, skip selection
- --reviewers claude,gemini: specify reviewers directly

Requires at least 2 reviewers for a debate.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 17:54:55 +08:00
Li Liu e77522a43e Merge pull request #2 from zhengbuqian/add-remote
feat: add --git-remote option for PR URL detection
2026-01-26 22:16:36 +08:00
Buqian Zheng 9dca82c7d7 feat: add --git-remote option for PR URL detection
Add --git-remote argument to specify which git remote to use when
constructing PR URLs from a PR number. This is useful when working
with forks where the user wants to review PRs from a specific remote
(e.g., upstream) instead of the default origin.

If not provided, defaults to 'origin' for backward compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 22:10:48 +08:00
Li Liu d4d5baa2e7 feat: add visual separator for convergence check
Now shows convergence check as a distinct step:
┌─ 🔍 Convergence Judge ─────────────────────────
⠋ Evaluating if reviewers reached consensus...
└─ Verdict: CONVERGED / NOT CONVERGED

Makes it clear this is a separate judge, not another reviewer.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 21:43:47 +08:00
Li Liu 7144b98e08 fix: stricter convergence check - reject if any reviewer explicitly disagrees
Previous prompt was too lenient ("mostly agree on key points").
Now requires TRUE consensus:
- All reviewers must agree on the same verdict
- NOT converged if any reviewer says "I disagree/reject [X]'s view"
- NOT converged if they agree on problems but disagree on actions
- System prompt: "Be conservative - when in doubt, say NOT_CONVERGED"

This fixes false positives like Gemini saying "I reject [claude]'s view"
but still being marked as converged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 21:40:46 +08:00
Li Liu 406dcf7326 refactor: balance debate tone - goal is finding issues, not fighting
- "adversarial debate against" → "code review debate with"
- "opponent" → "the other reviewer"
- Add "shared goal: find real issues and reach the best conclusion"
- "agree where valid, challenge where you disagree"
- "acknowledge good points and build on them"

Keep the anti-sycophancy stance but focus on solving problems together.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 18:32:03 +08:00