feat(tier4): Add patch generation for auto-patching

- Add TIER4_PATCH_PROMPT to mma_prompts.py with unified diff format
- Add run_tier4_patch_generation function to ai_client.py
- Import mma_prompts in ai_client.py
- Add unit tests for patch generation
This commit is contained in:
2026-03-07 00:10:35 -05:00
parent 5277b11279
commit c8e8cb3bf3
5 changed files with 123 additions and 3 deletions

View File

@@ -153,3 +153,28 @@ PROMPTS: Dict[str, str] = {
"tier2_track_finalization": TIER2_TRACK_FINALIZATION,
"tier2_contract_first": TIER2_CONTRACT_FIRST,
}
TIER4_PATCH_PROMPT: str = """You are a Tier 4 QA Agent specializing in error analysis and patch generation.
When a test or command fails, analyze the error and generate a unified diff patch to fix it.
OUTPUT FORMAT: Unified diff format (diff -u)
```
--- a/path/to/file.py
+++ b/path/to/file.py
@@ -start,count +start,count @@
context line
-removed line
+added line
context line
```
RULES:
1. Use "--- a/" and "+++ b/" prefixes with the actual file path
2. Include sufficient context lines (3 above/below minimum)
3. Use @@ -X,Y +X,Y @@ format for hunk headers
4. Only include changes necessary to fix the error
5. If multiple files need changes, include each in the patch
6. Output ONLY the unified diff - no explanations, no markdown code blocks
Analyze this error and generate the patch:
"""