feat: add project-review workflow (whole-project / single-feature review)

Adds the project-review workflow for code review independent of the git
diff. The scope is parsed from the user instruction: 全面/整个项目 ->
whole-project (score every source file), otherwise feature + target
keyword (locate the code with semantic search + graph queries).

- scoring_tools.py: score_review_func gains all_files=True to score every
  source file in the graph via store.get_all_files()
- main.py: score_review_tool gains all_files param; registers the
  project_review MCP prompt (prompts 6->7)
- prompts.py: project_review_prompt(scope, target) with whole-project and
  feature branches (fixed a precedence bug that truncated the feature text)
- skills.py + skills/project-review/: new read-only project-review skill
  with shared checklists
- .opencode/command/code-review-graph-project-review.md: slash command
- tests: test_project_review.py (prompt rendering), TestProjectReviewPrompt,
  skill count assertions 5->6, all_files wiring checks
- docs: prompts (6->7) + project-review entries across COMMANDS, CLAUDE,
  README (+localized), INDEX, architecture, LLM-OPTIMIZED-REFERENCE,
  CHANGELOG
This commit is contained in:
dev
2026-08-06 13:56:54 +08:00
parent 6f0e6f0775
commit 307d2fd471
45 changed files with 1339 additions and 131 deletions
+89 -6
View File
@@ -1,6 +1,6 @@
"""MCP prompt templates for Code Review Graph.
Provides 6 pre-built prompt workflows, all enforcing token-efficient
Provides 7 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
@@ -9,6 +9,7 @@ detail_level="minimal" first patterns with get_minimal_context entry point.
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
7. project_review - whole-project or single-feature review (not diff-based)
"""
from __future__ import annotations
@@ -209,9 +210,91 @@ def unified_review_prompt(
'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."
'7. Call `generate_report(review_data=<verdict, tier, scope, '
'metrics, merged findings>)` to write code-review-report.html '
"and code-review-report.md (format=\"both\").\n"
"8. Output: verdict (✅ PASS / ❌ FAIL), severity counts, each "
"issue with confidence + fix, and the manual-review items. "
"Any blocker → verdict ❌ FAIL."
)
def project_review_prompt(
scope: str = "whole-project",
target: str = "",
) -> list[Message]:
"""Whole-project or single-feature code review workflow (not diff-based).
Reviews the entire codebase (``scope="whole-project"``) or a single
feature/module/function (``scope="feature"`` with ``target``), using
graph-wide analysis and objective scoring independent of the git diff.
READ-ONLY: every finding waits for a manual fix decision.
Args:
scope: ``whole-project`` reviews every source file in the graph;
``feature`` reviews only the code related to ``target``.
target: Feature/module/function keyword when ``scope="feature"``
(e.g. "payment", "auth", "checkout flow").
"""
scope_note = (
"whole-project scope: score every source file with "
"`score_review(all_files=True)`."
if scope == "whole-project"
else (
"feature scope: locate the target's files with semantic search "
"and graph queries, then score only those files."
)
)
common = (
f"## Project Review Workflow (scope={scope}, target={target})\n"
f"{scope_note}\n"
"**READ-ONLY.** Present every finding for a manual fix decision. "
"Never modify code, commit, or push.\n"
'1. Call `get_minimal_context(task="project review")` for graph '
"stats and community overview.\n"
'2. Call `build_or_update_graph()` to ensure the graph is current.\n'
'3. Map the architecture: `get_architecture_overview('
'detail_level="minimal")` and `list_communities('
'detail_level="minimal")`.\n'
'4. Locate high-risk areas: `get_knowledge_gaps()`, '
'`get_hub_nodes()`, `get_bridge_nodes()`, `find_large_functions()` '
"and `get_surprising_connections()`.\n"
)
if scope == "whole-project":
workflow = (
'5. Score every source file: `score_review(all_files=True)`.\n'
"6. For the top-risk communities, drill in with "
'`get_community(include_members=True)` and '
'`query_graph(pattern="children_of", target=<community>)`.\n'
"7. Produce findings with severity (blocker/major/minor), "
"confidence (1-10), file:line and a proposed fix.\n"
"8. Call `dedupe_findings(findings=<your findings>)` to merge "
"and compute the PR quality score.\n"
'9. Call `generate_report(review_data=<verdict, scope, '
'metrics, merged findings>)` (format="both").\n'
"10. Output the verdict (✅ PASS / ❌ FAIL), severity counts, "
"each issue, and the manual-review items.\n"
)
else:
workflow = (
'5. Locate the feature code: `semantic_search_nodes(query='
'<target>)` and `query_graph(pattern="children_of", '
'target=<target>)`; collect the related files.\n'
"6. Map the blast radius: `get_impact_radius(changed_files="
"<collected files>)`.\n"
'7. Score the feature: `score_review(changed_files=<files + '
'impacted files>)`.\n'
"8. Review the feature code (Layer 1 chain decomposition) and "
"produce findings with severity, confidence, file:line and a "
"proposed fix.\n"
"9. Call `dedupe_findings(findings=<your findings>)` to merge "
"and compute the PR quality score.\n"
'10. Call `generate_report(review_data=<verdict, scope, '
'metrics, merged findings>)` (format="both").\n'
"11. Output the verdict (✅ PASS / ❌ FAIL), severity counts, "
"each issue, and the manual-review items.\n"
)
return _user(f"{_TOKEN_EFFICIENCY_PREAMBLE}\n{common}{workflow}")