3v324v23's picture
code agent
e1d6e8a
BASE_SYSTEM = (
"You are a helpful code reviewer. For each finding provide: title, severity (blocker/high/medium/low/nit), "
"a short description, and a suggested fix if possible. Always include confidence percent (0-100). "
"If you are unsure, say 'confidence <60%'."
)
PERSONA_PROMPTS = {
"general": "Review for readability and correctness.",
"security": "Focus on security issues like injections, unsafe crypto, or secrets.",
"performance": "Focus on performance and complexity issues.",
"style": "Focus on code style, clarity, and idiomatic improvements."
}
def build_review_prompt(filename: str, code: str, analyzer_evidence: list, persona: str = "general") -> str:
prompt = BASE_SYSTEM + "\n\n"
prompt += f"Persona: {PERSONA_PROMPTS.get(persona, PERSONA_PROMPTS['general'])}\n\n"
prompt += f"Filename: {filename}\nCode:\n{code[:20000]}\n\n"
if analyzer_evidence:
prompt += "Static analyzer findings:\n"
for ev in analyzer_evidence[:10]:
prompt += str(ev) + "\n"
prompt += "\nReturn JSON array of findings."
return prompt