@comate/zulu 1.4.0-beta.2 → 1.4.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/comate-engine/assets/skills/auto-commit/SKILL.md +241 -0
- package/comate-engine/assets/skills/auto-commit/references/data_structures.md +183 -0
- package/comate-engine/assets/skills/auto-commit/references/interaction_instruction.md +220 -0
- package/comate-engine/assets/skills/auto-commit/references/issue_type_mapping.json +19 -0
- package/comate-engine/assets/skills/auto-commit/references/query_reference.md +176 -0
- package/comate-engine/assets/skills/auto-commit/scripts/build_git_commit_payload.py +195 -0
- package/comate-engine/assets/skills/auto-commit/scripts/build_icafe_cards_payload.py +80 -0
- package/comate-engine/assets/skills/auto-commit/scripts/cache_manager.py +69 -0
- package/comate-engine/assets/skills/auto-commit/scripts/create_card_cli.py +67 -0
- package/comate-engine/assets/skills/auto-commit/scripts/git_diff_cli.py +201 -0
- package/comate-engine/assets/skills/auto-commit/scripts/git_utils.py +230 -0
- package/comate-engine/assets/skills/auto-commit/scripts/icafe/__init__.py +66 -0
- package/comate-engine/assets/skills/auto-commit/scripts/icafe/client.py +473 -0
- package/comate-engine/assets/skills/auto-commit/scripts/icafe/farseer.py +52 -0
- package/comate-engine/assets/skills/auto-commit/scripts/icafe/matching.py +784 -0
- package/comate-engine/assets/skills/auto-commit/scripts/logger.py +32 -0
- package/comate-engine/assets/skills/auto-commit/scripts/match_card_cli.py +41 -0
- package/comate-engine/assets/skills/auto-commit/scripts/payload_validators.py +309 -0
- package/comate-engine/assets/skills/auto-commit/scripts/recognize_card_cli.py +63 -0
- package/comate-engine/assets/skills/{automation-browser-comate → automation-browser}/SKILL.md +1 -0
- package/comate-engine/assets/skills/{cnap-comate → cnap}/SKILL.md +1 -0
- package/comate-engine/assets/skills/code-review/SKILL.md +202 -0
- package/comate-engine/assets/skills/code-review/agents/correctness-reviewer.md +62 -0
- package/comate-engine/assets/skills/code-review/agents/custom-reviewer.md +53 -0
- package/comate-engine/assets/skills/code-review/agents/meta-reviewer.md +84 -0
- package/comate-engine/assets/skills/code-review/agents/reliability-reviewer.md +72 -0
- package/comate-engine/assets/skills/code-review/agents/reuse-reviewer.md +101 -0
- package/comate-engine/assets/skills/code-review/agents/style-reviewer.md +65 -0
- package/comate-engine/assets/skills/code-review/evals/SKILL.md +334 -0
- package/comate-engine/assets/skills/code-review/evals/agents/gt-generator.md +76 -0
- package/comate-engine/assets/skills/code-review/evals/agents/miner.md +87 -0
- package/comate-engine/assets/skills/code-review/evals/agents/score-judge.md +168 -0
- package/comate-engine/assets/skills/code-review/evals/references/cli-query-template.md +114 -0
- package/comate-engine/assets/skills/code-review/evals/references/gt-schema.md +77 -0
- package/comate-engine/assets/skills/code-review/references/custom-rules/RULE_TEMPLATE.md +141 -0
- package/comate-engine/assets/skills/code-review/references/dispatch-template.md +142 -0
- package/comate-engine/assets/skills/code-review/references/output-schema.md +197 -0
- package/comate-engine/assets/skills/code-review/references/report-format.md +41 -0
- package/comate-engine/assets/skills/code-review/references/rules/Go/GO_AUTH_RULES.md +29 -0
- package/comate-engine/assets/skills/code-review/references/rules/Go/GO_CORRECTNESS_RULES.md +111 -0
- package/comate-engine/assets/skills/code-review/references/rules/Go/GO_RESOURCE_CONCURRENCY_RULES.md +190 -0
- package/comate-engine/assets/skills/code-review/references/rules/Go/GO_STYLE_RULES.md +354 -0
- package/comate-engine/assets/skills/code-review/references/rules/Java/JAVA_AUTH_RULES.md +34 -0
- package/comate-engine/assets/skills/code-review/references/rules/Java/JAVA_CORRECTNESS_RULES.md +207 -0
- package/comate-engine/assets/skills/code-review/references/rules/Java/JAVA_RESOURCE_CONCURRENCY_RULES.md +220 -0
- package/comate-engine/assets/skills/code-review/references/rules/Java/JAVA_STYLE_RULES.md +306 -0
- package/comate-engine/assets/skills/code-review/references/rules/Js/JS_AUTH_RULES.md +48 -0
- package/comate-engine/assets/skills/code-review/references/rules/Js/JS_CORRECTNESS_RULES.md +364 -0
- package/comate-engine/assets/skills/code-review/references/rules/Js/JS_RESOURCE_CONCURRENCY_RULES.md +180 -0
- package/comate-engine/assets/skills/code-review/references/rules/Js/JS_STYLE_RULES.md +350 -0
- package/comate-engine/assets/skills/code-review/references/rules/Python/PYTHON_AUTH_RULES.md +38 -0
- package/comate-engine/assets/skills/code-review/references/rules/Python/PYTHON_CORRECTNESS_RULES.md +255 -0
- package/comate-engine/assets/skills/code-review/references/rules/Python/PYTHON_RESOURCE_CONCURRENCY_RULES.md +180 -0
- package/comate-engine/assets/skills/code-review/references/rules/Python/PYTHON_STYLE_RULES.md +195 -0
- package/comate-engine/assets/skills/code-review/references/telemetry.md +27 -0
- package/comate-engine/assets/skills/{code-security-comate → code-security}/SKILL.md +1 -0
- package/comate-engine/assets/skills/{comate-docs-comate → comate-docs}/SKILL.md +1 -1
- package/comate-engine/assets/skills/create-automation-tasks-comate/SKILL.md +300 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/references/backend_dev.md +109 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/references/env_setup.md +130 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/references/frontend_dev.md +74 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/references/git_operations.md +88 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/references/long_running_task.md +96 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/references/testing_strategy.md +94 -0
- package/comate-engine/assets/skills/create-automation-tasks-comate/scripts/check_config.py +397 -0
- package/comate-engine/assets/skills/{create-image-comate → create-image}/SKILL.md +14 -9
- package/comate-engine/assets/skills/{create-rule-comate → create-rule}/SKILL.md +1 -0
- package/comate-engine/assets/skills/{create-skill-comate → create-skill}/SKILL.md +2 -3
- package/comate-engine/assets/skills/{figma2code-comate → figma2code}/SKILL.md +1 -0
- package/comate-engine/assets/skills/{get-ugate-token-comate → get-ugate-token}/SKILL.md +97 -13
- package/comate-engine/assets/skills/get-ugate-token/getUgateToken.py +244 -0
- package/comate-engine/assets/skills/{icafe-comate → icafe}/SKILL.md +1 -13
- package/comate-engine/assets/skills/{icode-comate → icode}/SKILL.md +1 -0
- package/comate-engine/fallbackServer.js +1 -1
- package/comate-engine/node_modules/@baidu/comate-browser-use/dist/launch-chrome/index.js +1 -1
- package/comate-engine/node_modules/@baidu/comate-browser-use/package.json +5 -5
- package/comate-engine/node_modules/@comate/plugin-shared-internals/dist/index.js +3 -3
- package/comate-engine/package.json +1 -1
- package/comate-engine/server.js +137 -77
- package/dist/bundle/index.js +20 -9
- package/package.json +1 -1
- package/comate-engine/assets/skills/get-ugate-token-comate/getUgateToken.py +0 -150
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/references/cases.md +0 -0
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/references/deploy-troubleshoot.md +0 -0
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/references/install.md +0 -0
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/references/kubectl.md +0 -0
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/references/login.md +0 -0
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/references/oncall.md +0 -0
- /package/comate-engine/assets/skills/{cnap-comate → cnap}/scripts/install_cnap_cli.sh +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/references/credential_hosting.md +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/references/vul_repair-go_sql_injection.md +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/references/vul_repair-java_sql_injection.md +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/references/vul_repair-php_sql_injection.md +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/references/vul_repair-python_sql_injection.md +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/references/vul_repair_sensitive.md +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/credential_hosting.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/credential_poll.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/http_client.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/parse_scan_result.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/repair_vulnerability.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/report_chat.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/scan_vulnerability.py +0 -0
- /package/comate-engine/assets/skills/{code-security-comate → code-security}/scripts/utils.py +0 -0
- /package/comate-engine/assets/skills/{comate-docs-comate → comate-docs}/references/doc-map-extended.md +0 -0
- /package/comate-engine/assets/skills/{comate-docs-comate → comate-docs}/references/models-and-billing.md +0 -0
- /package/comate-engine/assets/skills/{comate-docs-comate → comate-docs}/references/product-overview.md +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/LICENSE.txt +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/agents/analyzer.md +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/agents/comparator.md +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/agents/grader.md +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/assets/eval_review.html +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/eval-viewer/generate_review.py +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/eval-viewer/viewer.html +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/references/schemas.md +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/__init__.py +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/__pycache__/aggregate_benchmark.cpython-311.pyc +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/aggregate_benchmark.py +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/generate_report.py +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/package_skill.py +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/quick_validate.py +0 -0
- /package/comate-engine/assets/skills/{create-skill-comate → create-skill}/scripts/utils.py +0 -0
- /package/comate-engine/assets/skills/{create-subagent-comate → create-subagent}/SKILL.md +0 -0
- /package/comate-engine/assets/skills/{figma2code-comate → figma2code}/references/codeConnect.md +0 -0
- /package/comate-engine/assets/skills/{figma2code-comate → figma2code}/references/designToken.md +0 -0
- /package/comate-engine/assets/skills/{figma2code-comate → figma2code}/references/image2design.md +0 -0
- /package/comate-engine/assets/skills/{find-skills-comate → find-skills}/SKILL.md +0 -0
- /package/comate-engine/assets/skills/{find-skills-comate → find-skills}/scripts/fetch_skills.py +0 -0
- /package/comate-engine/assets/skills/{find-skills-comate → find-skills}/scripts/get_download_url.py +0 -0
- /package/comate-engine/assets/skills/{find-skills-comate → find-skills}/scripts/install_skill.py +0 -0
- /package/comate-engine/assets/skills/{find-skills-comate → find-skills}/scripts/preview_skill.py +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/ai-workflows.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/commands.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/error-handling.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/git-auto-bindcard-workflow.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/git-bindcard-workflow.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/iql-syntax.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/platform-concepts.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/smart-create-workflow.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/smart-find-workflow.md +0 -0
- /package/comate-engine/assets/skills/{icafe-comate → icafe}/references/smart-update-workflow.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/add_reviewers.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/build_fetch_command.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/check_repo_permission.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/create_branch.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/create_draft_comment.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_ai_cr_result.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_ai_review.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_diff_content.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_diff_file.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_machine_check.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_my_reviews.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_person_commit.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_person_repo.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_repo_branch.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_repo_config.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_repo_members.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_repo_reviews.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_review_comments.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_review_info.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/get_submit_settings.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/icode-api.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/publish_comments.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/set_review_score.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/start_ai_review.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/submit_review.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/api/trigger_ai_cr.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/feature/add-reviewer.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/feature/fix-machine-check.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/feature/merge-cr.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/feature/ssh-setup.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/feature/submit-acr.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/feature/submit-cr.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/git/clone.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/git/icode-git.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/git/push.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/git/push_cr.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/install.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/references/login.md +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/add-reviewer.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/common.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/fix-machine-check.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/merge-cr.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/ssh-setup.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/submit-acr.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/submit-cr.sh +0 -0
- /package/comate-engine/assets/skills/{icode-comate → icode}/scripts/test-preflight.sh +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/SKILL.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/examples.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/add_member.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/change_scope.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/copy_doc.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/create_doc.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/delete_doc.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/edit_content.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/move_doc.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_comment.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_content.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_flowchart.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_permission.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_recent_view.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_repo.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/query_user_info.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/update_member.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/references/upload_attachment.md +0 -0
- /package/comate-engine/assets/skills/{ku-operator-comate → ku-operator}/scripts/ku_operator.py +0 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review-eval
|
|
3
|
+
description: >-
|
|
4
|
+
Evaluate the code-review skill's effectiveness by mining commits from a git repo,
|
|
5
|
+
generating semantic ground truth, running the skill on the diffs, and scoring
|
|
6
|
+
recall/precision/F1. Uses both bug-fix commits (positive samples) and clean commits
|
|
7
|
+
(negative samples) to measure both bug detection and false positive control.
|
|
8
|
+
Use this skill whenever the user mentions "evaluate code review", "benchmark code review",
|
|
9
|
+
"run code review eval", "test the code-review skill", "code review evaluation",
|
|
10
|
+
"assess code review quality", or wants to measure how well the code-review skill
|
|
11
|
+
performs on their codebase.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Code Review Skill Evaluation
|
|
15
|
+
|
|
16
|
+
Evaluate the code-review skill by testing whether it can discover known bugs from
|
|
17
|
+
bug-fix commit diffs, while also measuring false positive control on clean commits.
|
|
18
|
+
Supports two execution modes: **lite** (SubAgent, diff-only, fast iteration) and **full** (CLI parallel processes, production-representative evaluation with complete multi-agent pipeline).
|
|
19
|
+
|
|
20
|
+
## What This Evaluates
|
|
21
|
+
|
|
22
|
+
Two core abilities:
|
|
23
|
+
|
|
24
|
+
1. **Bug detection (Recall)**: Given a diff that **introduces** a known bug (reversed from a bug-fix commit), can the skill discover the bug? Uses reversed bug-fix commits as positive samples.
|
|
25
|
+
2. **False positive control (Precision)**: Given a clean diff with no bugs, can the skill correctly say "no issues found"? Uses feature/refactor commits as negative samples.
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
| Parameter | Default | Description |
|
|
30
|
+
|-----------|---------|-------------|
|
|
31
|
+
| repo | Current working directory | Target git repository path |
|
|
32
|
+
| limit | 20 | Number of samples per type (bug-fix + clean) |
|
|
33
|
+
| workdir | `<repo>-eval-output/` | Output directory for all artifacts |
|
|
34
|
+
| mode | `lite` | Step 3 执行模式:`lite`(SubAgent,纯 diff,快速迭代)或 `full`(外部 CLI,完整生产 pipeline) |
|
|
35
|
+
| cli | `zulu` | Full mode 使用的 CLI:`zulu`(需要 `license`)或 `baidu-cc`(走内部认证) |
|
|
36
|
+
| license | *(required for zulu)* | `zulu run` 的 SaaS license key,仅 `cli=zulu` 时需要 |
|
|
37
|
+
| concurrency | 5 | Full mode 并行 CLI 进程数上限,建议 3-10,过高可能触发 API 限流 |
|
|
38
|
+
|
|
39
|
+
## 4-Step Pipeline
|
|
40
|
+
|
|
41
|
+
### Step 1: Mine Commits
|
|
42
|
+
|
|
43
|
+
Use `git log` to get candidates, then use a SubAgent to filter into positive and negative samples.
|
|
44
|
+
|
|
45
|
+
1. Execute these commands to get candidate commits:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Positive candidates (bug-fix)
|
|
49
|
+
git -C <repo> log --oneline --all -n 500 | grep -iE '\[Bug\]|fix|crash|修复|问题|异常|错误'
|
|
50
|
+
|
|
51
|
+
# Negative candidates (clean)
|
|
52
|
+
git -C <repo> log --oneline --all -n 500 | grep -iE 'feat|feature|add|支持|新增|优化|improve|enhance|实现'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. Launch **one SubAgent** that:
|
|
56
|
+
- Reads `agents/miner.md` for filtering rules
|
|
57
|
+
- For each candidate commit, runs `git show --stat <hash>` and `git log -1 --format="%H%n%P" <hash>` in the repo
|
|
58
|
+
- Applies filtering rules (10-200 lines, ≤5 files, source code changes)
|
|
59
|
+
- Separates into bug-fix samples (`sample-XXXX`) and clean samples (`clean-XXXX`)
|
|
60
|
+
- Outputs a JSON array of selected candidates
|
|
61
|
+
|
|
62
|
+
3. Save the output to `<workdir>/candidates.json`
|
|
63
|
+
|
|
64
|
+
If `<workdir>/candidates.json` already exists, ask the user whether to re-mine or reuse.
|
|
65
|
+
|
|
66
|
+
### Step 2: Generate Semantic Ground Truth
|
|
67
|
+
|
|
68
|
+
For each candidate in `candidates.json`, launch **parallel SubAgents** (5-10 at a time):
|
|
69
|
+
|
|
70
|
+
Each SubAgent:
|
|
71
|
+
1. 根据样本类型生成 diff 命令:
|
|
72
|
+
- **bug-fix 样本**:`git -C <repo> diff <commit> <parent_commit> -- <source_files>`(**反转方向**:修复后 → 修复前,模拟"引入 bug 的变更")
|
|
73
|
+
- **clean 样本**:`git -C <repo> diff <parent_commit> <commit> -- <source_files>`(正常方向:引入新功能的变更)
|
|
74
|
+
2. Reads `agents/gt-generator.md` for the GT generation rules
|
|
75
|
+
3. **Information symmetry**: The SubAgent sees ONLY the diff, NOT the commit subject. **Also NOT the sample type** (`bug-fix` or `clean`). The SubAgent only receives the sample ID for identification purposes. This ensures the GT generator and the skill operate under identical information conditions.
|
|
76
|
+
4. Analyzes the diff independently to determine if the **newly introduced code** (the `+` lines in the diff) has issues
|
|
77
|
+
5. Outputs findings if issues are found, or empty findings array if the code looks correct
|
|
78
|
+
6. Writes semantic GT JSON to `<workdir>/semantic_gt/<id>.json`
|
|
79
|
+
|
|
80
|
+
**为什么反转 bug-fix diff**:真实的 code review 场景是审查"引入变更"的代码。如果直接用 bug-fix diff(修复前 → 修复后),skill 和 GT 生成器看到的是"有人在修 bug",自然会说"修复合理,通过"。反转后(修复后 → 修复前),变成"有人提交了这段有 bug 的代码",才是真正测试 skill 发现 bug 的能力。Clean 样本本身就是"引入新功能",不需要反转。
|
|
81
|
+
|
|
82
|
+
**Incremental**: If `<workdir>/semantic_gt/<id>.json` already exists, skip that sample.
|
|
83
|
+
|
|
84
|
+
Each GT file contains:
|
|
85
|
+
- `sample_id`: the sample identifier
|
|
86
|
+
- `findings[]`: issues found in the newly introduced code (may be empty for any sample type)
|
|
87
|
+
- `expected_review`: what a good reviewer should say when seeing this diff — i.e., spotting problems in the **newly introduced code** (the `+` lines)
|
|
88
|
+
|
|
89
|
+
**Note**: Since the GT generator doesn't know the sample type, some bug-fix samples may get empty GT (bug too subtle to see from diff alone), and some clean samples may get non-empty GT (the feature commit actually introduced issues). This is by design — it reflects the true difficulty of the review task.
|
|
90
|
+
|
|
91
|
+
### Step 3: Run Code Review on Diffs
|
|
92
|
+
|
|
93
|
+
根据 `mode` 参数选择执行方式:
|
|
94
|
+
|
|
95
|
+
- **`mode=lite`(默认)**:用 SubAgent 直接审查 diff,速度快但只能跑单 Agent、纯 diff 审查
|
|
96
|
+
- **`mode=full`**:用外部 CLI 进程运行完整 code-review skill,包含 4 Agent 并行 + Meta-Review + 完整代码库访问
|
|
97
|
+
|
|
98
|
+
#### Step 3 — Lite Mode(SubAgent)
|
|
99
|
+
|
|
100
|
+
当 `mode=lite` 或 CLI 不可用时使用此模式。
|
|
101
|
+
|
|
102
|
+
For each candidate, launch **parallel SubAgents** (5-10 at a time):
|
|
103
|
+
|
|
104
|
+
Each SubAgent:
|
|
105
|
+
1. 根据样本类型生成 diff 命令(与 Step 2 一致):
|
|
106
|
+
- **bug-fix 样本**:`git -C <repo> diff <commit> <parent_commit> -- <source_files>`(反转方向)
|
|
107
|
+
- **clean 样本**:`git -C <repo> diff <parent_commit> <commit> -- <source_files>`(正常方向)
|
|
108
|
+
2. Reads the code-review skill definition from `../SKILL.md` (the parent directory)
|
|
109
|
+
3. **Standard code-review task**: Review the code change as you would in a real PR review.
|
|
110
|
+
Do NOT assume there is a bug. The diff may be a bug-fix, a feature addition, a refactor, or anything else.
|
|
111
|
+
Evaluate the change for correctness, reliability, style, and reuse issues.
|
|
112
|
+
If the code looks correct and well-implemented, say so — do not force-find problems.
|
|
113
|
+
4. Produces a review report following Step 6 output format **strictly**:
|
|
114
|
+
- Severity sections: `### 🔴 P0 严重 (N)` / `### 🟠 P1 高优 (N)` / `### 🟡 P2 中等 (N)` / `### 🔵 P3 低优 (N)`
|
|
115
|
+
- Each finding: `**N. [path/to/file.ts:42](path/to/file.ts#L42)**`
|
|
116
|
+
- Followed by `- 问题:...` and `- 建议:...`
|
|
117
|
+
- If no issues: "本次审查未发现需要阻断合入的问题,审查通过"
|
|
118
|
+
5. Writes the report to `<workdir>/responses/<id>.response.md`
|
|
119
|
+
|
|
120
|
+
**Evaluation mode note**: The SubAgent is in eval mode — no `delegate_subtask`, no `ask_user_question`,
|
|
121
|
+
no Step 1 scope detection, no Step 8 user interaction. Just produce the review report.
|
|
122
|
+
|
|
123
|
+
**Incremental**: If `<workdir>/responses/<id>.response.md` already exists, skip that sample.
|
|
124
|
+
|
|
125
|
+
**Lite mode 局限性**:SubAgent 无法嵌套调用 `delegate_subtask`,因此只能跑单 Agent 审查,不能启动完整的 4 Agent 并行 + Meta-Review pipeline。SubAgent 也没有完整的代码库访问能力(如 `codebase_search`),复用审查维度几乎无法生效。评测结果是 skill 的**下界估计**。
|
|
126
|
+
|
|
127
|
+
#### Step 3 — Full Mode(CLI 并行)
|
|
128
|
+
|
|
129
|
+
当 `mode=full` 时使用此模式。每个样本通过独立的 CLI 进程运行完整的 code-review skill pipeline。
|
|
130
|
+
|
|
131
|
+
##### 前置检查
|
|
132
|
+
|
|
133
|
+
1. 验证 CLI 可用:执行 `which <cli>`(`zulu` 或 `baidu-cc`)。如果不可用,**警告用户并降级到 Lite Mode**。
|
|
134
|
+
2. 如果 `cli=zulu`,验证 `license` 参数已提供。未提供则警告并降级。
|
|
135
|
+
3. 向用户确认即将使用 Full Mode,展示样本数和预估并发数。
|
|
136
|
+
|
|
137
|
+
##### 执行流程
|
|
138
|
+
|
|
139
|
+
1. 读取 `<workdir>/candidates.json`
|
|
140
|
+
2. 过滤出还没有 `<workdir>/responses/<id>.response.md` 的样本(增量支持)
|
|
141
|
+
3. 读取 `references/cli-query-template.md` 获取 CLI 命令模板和 query 模板
|
|
142
|
+
4. 对每个待处理样本,用模板生成 CLI 命令。**注意 diff 方向**:
|
|
143
|
+
- bug-fix 样本:`git diff {COMMIT} {PARENT_COMMIT} -- {SOURCE_FILES}`(反转方向)
|
|
144
|
+
- clean 样本:`git diff {PARENT_COMMIT} {COMMIT} -- {SOURCE_FILES}`(正常方向)
|
|
145
|
+
填充占位符后生成完整 query
|
|
146
|
+
5. 通过 `run_command` 执行并行 shell 脚本,控制并发数为 `concurrency` 个
|
|
147
|
+
|
|
148
|
+
##### Shell 脚本模式
|
|
149
|
+
|
|
150
|
+
主 Agent 生成一段 shell 脚本并通过 `run_command` 执行。脚本模式如下:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
#!/bin/bash
|
|
154
|
+
WORKDIR="<workdir>"
|
|
155
|
+
REPO="<repo>"
|
|
156
|
+
MAX_PARALLEL=<concurrency>
|
|
157
|
+
RESPONSES_DIR="$WORKDIR/responses"
|
|
158
|
+
mkdir -p "$RESPONSES_DIR"
|
|
159
|
+
|
|
160
|
+
run_review() {
|
|
161
|
+
local ID="$1" PARENT="$2" COMMIT="$3" FILES="$4"
|
|
162
|
+
local OUTPUT="$RESPONSES_DIR/${ID}.response.md"
|
|
163
|
+
|
|
164
|
+
# 增量:跳过已有结果
|
|
165
|
+
[ -f "$OUTPUT" ] && echo "SKIP: $ID" && return 0
|
|
166
|
+
|
|
167
|
+
echo "START: $ID"
|
|
168
|
+
|
|
169
|
+
# --- 根据 CLI 选择命令 ---
|
|
170
|
+
# zulu:
|
|
171
|
+
local RESULT
|
|
172
|
+
RESULT=$(zulu run \
|
|
173
|
+
-l "<license>" \
|
|
174
|
+
--activate-skill code-review \
|
|
175
|
+
--cwd "$REPO" \
|
|
176
|
+
--display task \
|
|
177
|
+
-q "<query with filled placeholders>" 2>/dev/null) || {
|
|
178
|
+
echo "FAIL: $ID"
|
|
179
|
+
echo "# Review Failed" > "$OUTPUT"
|
|
180
|
+
return 0
|
|
181
|
+
}
|
|
182
|
+
# baidu-cc:
|
|
183
|
+
# RESULT=$(baidu-cc -p "<query with filled placeholders>" \
|
|
184
|
+
# --allowedTools "Bash,Read,Write,Edit,Glob,Grep,Agent" \
|
|
185
|
+
# --cwd "$REPO" 2>/dev/null) || { ... }
|
|
186
|
+
|
|
187
|
+
# 去除 YAML frontmatter(如有)
|
|
188
|
+
echo "$RESULT" | awk 'BEGIN{s=0} /^---$/{s++;next} s>=2{print} s<1{print}' > "$OUTPUT"
|
|
189
|
+
echo "DONE: $ID"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
# 并发控制:后台进程 + wait -n
|
|
193
|
+
RUNNING=0
|
|
194
|
+
<for each sample, call run_review with args &, control concurrency>
|
|
195
|
+
wait
|
|
196
|
+
echo "All reviews completed."
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
> **注意**:主 Agent 需要根据 `candidates.json` 动态构建样本参数列表,而不是写死在脚本中。
|
|
200
|
+
|
|
201
|
+
##### CLI Query 内容
|
|
202
|
+
|
|
203
|
+
每个 CLI 进程的 query 遵循 `references/cli-query-template.md` 中的模板,核心要点:
|
|
204
|
+
|
|
205
|
+
- **提供精确的 diff 命令**:根据样本类型决定 diff 方向(bug-fix 反转、clean 正常),跳过 Step 1 范围检测
|
|
206
|
+
- **禁止用户交互**:跳过 Step 8,不调用 `ask_user_question`
|
|
207
|
+
- **严格 Step 6 输出格式**:确保 score-judge 能正常解析
|
|
208
|
+
- **不预设 bug 存在**:和 Lite Mode 一样,不暗示样本类型
|
|
209
|
+
|
|
210
|
+
##### 失败处理
|
|
211
|
+
|
|
212
|
+
| 场景 | 处理 |
|
|
213
|
+
|------|------|
|
|
214
|
+
| CLI 进程异常退出 | 写 `# Review Failed` 占位文件,继续其他样本 |
|
|
215
|
+
| CLI 进程超时 | 同上 |
|
|
216
|
+
| 输出中缺少 severity section | 保留原始输出,score-judge 会按"审查通过"处理 |
|
|
217
|
+
| 部分样本失败 | 在 Step 4 报告中统计失败数,不影响已成功样本的评分 |
|
|
218
|
+
| 用户中断(Ctrl-C) | 增量设计,重跑自动跳过已完成样本 |
|
|
219
|
+
|
|
220
|
+
##### Full Mode 的优势
|
|
221
|
+
|
|
222
|
+
- 被测 skill 运行**完整生产 pipeline**:4 个专业 Agent 并行(correctness/style/reliability/reuse)+ Meta-Review 降噪
|
|
223
|
+
- 每个 CLI 进程拥有完整工具集:`read_file`、`grep_content`、`codebase_search`,可读取完整文件上下文
|
|
224
|
+
- 评测结果直接代表用户实际体验到的 skill 质量
|
|
225
|
+
|
|
226
|
+
**Incremental**: If `<workdir>/responses/<id>.response.md` already exists, skip that sample.
|
|
227
|
+
|
|
228
|
+
### Step 4: Score and Report
|
|
229
|
+
|
|
230
|
+
For each sample, launch **one SubAgent** per sample (or batch 5-10 in parallel):
|
|
231
|
+
|
|
232
|
+
Each SubAgent:
|
|
233
|
+
1. Reads `<workdir>/semantic_gt/<id>.json` (the GT)
|
|
234
|
+
2. Reads `<workdir>/responses/<id>.response.md` (the skill's review)
|
|
235
|
+
3. Reads `agents/score-judge.md` for judging rules
|
|
236
|
+
4. Determines the sample type from `candidates.json` (NOT from the GT file — the GT generator doesn't know sample type)
|
|
237
|
+
5. For bug-fix samples with GT findings: checks if any predicted finding semantically matches a GT finding
|
|
238
|
+
6. For bug-fix samples with empty GT (`gt_blind=true`): the bug was too subtle for diff-only analysis; if skill found it anyway, it's a bonus hit
|
|
239
|
+
7. For clean samples with empty GT: checks if the skill correctly reported "no issues" (correct negative) or falsely reported a P0-P2 issue (false positive)
|
|
240
|
+
8. For clean samples with GT findings: the GT independently found issues in the feature commit; if the skill found the same issues, it's a hit (NOT a false positive)
|
|
241
|
+
9. Outputs a JSON score result with `sample_type`, `gt_blind`, `hits`, `false_positives`, `correct_negatives`
|
|
242
|
+
10. Writes to `<workdir>/scores/<id>.json`
|
|
243
|
+
|
|
244
|
+
After all scoring SubAgents complete, the **main Agent** aggregates results and writes `<workdir>/report.md`.
|
|
245
|
+
|
|
246
|
+
#### Report structure
|
|
247
|
+
|
|
248
|
+
```markdown
|
|
249
|
+
# Code Review Skill Evaluation Report
|
|
250
|
+
|
|
251
|
+
**Mode**: lite / full
|
|
252
|
+
**CLI**: zulu / baidu-cc (full mode only)
|
|
253
|
+
|
|
254
|
+
## Overall Metrics
|
|
255
|
+
| Metric | Value |
|
|
256
|
+
|--------|-------|
|
|
257
|
+
| Bug-fix samples | N |
|
|
258
|
+
| Clean samples | N |
|
|
259
|
+
| GT findings (bug-fix, excl. gt_blind) | N |
|
|
260
|
+
| GT findings (clean, unexpected) | N |
|
|
261
|
+
| Predicted findings (bug-fix) | N |
|
|
262
|
+
| Predicted findings (clean) | N |
|
|
263
|
+
| Recall | X% (hits / GT findings, excl. gt_blind) |
|
|
264
|
+
| Recall (incl. gt_blind bonus) | X% |
|
|
265
|
+
| Precision | X% (hits / total pred P0-P2) |
|
|
266
|
+
| False Positive Rate | X% (FP on clean samples with empty GT) |
|
|
267
|
+
| Correct Negative Rate | X% (correct negatives / clean samples with empty GT) |
|
|
268
|
+
| GT Blindness Rate | X% (gt_blind bug-fix samples / total bug-fix samples) |
|
|
269
|
+
| F1 | X% |
|
|
270
|
+
|
|
271
|
+
## Bug-Fix Sample Results (Recall)
|
|
272
|
+
| Sample | GT | GT Blind | Pred | Hit | FP | Recall |
|
|
273
|
+
|--------|:--:|:--------:|:----:|:---:|:--:|:------:|
|
|
274
|
+
|
|
275
|
+
## Clean Sample Results (False Positive Control)
|
|
276
|
+
| Sample | GT | Pred | Hit | FP | Correct Negative |
|
|
277
|
+
|--------|:--:|:----:|:---:|:--:|:---------------|
|
|
278
|
+
|
|
279
|
+
## GT Blindness Analysis
|
|
280
|
+
(bug-fix samples where GT also couldn't find the bug from diff alone)
|
|
281
|
+
|
|
282
|
+
## Worst Samples (missed bugs)
|
|
283
|
+
## False Positive Analysis
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Metric definitions
|
|
287
|
+
|
|
288
|
+
- **Recall**: Of all GT findings in bug-fix samples (excluding `gt_blind` samples), how many did the skill find?
|
|
289
|
+
- **Recall (incl. gt_blind bonus)**: Same as Recall, but gt_blind samples where the skill found the bug are counted as bonus hits (numerator only, not denominator).
|
|
290
|
+
- **Precision**: Of all P0-P2 findings the skill reported across ALL samples, how many matched a GT finding?
|
|
291
|
+
- **False Positive Rate**: Of clean samples where GT is also empty, what fraction did the skill incorrectly flag with a P0-P2 finding?
|
|
292
|
+
- **Correct Negative Rate**: Of clean samples where GT is also empty, what fraction correctly got "no issues"?
|
|
293
|
+
- **GT Blindness Rate**: Of bug-fix samples, what fraction had empty GT (bug too subtle for diff-only analysis)? A high rate suggests the sample set contains many subtle bugs that are hard to detect from diffs alone.
|
|
294
|
+
- **F1**: Harmonic mean of Recall and Precision.
|
|
295
|
+
|
|
296
|
+
## Reading the Report
|
|
297
|
+
|
|
298
|
+
- **Recall ≥ 60%**: decent — the skill catches most known bugs
|
|
299
|
+
- **False Positive Rate ≤ 20%**: good — the skill doesn't over-report on clean diffs
|
|
300
|
+
- **F1 ≥ 50%**: solid overall performance
|
|
301
|
+
|
|
302
|
+
## Important Notes
|
|
303
|
+
|
|
304
|
+
- **Lite mode vs Full mode**: Lite mode 评估简化版单 Agent 审查(下界估计),适合快速迭代和调试。Full mode 评估完整生产 pipeline(4 Agent 并行 + Meta-Review + 代码库访问),结果直接代表用户体验。**正式评测建议使用 Full mode**。
|
|
305
|
+
- **模式切换注意事项**:两种模式产出的 `responses/` 文件不应混用。如果从 lite 切换到 full(或反向),应先清空 `<workdir>/responses/` 目录再重跑 Step 3,否则增量逻辑会跳过已有文件。
|
|
306
|
+
- **Information symmetry**: GT generator and skill see the same diff (no commit subject, **no sample type**). The GT generator does not know whether a sample is bug-fix or clean. This prevents confirmation bias and ensures the GT reflects what's actually visible from the diff.
|
|
307
|
+
- **Reversed diff for bug-fix samples**: Bug-fix samples use reversed diff (`commit → parent`), making the diff look like "someone introduced this buggy code". This aligns the evaluation task with real code review: reviewing newly submitted code for problems. Clean samples use normal diff direction (`parent → commit`) since they already represent "introducing new functionality".
|
|
308
|
+
- **No confirmation bias**: Both Step 2 (GT generation) and Step 3 (skill execution) use standard instructions with no hint about sample type. Both must independently decide if there are issues.
|
|
309
|
+
- **GT blindness handling**: When a bug-fix sample's GT is empty (`gt_blind=true`), it means the bug is too subtle to detect from the diff alone. These samples are excluded from the Recall denominator to avoid unfairly penalizing the skill. If the skill finds the bug anyway, it's counted as a bonus.
|
|
310
|
+
- **Clean sample fairness**: If the GT generator independently finds issues in a clean sample, skill findings that match are counted as hits, not false positives. This prevents penalizing the skill for correct behavior.
|
|
311
|
+
- **Lower-bound evaluation (lite mode only)**: Lite mode 的 SubAgent 只能看 diff(无完整文件访问)。Full mode 无此限制,CLI 进程拥有完整工具集。
|
|
312
|
+
- **Incremental runs**: All steps skip existing outputs. Safe to re-run at any time.
|
|
313
|
+
- **GT quality**: Semantic GT is generated by SubAgent analysis of diffs without knowing sample type. For high-stakes evaluation, spot-check `semantic_gt/*.json` files manually, especially gt_blind cases.
|
|
314
|
+
- **Portability**: Works on any git repo. Just point `repo` at the target.
|
|
315
|
+
|
|
316
|
+
## Output Structure
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
<workdir>/
|
|
320
|
+
candidates.json # Step 1: bug-fix + clean samples
|
|
321
|
+
semantic_gt/ # Step 2: one JSON per sample
|
|
322
|
+
sample-0001.json # bug-fix sample with findings
|
|
323
|
+
clean-0001.json # clean sample with empty findings
|
|
324
|
+
...
|
|
325
|
+
responses/ # Step 3: review reports
|
|
326
|
+
sample-0001.response.md
|
|
327
|
+
clean-0001.response.md
|
|
328
|
+
...
|
|
329
|
+
scores/ # Step 4: per-sample scoring
|
|
330
|
+
sample-0001.json
|
|
331
|
+
clean-0001.json
|
|
332
|
+
...
|
|
333
|
+
report.md # Step 4: aggregated report
|
|
334
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Semantic Ground Truth Generator
|
|
2
|
+
|
|
3
|
+
你是一个代码审查评测专家。给定一个 commit 的 diff,你的任务是为评测生成 ground truth。
|
|
4
|
+
|
|
5
|
+
## 核心原则
|
|
6
|
+
|
|
7
|
+
GT 生成器和 code-review skill 必须看到**完全相同的信息**,以确保评测公平。
|
|
8
|
+
|
|
9
|
+
**两者都只能看到 diff**。不能利用 commit subject、ticket 号、样本类型等额外信息来推断是否存在 bug。
|
|
10
|
+
|
|
11
|
+
## 输入
|
|
12
|
+
|
|
13
|
+
你会收到:
|
|
14
|
+
- 完整的 git diff
|
|
15
|
+
- 样本 ID(如 `sample-0001` 或 `clean-0001`,仅用于标识,不代表代码质量)
|
|
16
|
+
|
|
17
|
+
**注意**:你不会被告知这个 diff 是什么类型的变更。你必须完全依赖 diff 内容本身来独立判断。
|
|
18
|
+
|
|
19
|
+
## 任务
|
|
20
|
+
|
|
21
|
+
分析 diff,判断**新引入的代码(diff 中的 `+` 行)**是否存在值得指出的问题。
|
|
22
|
+
|
|
23
|
+
这是一个标准的 code review 任务:有人提交了一段代码变更,你需要审查这次变更引入的代码是否有 bug 或缺陷。
|
|
24
|
+
|
|
25
|
+
### 如果发现问题
|
|
26
|
+
|
|
27
|
+
从 diff 中识别新引入代码存在的 bug 或缺陷。重点关注:
|
|
28
|
+
- diff 中新增的代码(`+` 行)是否引入了问题
|
|
29
|
+
- 这个问题的根因是什么
|
|
30
|
+
|
|
31
|
+
产出 1-N 条 findings,每条描述一个独立的问题。
|
|
32
|
+
|
|
33
|
+
### 如果未发现问题
|
|
34
|
+
|
|
35
|
+
如果 diff 看起来是正常的功能增强、重构或改进,且新引入的代码不存在明显问题,产出**空的 findings 数组**。
|
|
36
|
+
|
|
37
|
+
**重要**:不要硬凑问题。只有在 diff 中确实能看出新引入代码存在缺陷时才输出 findings。
|
|
38
|
+
|
|
39
|
+
## 输出格式
|
|
40
|
+
|
|
41
|
+
**仅输出 JSON 对象**,不要包含任何其他文字:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"sample_id": "<id>",
|
|
46
|
+
"findings": [
|
|
47
|
+
{
|
|
48
|
+
"file": "<相对于仓库根目录的文件路径>",
|
|
49
|
+
"line_range": [起始行, 结束行],
|
|
50
|
+
"dimension": "<correctness|reliability|style|reuse>",
|
|
51
|
+
"severity": "<P0|P1|P2|P3>",
|
|
52
|
+
"description": "<描述新引入的代码存在什么问题>",
|
|
53
|
+
"root_cause": "<为什么存在这个问题>",
|
|
54
|
+
"expected_review": "<一个优秀的 reviewer 看到这个 diff 时应该说什么>"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 规则
|
|
61
|
+
|
|
62
|
+
1. **只看 diff**。不要利用 commit subject、样本类型或其他元信息来推断是否存在 bug。
|
|
63
|
+
2. **独立判断**:你的角色和 code-review skill 完全对等——只从 diff 中判断新引入的代码是否有问题。
|
|
64
|
+
3. **一个独立问题只对应一条 finding**。不要按 diff hunk 逐条展开。
|
|
65
|
+
4. `description` 应描述**新引入的代码存在什么问题**(`+` 行引入的缺陷)。
|
|
66
|
+
5. `root_cause` 应解释**问题为什么存在**(深层原因)。
|
|
67
|
+
6. `expected_review` 应描述**一个优秀的 reviewer 看到这个 diff 时应该指出的问题**。这是判分的关键锚点。
|
|
68
|
+
7. `line_range` 应覆盖包含根因的最小代码区域。
|
|
69
|
+
8. `severity` 反映问题的严重程度,与主 skill 保持一致:
|
|
70
|
+
- **P0**:明确的严重 bug、安全漏洞、数据损坏或崩溃风险
|
|
71
|
+
- **P1**:高概率逻辑问题、显著性能问题、重要边界错误
|
|
72
|
+
- **P2**:中等可维护性或稳定性问题
|
|
73
|
+
- **P3**:低风险改进项或代码风格建议
|
|
74
|
+
9. `dimension` 反映问题的主要类别,与主 skill 的四个审查维度对齐:`correctness`(正确性)、`reliability`(可靠性/资源/并发/鉴权)、`style`(代码规范)、`reuse`(复用)。
|
|
75
|
+
10. **没有问题就输出空 findings**:如果 diff 看起来是合理的改进且新引入代码无明显缺陷,输出空数组 `[]`。不要硬凑。
|
|
76
|
+
11. **仅输出 JSON,不要输出任何其他内容**。
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Commit Miner
|
|
2
|
+
|
|
3
|
+
你是一个代码审查评测的数据挖掘专家。你的任务是从 git 仓库的 commit 历史中筛选出两类评测样本:
|
|
4
|
+
|
|
5
|
+
1. **正样本(bug-fix)**:已知包含 bug 修复的 commit
|
|
6
|
+
2. **负样本(clean)**:正常的功能增强、重构等 commit(不包含 bug 修复)
|
|
7
|
+
|
|
8
|
+
## 输入
|
|
9
|
+
|
|
10
|
+
你会收到:
|
|
11
|
+
- 仓库路径
|
|
12
|
+
- 一份候选 commit 列表(通过 `git log` 获取,包含 hash + subject)
|
|
13
|
+
|
|
14
|
+
## 工作方式
|
|
15
|
+
|
|
16
|
+
对每个候选 commit:
|
|
17
|
+
|
|
18
|
+
1. 执行 `git show --stat <hash>` 查看变更规模和涉及的文件
|
|
19
|
+
2. 执行 `git log -1 --format="%H%n%P%n%s%n%b" <hash>` 获取完整 commit 信息
|
|
20
|
+
3. 根据下方规则判断属于正样本还是负样本还是排除
|
|
21
|
+
|
|
22
|
+
## 正样本筛选规则
|
|
23
|
+
|
|
24
|
+
**保留**满足以下所有条件的 commit,标记 `"type": "bug-fix"`:
|
|
25
|
+
- commit message 包含 bug/fix/crash/修复/问题/异常/错误 等关键词(不区分大小写)
|
|
26
|
+
- 变更规模在 10-200 行之间
|
|
27
|
+
- 变更文件数 ≤ 5 个
|
|
28
|
+
- 主要修改的是源代码文件
|
|
29
|
+
|
|
30
|
+
**排除**:
|
|
31
|
+
- commit message 包含 refactor/rename/revert/docs/chore/style/lint/merge/update dependency
|
|
32
|
+
- 纯测试文件变更
|
|
33
|
+
|
|
34
|
+
## 负样本筛选规则
|
|
35
|
+
|
|
36
|
+
**保留**满足以下所有条件的 commit,标记 `"type": "clean"`:
|
|
37
|
+
- commit message 包含 feature/add/feat/支持/新增/优化/improve/enhance/new/实现 等关键词
|
|
38
|
+
- 变更规模在 10-200 行之间
|
|
39
|
+
- 变更文件数 ≤ 5 个
|
|
40
|
+
- 主要修改的是源代码文件
|
|
41
|
+
- **不包含** bug/fix/crash/修复/问题/异常/错误 等关键词
|
|
42
|
+
|
|
43
|
+
**排除**:
|
|
44
|
+
- 纯测试文件变更、纯配置变更
|
|
45
|
+
- commit message 包含 refactor/rename/revert/docs/chore/style/lint/merge/update dependency
|
|
46
|
+
|
|
47
|
+
## 输出
|
|
48
|
+
|
|
49
|
+
输出 JSON 数组,每个元素代表一个筛选后的 commit:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
[
|
|
53
|
+
{
|
|
54
|
+
"id": "sample-0001",
|
|
55
|
+
"commit": "abc123def456",
|
|
56
|
+
"parent_commit": "parent_hash",
|
|
57
|
+
"subject": "commit subject line",
|
|
58
|
+
"type": "bug-fix",
|
|
59
|
+
"source_files": ["path/to/file1.ts", "path/to/file2.ts"],
|
|
60
|
+
"language_exts": [".ts"],
|
|
61
|
+
"changed_lines": 45,
|
|
62
|
+
"file_count": 2
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "clean-0001",
|
|
66
|
+
"commit": "def456abc789",
|
|
67
|
+
"parent_commit": "parent_hash",
|
|
68
|
+
"subject": "commit subject line",
|
|
69
|
+
"type": "clean",
|
|
70
|
+
"source_files": ["path/to/file1.ts"],
|
|
71
|
+
"language_exts": [".ts"],
|
|
72
|
+
"changed_lines": 30,
|
|
73
|
+
"file_count": 1
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 规则
|
|
79
|
+
|
|
80
|
+
- `parent_commit` 通过 `git log -1 --format="%P" <hash>` 获取(取第一个 parent)
|
|
81
|
+
- `source_files` 只包含源代码文件,排除 .json/.yaml/.md/.txt 等非源码文件
|
|
82
|
+
- `language_exts` 从 source_files 的扩展名提取
|
|
83
|
+
- `changed_lines` 从 `git show --stat` 的最后一行统计数字获取
|
|
84
|
+
- 正样本 id 格式:`sample-XXXX`(按顺序编号)
|
|
85
|
+
- 负样本 id 格式:`clean-XXXX`(按顺序编号)
|
|
86
|
+
- **正负样本数量建议 1:1**,但至少各保留 5 个
|
|
87
|
+
- 只输出 JSON 数组,不要输出任何其他内容
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Precision Judge
|
|
2
|
+
|
|
3
|
+
你是一个代码审查评测的判分器。你的任务是判定 code-review skill 的输出是否发现了已知问题。
|
|
4
|
+
|
|
5
|
+
## 背景
|
|
6
|
+
|
|
7
|
+
评测流程:
|
|
8
|
+
1. 从 git 历史中取出 commit 的 diff
|
|
9
|
+
2. 样本分两类:
|
|
10
|
+
- **bug-fix 样本**:从 bug-fix commit 中取出的**反转 diff**(修复后 → 修复前),模拟"有人提交了引入 bug 的代码"
|
|
11
|
+
- **clean 样本**:从 feature/enhance commit 中取出的正常 diff(修改前 → 修改后)
|
|
12
|
+
3. GT 生成器和 code-review skill 都只看到 diff(不知道样本类型),各自独立产出分析结果
|
|
13
|
+
4. 你需要结合样本类型和 GT,判断 skill 的表现
|
|
14
|
+
|
|
15
|
+
## 输入
|
|
16
|
+
|
|
17
|
+
- **样本类型**:`bug-fix` 或 `clean`(来自 candidates.json,不是 GT 生成器标注的)
|
|
18
|
+
- **GT findings**: GT 生成器独立分析产出的 findings(可能为空)
|
|
19
|
+
- **Predicted findings**: skill 在审查报告中实际说了什么
|
|
20
|
+
|
|
21
|
+
## 维度映射
|
|
22
|
+
|
|
23
|
+
GT 的 `dimension` 与主 skill 的 `reviewer`/`category` 对应关系如下。判分时用此映射理解 skill 输出的分类含义:
|
|
24
|
+
|
|
25
|
+
| GT `dimension` | 主 skill `reviewer` | 对应的 `category` 值 |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `correctness` | `correctness` | `null-safety`, `type-error`, `data-structure`, `exception-handling`, `variable-param`, `string-format`, `control-flow`, `oop-error`, `framework-bug` |
|
|
28
|
+
| `reliability` | `reliability` | `resource-leak`, `concurrency-race`, `thread-safety`, `db-operation`, `async-issue`, `auth-missing`, `auth-bypass`, `auth-logic-error`, `performance-issue` |
|
|
29
|
+
| `style` | `style` | `code-format`, `naming-convention`, `code-style`, `comment-style`, `vue-style`, `react-style` |
|
|
30
|
+
| `reuse` | `reuse` | `duplicate-function`, `inline-reimplementation`, `similar-pattern` |
|
|
31
|
+
|
|
32
|
+
**注意**:
|
|
33
|
+
- 判分时**不要因为 dimension/reviewer 不匹配就判定 miss**。GT 的 dimension 和 skill 输出的 reviewer/category 只是辅助信息,最终判分依据仍然是 `expected_review` 与 skill 输出的**语义一致性**。
|
|
34
|
+
- 如果 GT finding 的 `dimension` 为 `efficiency` 或 `quality`(历史数据),将其映射到 `reliability`(performance-issue 等)。
|
|
35
|
+
|
|
36
|
+
## 判分逻辑
|
|
37
|
+
|
|
38
|
+
### 对于 bug-fix 样本
|
|
39
|
+
|
|
40
|
+
bug-fix 样本使用反转 diff,diff 中的 `+` 行是引入 bug 的代码。skill 的任务是发现这些新引入代码中的问题。
|
|
41
|
+
|
|
42
|
+
#### 情况 A:GT 有 findings
|
|
43
|
+
|
|
44
|
+
对每个 GT finding,判断 skill 是否命中:
|
|
45
|
+
|
|
46
|
+
**命中(hit=1)**:skill 的输出和 GT 的 `expected_review` 语义一致,指向同一个底层问题。文件必须匹配,问题的核心相同。
|
|
47
|
+
|
|
48
|
+
**未命中(hit=0)**:skill 说"审查通过"、发现了完全不同的文件、或发现了 GT 中没有的其他问题。
|
|
49
|
+
|
|
50
|
+
#### 情况 B:GT 无 findings(bug 过于隐蔽,GT 也未发现)
|
|
51
|
+
|
|
52
|
+
此情况说明这个 bug 即使在反转 diff 中也很难看出。标记为 `gt_blind=true`。
|
|
53
|
+
- 如果 skill 也没发现:`hit=0`,但 `gt_blind=true`(不计入 Recall 分母,因为 GT 也看不出来)
|
|
54
|
+
- 如果 skill 反而发现了:`hit=1`,`gt_blind=true`(skill 表现超出 GT,是加分项)
|
|
55
|
+
|
|
56
|
+
### 对于 clean 样本
|
|
57
|
+
|
|
58
|
+
#### 情况 A:GT 无 findings(GT 也认为 diff 无问题)
|
|
59
|
+
|
|
60
|
+
**正确(correct=1)**:skill 说"审查通过"或"未发现需要阻断合入的问题",或只报告了 P3 级别的代码风格建议。
|
|
61
|
+
|
|
62
|
+
**误报(false_positive=1)**:skill 报告了 P0/P1/P2 级别的问题。
|
|
63
|
+
|
|
64
|
+
#### 情况 B:GT 有 findings(GT 独立发现了 clean 样本中的问题)
|
|
65
|
+
|
|
66
|
+
此情况说明这个 feature commit 实际上也存在问题。按 bug-fix 样本的逻辑判分:
|
|
67
|
+
- 如果 skill 的 finding 和 GT 的 finding 语义匹配:`hit=1`(skill 正确发现了问题,不算误报)
|
|
68
|
+
- 如果 skill 的 finding 和 GT 的 finding 不匹配:按正常逻辑判断是命中、未命中还是误报
|
|
69
|
+
|
|
70
|
+
**关键**:当 GT 在 clean 样本上也发现了问题时,skill 发现同样的问题是正确行为,**绝不能算误报**。
|
|
71
|
+
|
|
72
|
+
## 输出
|
|
73
|
+
|
|
74
|
+
仅输出 JSON,不要包含任何其他内容:
|
|
75
|
+
|
|
76
|
+
### bug-fix 样本(GT 有 findings)
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"sample_type": "bug-fix",
|
|
81
|
+
"gt_blind": false,
|
|
82
|
+
"gt_count": 1,
|
|
83
|
+
"pred_count": 3,
|
|
84
|
+
"hits": 1,
|
|
85
|
+
"false_positives": 2,
|
|
86
|
+
"correct_negatives": 0,
|
|
87
|
+
"details": [
|
|
88
|
+
{
|
|
89
|
+
"gt_idx": 0,
|
|
90
|
+
"gt_description": "新引入代码的 bug 描述",
|
|
91
|
+
"matched_pred": "skill 实际说了什么",
|
|
92
|
+
"hit": true,
|
|
93
|
+
"reason": "判定理由"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### bug-fix 样本(GT 也未发现 bug,gt_blind)
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"sample_type": "bug-fix",
|
|
104
|
+
"gt_blind": true,
|
|
105
|
+
"gt_count": 0,
|
|
106
|
+
"pred_count": 1,
|
|
107
|
+
"hits": 1,
|
|
108
|
+
"false_positives": 0,
|
|
109
|
+
"correct_negatives": 0,
|
|
110
|
+
"details": [
|
|
111
|
+
{
|
|
112
|
+
"gt_idx": null,
|
|
113
|
+
"gt_description": "GT 未发现问题(bug 过于隐蔽)",
|
|
114
|
+
"matched_pred": "skill 实际发现的问题",
|
|
115
|
+
"hit": true,
|
|
116
|
+
"reason": "skill 在 GT 也看不出的情况下独立发现了 bug,超出 GT 基准"
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### clean 样本(GT 无 findings,skill 也无问题)
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"sample_type": "clean",
|
|
127
|
+
"gt_blind": false,
|
|
128
|
+
"gt_count": 0,
|
|
129
|
+
"pred_count": 0,
|
|
130
|
+
"hits": 0,
|
|
131
|
+
"false_positives": 0,
|
|
132
|
+
"correct_negatives": 1,
|
|
133
|
+
"details": []
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### clean 样本(GT 有 findings,skill 也发现了同样问题)
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"sample_type": "clean",
|
|
142
|
+
"gt_blind": false,
|
|
143
|
+
"gt_count": 1,
|
|
144
|
+
"pred_count": 1,
|
|
145
|
+
"hits": 1,
|
|
146
|
+
"false_positives": 0,
|
|
147
|
+
"correct_negatives": 0,
|
|
148
|
+
"details": [
|
|
149
|
+
{
|
|
150
|
+
"gt_idx": 0,
|
|
151
|
+
"gt_description": "GT 在 clean 样本中发现的问题",
|
|
152
|
+
"matched_pred": "skill 发现的同样问题",
|
|
153
|
+
"hit": true,
|
|
154
|
+
"reason": "skill 和 GT 一致发现了 clean 样本中的真实问题,不算误报"
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 规则
|
|
161
|
+
|
|
162
|
+
1. **重点看 `expected_review`**:这是 GT 中最关键的判分依据。
|
|
163
|
+
2. **宽松但不过度宽松**:skill 的表述不需要和 GT 完全一致,但必须指向同一个底层问题。如果只是"同一个文件的不同问题",不算命中。
|
|
164
|
+
3. **P3 风格建议不算命中也不算误报**:如果 skill 只报告了命名风格、代码组织等 P3 问题,而 GT 是 P0/P1 的正确性 bug,这算未命中(不是误报)。
|
|
165
|
+
4. **误报只针对 P0-P2 级别**:skill 报告了一个不存在的 P0/P1/P2 问题才算误报。P3 不算。
|
|
166
|
+
5. **保守判定**:如果不确定,判定为 miss(hit=0)。
|
|
167
|
+
6. **尊重 GT 的盲审结果**:GT 生成器不知道样本类型,它的 findings 反映了"仅从 diff 能看出的问题"。当 GT 和 skill 一致发现问题时(即使在 clean 样本上),这是正确行为。
|
|
168
|
+
7. **gt_blind 标记**:当 bug-fix 样本的 GT 为空时,标记 `gt_blind=true`,这些样本在计算 Recall 时需要特殊处理。
|