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:
dev
2026-08-05 13:58:51 +08:00
parent 84ae9b817e
commit b96f38276f
13 changed files with 159 additions and 21 deletions
+59 -1
View File
@@ -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."
)