feat: add unified_review MCP prompt + sync tool/prompt counts
Adds the unified_review MCP prompt (invoked as /code-review-graph:unified_review) that drives the unified-review workflow: graph context -> detect_changes -> score_review -> findings -> dedupe_findings -> generate_report. READ-ONLY: every finding waits for a manual fix decision. Takes base and tier (fast/standard/strict) arguments. - prompts.py: unified_review_prompt + docstring count 5->6 - main.py: @mcp.prompt() registration - tests/test_prompts.py: TestUnifiedReviewPrompt + preamble test - docs: LLM-OPTIMIZED-REFERENCE, COMMANDS, CLAUDE.md, INDEX, architecture, README + 4 localized READMEs; tool count 30->31 and prompt count 5->6 synced (historical ROADMAP/FEATURES version notes left unchanged)
This commit is contained in:
@@ -35,7 +35,7 @@ score_review_tool returns objective metrics (sql_risk, exception_coverage, redun
|
||||
<section name="commands">
|
||||
Core MCP tools: get_minimal_context_tool, detect_changes_tool, get_review_context_tool, get_impact_radius_tool, query_graph_tool, semantic_search_nodes_tool, get_architecture_overview_tool, get_affected_flows_tool, list_flows_tool, list_communities_tool, refactor_tool, build_or_update_graph_tool, run_postprocess_tool, embed_graph_tool, list_graph_stats_tool, get_docs_section_tool
|
||||
Unified-review MCP tools: score_review_tool, dedupe_findings_tool, generate_report_tool
|
||||
MCP prompts (5): review_changes, architecture_map, debug_issue, onboard_developer, pre_merge_check
|
||||
MCP prompts (6): review_changes, architecture_map, debug_issue, onboard_developer, pre_merge_check, unified_review
|
||||
Skills: build-graph, debug-issue, explore-codebase, refactor-safely, review-changes, review-delta, review-pr, unified-review
|
||||
CLI: code-review-graph [install|init|build|update|status|watch|visualize|serve|mcp|wiki|detect-changes|postprocess|embed|register|unregister|repos|eval|daemon]
|
||||
Token efficiency: Prefer detail_level="minimal" where available. Always call get_minimal_context_tool first. Some review/context tools return compact estimated context_savings metadata.
|
||||
|
||||
@@ -28,6 +28,7 @@ from .prompts import (
|
||||
onboard_developer_prompt,
|
||||
pre_merge_check_prompt,
|
||||
review_changes_prompt,
|
||||
unified_review_prompt,
|
||||
)
|
||||
from .tools import (
|
||||
apply_refactor_func,
|
||||
@@ -1124,6 +1125,21 @@ def pre_merge_check(base: str = "HEAD~1") -> list[dict]:
|
||||
return pre_merge_check_prompt(base=base)
|
||||
|
||||
|
||||
@mcp.prompt()
|
||||
def unified_review(base: str = "HEAD~1", tier: str = "standard") -> list[dict]:
|
||||
"""Three-layer unified review (CRG graph context + scoring + dedupe + report).
|
||||
|
||||
Fuses graph context with the objective scoring metrics, finding merge,
|
||||
and the standalone HTML report. READ-ONLY: every finding waits for a
|
||||
manual fix decision.
|
||||
|
||||
Args:
|
||||
base: Git ref to diff against. Default: HEAD~1.
|
||||
tier: Review tier (fast / standard / strict). Default: standard.
|
||||
"""
|
||||
return unified_review_prompt(base=base, tier=tier)
|
||||
|
||||
|
||||
def _apply_tool_filter(tools: str | None = None) -> None:
|
||||
"""Remove tools not listed in the allow-list.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""MCP prompt templates for Code Review Graph.
|
||||
|
||||
Provides 5 pre-built prompt workflows, all enforcing token-efficient
|
||||
Provides 6 pre-built prompt workflows, all enforcing token-efficient
|
||||
detail_level="minimal" first patterns with get_minimal_context entry point.
|
||||
|
||||
1. review_changes - pre-commit review using detect_changes + affected_flows
|
||||
@@ -8,6 +8,7 @@ detail_level="minimal" first patterns with get_minimal_context entry point.
|
||||
3. debug_issue - guided debugging using search, flow tracing
|
||||
4. onboard_developer - new dev orientation using stats, architecture, flows
|
||||
5. pre_merge_check - PR readiness with risk scoring, test gaps, dead code
|
||||
6. unified_review - three-layer review: graph context + scoring + dedupe + report
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -157,3 +158,60 @@ def pre_merge_check_prompt(base: str = "HEAD~1") -> list[Message]:
|
||||
"7. Output: GO/NO-GO recommendation with 1-sentence "
|
||||
"justification + list of required follow-ups."
|
||||
)
|
||||
|
||||
|
||||
def unified_review_prompt(
|
||||
base: str = "HEAD~1",
|
||||
tier: str = "standard",
|
||||
) -> list[Message]:
|
||||
"""Three-layer unified review workflow (READ-ONLY).
|
||||
|
||||
Fuses CRG graph context with the objective scoring metrics
|
||||
(score_review), finding merge (dedupe_findings), and the standalone
|
||||
HTML report (generate_report). Every finding is presented for a manual
|
||||
fix decision -- this workflow never modifies code.
|
||||
|
||||
Args:
|
||||
base: Git ref to diff against. Default: HEAD~1.
|
||||
tier: Review tier. "fast" (Layer 1 + blockers only),
|
||||
"standard" (all layers), "strict" (full + per-item
|
||||
confirmation). Default: standard.
|
||||
"""
|
||||
tier_notes = {
|
||||
"fast": (
|
||||
"fast tier: run Layers 1 and the blocker check only; "
|
||||
"skip Layer 2 metrics and the report."
|
||||
),
|
||||
"strict": (
|
||||
"strict tier: full review; every blocker and major finding "
|
||||
"needs per-item user confirmation before it is recorded."
|
||||
),
|
||||
}.get(tier, "standard tier: run all layers.")
|
||||
return _user(
|
||||
f"{_TOKEN_EFFICIENCY_PREAMBLE}\n"
|
||||
f"## Unified Review Workflow (base={base}, tier={tier})\n"
|
||||
f"{tier_notes}\n"
|
||||
"**READ-ONLY.** Present every finding for a manual fix decision. "
|
||||
"Never modify code, commit, or push.\n"
|
||||
'1. Call `get_minimal_context(task="unified review")` for the '
|
||||
"risk overview.\n"
|
||||
'2. Call `build_or_update_graph()` to ensure the graph is '
|
||||
"current.\n"
|
||||
'3. Call `detect_changes(detail_level="minimal")` for changed '
|
||||
"files, risk score, test gaps and affected flows.\n"
|
||||
'4. Call `score_review(detail_level="standard")` for the '
|
||||
"objective metrics (sql_risk, exception_coverage, redundancy, "
|
||||
"high-risk density, vulnerability). Trust the tool grades; "
|
||||
"LLM-judged metrics are in `llm_judged`.\n"
|
||||
"5. Review the changed source (Layer 1 chain decomposition) and "
|
||||
"produce findings with severity (blocker/major/minor), "
|
||||
"confidence (1-10), file:line and a proposed fix.\n"
|
||||
'6. Call `dedupe_findings(findings=<your findings>)` to merge '
|
||||
"by fingerprint, boost multi-source confidence and compute the "
|
||||
"PR quality score.\n"
|
||||
'7. Call `generate_report(review_data=<verdict, tier, scope, '
|
||||
'metrics, merged findings>)` to write code-review-report.html.\n'
|
||||
"8. Output: verdict (✅ PASS / ❌ FAIL), severity counts, each "
|
||||
"issue with confidence + fix, and the manual-review items. "
|
||||
"Any blocker → verdict ❌ FAIL."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user