Commit Graph

34 Commits

Author SHA1 Message Date
Li Liu 6e31ec33ac test: drop obsolete summaries assertion after summary-step removal
The per-reviewer summary step was removed in 0f03726, dropping the
summaries field from DebateResult, but this test still asserted on it
and failed. Remove the stale assertion.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 14:28:30 -07:00
Li Liu f94808969f feat: add --fail-fast option to abort review/discuss on any reviewer failure
By default the orchestrator is resilient: a single reviewer (or context
gatherer) failure is logged and the round continues with the survivors,
aborting only when all reviewers fail.

The new --fail-fast flag flips to strict mode — any reviewer or
context-gathering failure re-throws immediately and terminates the
whole flow. Wired through the review and discuss commands via
OrchestratorOptions.failFast, with a regression test and README docs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 14:24:03 -07:00
Li Liu 8a8dab1ec4 fix: improve inline PR comment placement with content-based matching and full diff fallback
- Add extractDiffLineRanges() to include valid line ranges in structurizer prompt
- Add content-based matching (extractCodeFromBody + findLineByContent) as fallback
- Add full diff fallback via gh api when per-file patches are null
- Widen nearest-line threshold from 20 to 50 for better coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 18:12:23 +08:00
Li Liu 5df0e65e5e feat: pre-flight check for CLI binaries with friendly error messages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 13:55:12 +08:00
Li Liu c2d0f583af fix: register exit handler to clean up temp prompt files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 13:55:09 +08:00
Li Liu 6bc75ca3ea fix: single reviewer failure no longer terminates entire review session
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 13:53:05 +08:00
Li Liu 38ff61471a fix: prevent command injection in history-collector via spawnSync
Replace execSync with spawnSync in getFileHistory() and getPRDetails()
to prevent shell injection through file paths and PR numbers. Add input
validation for prNumber (must be a positive integer).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 13:51:12 +08:00
Li Liu 9a6aaca563 fix: prevent command injection in reference-collector via spawnSync
Replace execSync with spawnSync in findReferences() to prevent shell
injection through malicious symbol names in PR diffs. Use -F (fixed-string)
and -e flags for safe argument passing to ripgrep.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 13:51:08 +08:00
Li Liu b541b509d7 fix: improve inline PR comment placement with near-line matching
When the AI reviewer references a line not exactly in a diff hunk,
find the nearest valid diff line (within 20 lines) and post inline
there instead of falling back to file-level. Also constrain the
structurizer prompt to only reference files actually in the diff.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 23:29:14 +08:00
ChrisPan bf896593b3 feat: add custom API base URL support for all API providers (#6)
Allow users to configure `base_url` per provider to connect to
compatible third-party endpoints (Azure OpenAI, Ollama, vLLM, one-api,
etc.). All four API providers (Anthropic, OpenAI, Gemini, MiniMax) now
accept an optional `base_url` in config which is passed through to
their respective SDKs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-26 22:55:17 +08:00
Li Liu 2b0e1ba711 refactor: comprehensive codebase improvements across 7 phases
Phase A - Quick fixes:
- Remove debug logging that leaked prompt content (qwen-code)
- Fix orchestrator session leak with try/finally cleanup
- CJK-aware token estimation for better accuracy
- Issue parser validation (line > 0, endLine >= line, non-empty fields)
- Improved similarity matching with stop words filtering and description weight

Phase B - Medium fixes:
- Add retry utility with exponential backoff for API providers
- Config validation at load time (required fields, empty API key warnings)
- GitHub PR comment deduplication (skip already-posted comments)
- Ctrl+C graceful exit for interactive comment review

Phase C - Structured logging:
- Logger class with debug/info/warn/error levels (MAGPIE_LOG_LEVEL env var)

Phase D - Type safety:
- Replace `any` types with proper types across discuss.ts, review.ts,
  issue-parser.ts, commenter.ts, repo-orchestrator.ts, history-collector.ts

Phase E - Session helper extraction:
- CliSessionHelper class shared by 4 CLI providers, reducing duplication

Phase F - Split review.ts (1991 → 6 files):
- review.ts (command + action), interactive.ts, repo-review.ts,
  session-cmds.ts, utils.ts, types.ts

Phase G - Tests:
- 6 new test files (retry, logger, session-helper, issue-parser-enhanced,
  loader-validation, orchestrator-session)
- Fix pre-existing test failures (commenter, anthropic)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:46:46 +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 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 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 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 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
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 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 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 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
Li Liu 6a068dbbc4 feat: add provider factory for model routing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:29:08 +08:00
Li Liu 5d482f95a0 feat: add OpenAI provider with streaming
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:27:26 +08:00
Li Liu c69c394fba feat: add Anthropic provider with streaming
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:25:49 +08:00
Li Liu b7117ec8e6 feat: add AI provider type definitions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:24:12 +08:00
Li Liu bc1a999a98 feat: add config init with default template
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:22:11 +08:00
Li Liu d16a439367 feat: add config loader with env var expansion
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:20:04 +08:00
Li Liu ce22bccba9 feat: add config type definitions
Add TypeScript interfaces for the Magpie configuration system:
- ProviderConfig: API key storage for providers
- ReviewerConfig: Model and prompt configuration
- DefaultsConfig: Default settings (max_rounds, output_format)
- MagpieConfig: Root configuration structure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:17:59 +08:00