Fix CI/CD: Add Gitea Actions workflow and fix linting issues

This commit is contained in:
Developer
2026-02-05 09:02:49 +00:00
commit d8325c4be2
111 changed files with 19657 additions and 0 deletions

View File

@@ -0,0 +1,133 @@
class ReviewPromptTemplates:
base_prompt: str = """You are an expert code reviewer analyzing staged changes in a Git repository.
Review the following code changes and provide detailed feedback on:
1. Potential bugs and security vulnerabilities
2. Code style and best practices violations
3. Performance concerns
4. Documentation issues
5. Suggestions for improvement
Respond in the following JSON format:
{{
"issues": [
{{
"file": "filename",
"line": line_number,
"severity": "critical|warning|info",
"category": "bug|security|style|performance|documentation",
"message": "description of the issue",
"suggestion": "suggested fix (if applicable)"
}}
],
"summary": {{
"critical_count": number,
"warning_count": number,
"info_count": number,
"overall_assessment": "brief summary"
}}
}}
Only include issues that match the strictness level: {strictness}
{strictness_settings}
Review the following diff:
```
{diff}
```
"""
permissive_settings: str = """Strictness: PERMISSIVE
- Only report critical security issues
- Only report definite bugs (not potential issues)
- Ignore style and formatting issues
- Ignore performance concerns
- Ignore documentation issues
"""
balanced_settings: str = """Strictness: BALANCED
- Report all security issues
- Report all definite bugs and potential bugs
- Report major style violations
- Ignore minor performance concerns
- Ignore documentation issues unless critical
"""
strict_settings: str = """Strictness: STRICT
- Report all security issues (even minor)
- Report all bugs (definite and potential)
- Report all style violations
- Report performance concerns
- Report documentation issues
- Suggest specific improvements
"""
@classmethod
def get_prompt(cls, diff: str, strictness: str = "balanced", language: str = "unknown") -> str:
settings_map = {
"permissive": cls.permissive_settings,
"balanced": cls.balanced_settings,
"strict": cls.strict_settings
}
settings = settings_map.get(strictness.lower(), cls.balanced_settings)
base = cls.base_prompt.format(
strictness=strictness.upper(),
strictness_settings=settings,
diff=diff
)
if language != "unknown":
base += f"\n\nNote: This code is in {language}. Apply {language}-specific best practices."
return base
@classmethod
def get_commit_review_prompt(cls, diff: str, commit_message: str, strictness: str = "balanced") -> str:
prompt = f"""Review the following commit with message: "{commit_message}"
Analyze whether the changes align with the commit message and provide feedback.
"""
prompt += cls.get_prompt(diff, strictness)
return prompt
@classmethod
def get_security_review_prompt(cls, diff: str) -> str:
template = """You are a security expert reviewing code changes for vulnerabilities.
Focus specifically on:
1. Injection vulnerabilities (SQL, command, code injection)
2. Authentication and authorization issues
3. Sensitive data exposure
4. Cryptographic weaknesses
5. Path traversal and file inclusion
6. Dependency security issues
Provide findings in JSON format:
```
{{
"vulnerabilities": [
{{
"file": "filename",
"line": line_number,
"severity": "critical|high|medium|low",
"type": "vulnerability type",
"description": "detailed description",
"exploit_scenario": "how it could be exploited",
"fix": "recommended fix"
}}
],
"secure_patterns": ["list of good security practices observed"],
"concerns": ["list of potential security concerns"]
}}
```
Review the following diff:
```
{diff}
```
"""
return template.format(diff=diff)