Commit b481d10
committed
feat(mcp): codegraph_review_context — structured PR-review context from a diff
Adds a new MCP tool that takes a unified diff and returns structured
review context for an LLM-driven PR reviewer. Codegraph becomes a
substrate for Greptile/CodeRabbit-style products without itself doing
the synthesis.
Per changed file:
- status (added / modified / deleted / renamed)
- hunks (line ranges)
- affected symbols (line-range overlap with hunks)
- tests covering the file (via tests-edges; graceful no-op if absent)
Per affected symbol:
- signature, docstring
- top-N callers, top-N callees
- impact-radius node count
- src/review/diff-parser.ts: pure unified-diff parser
- src/review/index.ts: buildReviewContext + co-change warnings
- src/index.ts: CodeGraph.buildReviewContext public API
- src/mcp/tools/review-context.ts: ToolModule (post-colbymchenry#117 form)
- src/mcp/tools.ts: handleReviewContext + serializeReviewContextWithinCap
(progressive-trim JSON serializer that keeps output <= MAX_OUTPUT_LENGTH
while preserving JSON parseability)
- __tests__/review-context.test.ts: 25 tests
Output is JSON; the LLM consumer does the synthesis.
This is the post-colbymchenry#117 (per-tool MCP registry) form — the original
PR's case-switch dispatch is replaced by a ToolModule entry plus
a 'handleReviewContext' HandlerKey.
Tests that exercise co-change warnings include a graceful inline
ALTER TABLE for commit_count, since that column lands with colbymchenry#112's
centrality+churn migration. After colbymchenry#112 lands the ALTER becomes a
no-op (column already exists).1 parent 40772e9 commit b481d10
9 files changed
Lines changed: 1361 additions & 2 deletions
File tree
- __tests__
- src
- mcp
- tools
- review
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
0 commit comments