159 Commits

Author SHA1 Message Date
Li Liu 0f7b85cc5b feat: add regenerate option for post-discussion comments
After discuss generates a comment, users can now press [r] to
regenerate with custom instructions (e.g. "more concise", "add code
example"). Supports unlimited regeneration cycles with full
conversation context preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 19:48:03 +08:00
Li Liu 8b35dbecbf docs: update README with new providers, post-processing, and debug mode
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:27:52 +08:00
Li Liu 1efe5165c7 fix: post inline comments per-line instead of one big review
Rewrote commenter to post each issue as an individual inline comment
on the specific line via GitHub PR comments API. If the line is not
in the diff, falls back to a regular PR comment with file:line context.
Previously used batch PR review API where one invalid line would fail
the entire batch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:22:31 +08:00
Li Liu dda200a8a9 feat: auto-explain issues on discuss + progress tracking
- Discussion mode ('d') now auto-sends first message asking the
  reviewer to explain the issue in detail (where, why, how to fix)
  before user interaction begins
- Progress bar shows running tally: posted/edited/discussed/skipped
  counts displayed on each issue header

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:17:28 +08:00
Li Liu 4beed0fd9c fix: ora discardStdin kills process during interactive discussion
Root cause: ora's default discardStdin=true calls process.stdin.pause()
when spinner stops. This makes the stdin handle inactive in libuv, and
since readline's question() does not call resume(), the event loop sees
no active handles and the process exits silently. Only affects TTY
environments (stdinDiscarder checks isTTY).

Fix: use discardStdin:false on all ora spinners that coexist with
readline, plus explicit process.stdin.resume() safety net.

Also includes:
- Multi-turn discussion with conversation history and debate context
- AI-generated final comments after discussion
- unhandledRejection guard for async generator cleanup
- Pre-fetch PR diff so API-only models get the code
- Solo review/discuss support (min 1 reviewer, skip convergence)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:15:11 +08:00
Li Liu 52577cfce1 fix: add stream cleanup to anthropic/openai providers
- AnthropicProvider: stream.abort() in finally block ensures HTTP
  connection is released even if consumer breaks early
- OpenAIProvider: stream.controller.abort() for same reason
- GeminiProvider: document that consuming all chunks is sufficient

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:14:57 +08:00
Li Liu fe9257ebcc feat: add mock, qwen-code, minimax providers
- MockProvider for debug mode: supports MAGPIE_MOCK_DELAY,
  MAGPIE_MOCK_RESPONSE, MAGPIE_MOCK_FILE env vars; echoes input by default
- QwenCodeProvider: wraps qwen-code CLI (OAuth-based)
- MiniMaxProvider: API-based provider using MiniMax-M2.5
- config.mock top-level flag: when true, all models route to MockProvider
- model prefix matching: mock, mock1, mock2 etc. all map to mock provider

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:14:49 +08:00
Li Liu c54f1e1149 feat: add session support for Codex CLI provider
Use `codex exec --json` and `codex exec resume <thread_id>` to maintain
multi-turn conversation state, matching Claude and Gemini CLI behavior.
In debate rounds, only the last message is sent instead of full history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:50:51 +08:00
Li Liu cea0cb758c fix: rich issue descriptions + fix discuss flow in post-processing
1. Structurizer now requests comprehensive markdown descriptions with
   original code quotes, impact analysis, and fix rationale — suitable
   for GitHub PR comments.

2. Fix discuss (d) silently skipping: raisedBy was stripped by
   parseReviewerOutput, defaulting to ['summarizer'] which matched no
   reviewer. Now preserved through parsing pipeline, with fallback to
   first available reviewer.

3. Issue display now renders markdown via marked() for proper formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 15:07:00 +08:00
Li Liu e40eb6afc8 fix: disable tools for structurizer to prevent code modification instead of JSON extraction
When extracting structured issues from review text, Claude Code with
--dangerously-skip-permissions would interpret file paths and fix suggestions
as instructions to modify code, producing "All fixes applied..." instead of
JSON. Fix by passing --tools "" to disable all tools for the structurizer call.

Also: end summarizer session before structurization for clean non-session call,
make issue-parser more lenient (accept raw JSON objects, optional verdict/summary).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 00:04:31 +08:00
Li Liu 6afc9a9498 fix: flush analysis buffer before displaying system context
The analysis content was still buffered when onContextGathered fired,
causing the context section to appear before the analysis text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:45:28 +08:00
Li Liu 0673274030 refactor: always use AI to extract structured issues, never parse reviewer JSON
Reviewer output format is not under our control. Instead of trying to
parse JSON blocks from reviewer messages (which may not match our schema),
always use the summarizer to extract structured issues from the review
discussion text. This is more robust and removes any dependency on
reviewer prompt configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:39:27 +08:00
Li Liu f265dacea7 feat: auto-structurize review issues when reviewers don't output JSON
When reviewers don't include structured JSON blocks in their output,
the summarizer is called to extract issues from the unstructured review
text into the standard JSON format. This ensures the per-issue
interactive post-processing flow always works for PR reviews.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:37:25 +08:00
Li Liu 4070d2ec70 fix: add role label to session names + fallback post-processing
1. Session names now include explicit role: "reviewer:gemini" instead of
   just "gemini", matching analyzer/summarizer pattern
2. PR post-processing no longer requires structured JSON issues. When
   reviewers don't output JSON blocks, offers to post the final
   conclusion as a general PR comment instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:33:59 +08:00
Li Liu 6ca7a14f54 fix: prevent context gatherer output from interleaving with analysis stream
Move onContextGathered callback to after Promise.all resolves, so context
displays after analysis finishes streaming. Work is still parallel, only
the display is sequential.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:28:09 +08:00
Li Liu 3a2ea02062 fix: add anti-preamble instruction to analyzer prompt
Prevents AI from outputting chatty preamble like "Here's my analysis"
before the actual content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:25:47 +08:00
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