159 Commits

Author SHA1 Message Date
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
Li Liu 43c395a6d5 feat: improve debate format with named reviewers and adversarial prompts
- Replace anonymous [AI Reviewer] with specific reviewer IDs (e.g., [claude], [gemini])
- Rewrite prompts to emphasize adversarial debate, not collaborative review
- Each AI now knows: "You are [X], your opponent is [Y]"
- Use action words like "Challenge their points", "Defend your position"
- Remove verbose old instructions, keep prompts focused

This makes AIs actually argue with each other instead of politely agreeing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 18:30:29 +08:00
Li Liu 96fc85c217 fix: disable gemini-cli session support (uses full context mode)
Gemini CLI only supports index-based sessions (-r latest or -r 5),
not custom session IDs like Claude CLI. Since "latest" could refer
to a different session if user runs other Gemini commands, this is
unreliable. Disabled session support for Gemini CLI - it will always
use full context mode instead.

Also updated README to clarify session support per provider.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 18:10:33 +08:00
Li Liu de26a36e38 fix: gemini-cli session support for incremental discussion
Fixed bug where sessionId was checked instead of hasSession.
Now gemini-cli properly uses -r latest to resume sessions
for incremental discussion like claude-code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:45:45 +08:00
Li Liu 9bcaf728fd docs: update README with new features
- Add gemini-cli to supported providers
- Document session persistence
- Document post-analysis Q&A feature
- Document markdown rendering
- Document cold jokes
- Update example config for CLI-only setup
- Add PR URL support in examples

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:43:33 +08:00
Li Liu fdc1eeca7a feat: add Gemini CLI provider support
- New gemini-cli provider using the Gemini CLI tool
- Uses -y (yolo mode) for auto-approve and -o text for clean output
- Supports session resumption with -r latest
- 15 minute timeout like other CLI providers
- Added to init wizard as a no-API-key option

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:36:43 +08:00
Li Liu 4fdb41d9ea fix: render markdown for analyzer and reviewer outputs
Previously only the final conclusion was rendered with markdown.
Now all reviewer outputs are buffered and rendered with marked
when each reviewer finishes speaking.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:32:08 +08:00
Li Liu 6de693bc0e feat: add session persistence and post-analysis Q&A
Session persistence (reduces token usage):
- Claude Code provider maintains session across rounds
- Uses --session-id for first call, --resume for subsequent
- Only sends incremental messages in session mode

Post-analysis interactive Q&A:
- In interactive mode (-i), user can ask specific reviewers before debate
- Format: @reviewer_id question (e.g., @claude What about security?)
- Allows clarifying questions before full debate begins

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:14:16 +08:00
Li Liu 68f31138c7 fix: stop spinner after summarizer completes
The summarizer uses non-streaming chat(), so onMessage callback
never fires to stop the spinner. Now explicitly stop it after
runStreaming() returns.

Also refactored spinner/interval to use object ref to fix
TypeScript control flow analysis issues with closures.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:57:24 +08:00
Li Liu e7548ddd67 feat: render markdown in terminal for better readability
- Use marked + marked-terminal to render final conclusion
- Proper colors, bold, table alignment in terminal

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:54:36 +08:00
Li Liu dd6466ade6 Revert "feat: improve summarizer output format for better readability"
This reverts commit 77a6ccda74.
2026-01-26 16:53:28 +08:00
Li Liu 77a6ccda74 feat: improve summarizer output format for better readability
- Structured format with clear sections (共识点, 分歧点, 行动项, 总体评估)
- Priority table for action items (P0/P1/P2)
- Detailed issue format with location, problem, risk, consensus level
- Clear merge status and conditions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:51:58 +08:00
Li Liu a153c0efa2 feat: increase timeout to 15min and show cold jokes while waiting
- Increase CLI provider timeout from 5 to 15 minutes for large PRs
- Display random programmer jokes while waiting for AI reviewers
- 36 English cold jokes rotate every 8 seconds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:37:39 +08:00
Li Liu 0ba997e91a Merge pull request #1 from xiaofan-luan/feat/interactive-init-and-local-review
feat: add interactive reviewer selection and local diff review
2026-01-26 16:30:30 +08:00
xiaofanluan 30879d9742 feat: add interactive reviewer selection and local diff review
Add interactive mode to `magpie init` allowing users to select which AI
reviewers to configure. Shows available options with API key requirements
and generates a customized config. Supports -y flag for defaults.

Add --local flag to `magpie review` to review uncommitted changes (staged
+ unstaged) without needing a PR. Falls back to last commit if no local
changes exist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:27:44 +08:00
Li Liu 5d125a4c07 feat: support full PR URL and auto-detect repo from git remote 2026-01-26 16:20:11 +08:00
Li Liu 65d11bc39b feat: add 5-minute timeout for CLI providers to prevent hanging 2026-01-26 16:16:41 +08:00
Li Liu 5d2e9328a1 fix: don't force specific commands, let AI decide how to fetch details 2026-01-26 16:03:01 +08:00
Li Liu 0f4b596379 fix: pass task prompt to reviewers so they can access PR details 2026-01-26 16:01:50 +08:00
Li Liu ecf4667b1d refactor: let AI fetch diff itself instead of passing it 2026-01-26 15:56:40 +08:00
Li Liu 03dc45d195 fix: avoid repeating diff in every round, use analysis instead 2026-01-26 15:54:57 +08:00
Li Liu fcb3f17891 feat: add local review modes (--local, --branch, --files) 2026-01-26 15:35:37 +08:00
Li Liu a2f35e007d feat: improve output readability with better formatting 2026-01-26 15:30:04 +08:00
Li Liu 2afb5b756c docs: translate README to English 2026-01-26 15:21:34 +08:00
Li Liu ccba115f5e feat: add convergence detection, token tracking, and UX improvements
- Add convergence detection (default enabled, configurable)
- Add token usage estimation and cost tracking
- Add spinner for waiting states
- Fix AI sycophancy by clarifying debate context
- Explicitly state reviewer count in prompts
- Update README with Chinese documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:20:14 +08:00
Li Liu dd20e52451 feat: add OpenAI Codex CLI provider
Add codex-cli provider that calls the codex CLI command, similar to claude-code provider.
Also update gemini model to gemini-3-pro in user config.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:39:23 +08:00
Li Liu 76e7d32587 feat: add Gemini provider and update default config
Add Google Gemini provider using @google/generative-ai SDK with support
for both standard and streaming chat methods. Update default config
template to use simpler model-based reviewer names (claude, gemini)
instead of role-based names. Analyzer and summarizer now use claude-code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:22:33 +08:00
Li Liu f87ecd31ed feat: add Claude Code CLI provider for subscription users 2026-01-26 13:13:15 +08:00
Li Liu 933a2d597e feat: add PR analyzer step before debate 2026-01-26 13:08:57 +08:00
Li Liu f566f8026d docs: add README 2026-01-26 12:38:58 +08:00
Li Liu b23f9cadb1 test: add E2E tests for CLI
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:38:16 +08:00
Li Liu 9c1d5b7838 feat: add streaming output support
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:36:55 +08:00
Li Liu 452ae2c8ec chore: add barrel exports
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:35:45 +08:00
Li Liu 1aaa4f73d9 feat: add CLI with review and init commands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:34:32 +08:00
Li Liu 3f038cef4d feat: add debate orchestrator with round management
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:32:11 +08:00