|
3 | 3 | from typing import Any |
4 | 4 |
|
5 | 5 | from src.agents import get_agent |
6 | | -from src.api.recommendations import get_suggested_rules_from_repo |
| 6 | +from src.api.recommendations import generate_pr_body_for_suggested_rules, get_suggested_rules_from_repo |
7 | 7 | from src.core.config import config |
8 | 8 | from src.core.models import Severity, Violation |
9 | 9 | from src.core.utils.event_filter import NULL_SHA |
@@ -122,6 +122,8 @@ async def process(self, task: Task) -> ProcessingResult: |
122 | 122 | github_token=github_token, |
123 | 123 | rules_yaml=rules_yaml, |
124 | 124 | push_sha=payload.get("after") or payload.get("head_commit", {}).get("sha"), |
| 125 | + rules_translated=rules_count, |
| 126 | + rules_ambiguous=len(ambiguous), |
125 | 127 | ) |
126 | 128 | except Exception as e: |
127 | 129 | latency_ms = int((time.time() - scan_start) * 1000) |
@@ -234,6 +236,8 @@ async def _create_pr_with_suggested_rules( |
234 | 236 | github_token: str, |
235 | 237 | rules_yaml: str, |
236 | 238 | push_sha: str | None, |
| 239 | + rules_translated: int = 0, |
| 240 | + rules_ambiguous: int = 0, |
237 | 241 | ) -> None: |
238 | 242 | """ |
239 | 243 | Self-improving loop: create a branch with proposed .watchflow/rules.yaml and open a PR |
@@ -366,10 +370,12 @@ async def _create_pr_with_suggested_rules( |
366 | 370 | ) |
367 | 371 | return |
368 | 372 |
|
369 | | - pr_body = ( |
370 | | - "This PR was auto-generated by Watchflow because AI rule files (e.g. `rules.md`, " |
371 | | - "`*guidelines*.md`) were updated. It proposes updating `.watchflow/rules.yaml` with " |
372 | | - "the translated rules so your team can review the auto-generated constraints before merging." |
| 373 | + pr_body = generate_pr_body_for_suggested_rules( |
| 374 | + repo_full_name=repo_full_name, |
| 375 | + rules_yaml=rules_yaml, |
| 376 | + rules_translated=rules_translated, |
| 377 | + rules_ambiguous=rules_ambiguous, |
| 378 | + installation_id=installation_id, |
373 | 379 | ) |
374 | 380 | pr_result = await self.github_client.create_pull_request( |
375 | 381 | repo_full_name, |
|
0 commit comments