PRIX / lib /src /prompts.js
Rachit-Tw's picture
Fix parseReview validLine logic to correctly parse AI findings
bcbc081
Raw
History Blame Contribute Delete
8.09 kB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Prompts = void 0;
class Prompts {
summarize;
summarizeReleaseNotes;
summarizeFileDiff = `## PR: $title
## Desc: $description
## Diff:
\`\`\`diff
$file_diff
\`\`\`
Instructions: Summarize changes in <100 words. Focus on logic/API changes. Check for:
- Syntax errors, compilation errors, or incomplete code
- Logic/API changes
Then add exactly: [TRIAGE]: NEEDS_REVIEW | APPROVED
- NEEDS_REVIEW: Logic/var changes, syntax errors, or incomplete code.
- APPROVED: Typos/docs/format only.
`;
triageFileDiff = ``;
summarizeChangesets = `Group and deduplicate the following changesets in this PR.
Respond with updated changesets using the same format.
Important: Provide ONLY the final summarized result. Do NOT include reasoning steps, "Step 1", "Step 2", or any other conversational filler.
$raw_summary
`;
summarizePrefix = `## 📋 Summary of Changes
$raw_summary
`;
summarizeShort = `Provide a concise, professional summary of changes and architectural impact.
Format your response with:
- **Overview**: 2-3 sentences on what this PR does
- **Key Changes**: Bullet points of the most important modifications
- **Architectural Impact**: How this affects the system design (if any)
Requirements:
- Use proper markdown formatting (headers, bullet points, bold text)
- Focus strictly on PR facts
- Max 300 words
- No conversational filler, no "Step 1/2/3", no reasoning steps
- No code blocks unless showing actual code examples
`;
reviewFileDiff = `## PR: $title
## Description:
$description
## Summary:
$short_summary
## Codebase Context (Symbol Graph)
\`\`\`
$remedy_context
\`\`\`
## Instructions
Review new hunks for substantive issues. Format comments starting with line range (e.g., "22-25:").
**CRITICAL - First Check**: Syntax errors, compilation errors, or incomplete/invalid code that would break the build or runtime.
- If you see incomplete code, syntax errors, or code that won't compile: Mark as [CRITICAL] | [BUG]
**Detailed Audit**: Inspect for:
- **Mutation/Side-effects**: Does it change arguments? (e.g., modifying object/array arguments instead of returning a copy).
- **Type Safety**: Implicit conversions or missing edge-case checks.
- **Logic**: Off-by-one errors, race conditions, or unnecessary complexity.
- **Syntax/Compilation**: Will this code compile and run?
**Output Format**:
- You MUST start each finding EXACTLY with: [LINE_START-LINE_END] | [LEVEL] | [TYPE]
- Example: [22-25] | [CRITICAL] | [Security]
- **Consequence**: Explain why this matters and the worst-case production failure
- **Fix**: Provide a code block fix
- **Suggestion**: Use GitHub suggestion format: \`\`\`suggestion [FIXED_CODE] \`\`\`
- Use ACTUAL function/variable names from the codebase context
- Do NOT use generic names like temp_var, fix_this, etc.
- Match existing code style
- **Confidence**: Score 0-100% at the end. Only show findings with confidence >= 80% for critical/major issues.
If no issues found after rigorous audit: Respond ONLY with LGTM!. Do NOT include any conversational text.
## Changes in $filename:
$patches
`;
reviewFileBatch = `## PR: $title
## Description:
$description
## Summary:
$short_summary
## Instructions
Critical: You are reviewing a BATCH of multiple files.
**For EACH file:**
1. Start with header: ### File: [filename]
2. **FIRST CHECK**: Syntax errors, compilation errors, or incomplete code (mark as [CRITICAL] | [BUG])
3. Then audit for:
- Mutation/Side-effects: Does it change arguments?
- Type Safety: Implicit conversions or missing edge-case checks
- Logic: Off-by-one errors, race conditions
- Syntax/Compilation: Will this code compile and run?
**Output Format**:
- You MUST start each finding EXACTLY with: [LINE_START-LINE_END] | [LEVEL] | [TYPE]
- Example: [22-25] | [CRITICAL] | [Security]
- Explain consequence and worst-case production failure
- Provide fix with \`\`\`suggestion [FIXED_CODE] \`\`\` format
- Use ACTUAL function/variable names from codebase
- Confidence score 0-100% (>= 80% for critical/major)
For files with no issues: Respond ONLY with ### File: [filename]\nLGTM!. Do NOT include any conversational text.
## Files to Review in this Batch:
$batch_content
`;
comment = `Reply to this instruction in the context of the PR.
## PR: $title
## Description:
$description
## Summary:
$short_summary
## Instructions
Reply directly to the comment below. Begin with "@user".
## New Comment
\`\`\`
$comment
\`\`\`
## Context (Diff)
\`\`\`diff
$diff
\`\`\`
`;
fixSuggestion = `The code suggestion for $filename failed CI:
$suggestion
CI Error: $error
Correct the suggestion block. Respond ONLY with the fixed block.
`;
contextAwareFixSuggestion = `## Codebase Context for Fix
$remedy_context
## Review Comment Requiring Fix
$suggestion
## CI Error
$error
## Instructions
You are fixing a code review finding. Using the codebase context above:
1. The fix MUST use existing function/variable names from the context (do NOT invent names like temp_var or fix_this)
2. Match the coding style and patterns already present in the codebase
3. If referencing existing code patterns, cite them: Based on pattern in $filename:$line
4. Ensure the fix is semantically correct for this specific codebase
Respond ONLY with the corrected suggestion block using GitHub markdown:
\`\`\`suggestion
[FIXED_CODE]
\`\`\`
`;
issueAnalysis = `## Repository Context (Codebase Structure)
$codebase_structure
## Issue
Title: $title
Description: $description
Task: $task_description
## Instructions
You are PRIX, an expert software engineering assistant. Based on the issue and codebase structure above, provide a concise response with exactly these 4 sections:
1. **Problem Summary**: 2-3 sentences describing the issue
2. **Root Cause**: Key root cause (1-2 sentences max)
3. **Fix Plan**: Numbered list of steps (max 5 steps)
4. **IDE Prompt**: Complete prompt for an AI IDE/agent to fix this issue
Be specific and reference relevant directories/files from the codebase structure where applicable.
`;
constructor(summarize = '', summarizeReleaseNotes = '') {
this.summarize = summarize;
this.summarizeReleaseNotes = summarizeReleaseNotes;
}
renderSummarizeFileDiff(inputs, reviewSimpleChanges) {
let prompt = this.summarizeFileDiff;
if (reviewSimpleChanges === false) {
prompt += this.triageFileDiff;
}
return inputs.render(prompt);
}
renderSummarizeChangesets(inputs) {
return inputs.render(this.summarizeChangesets);
}
renderSummarize(inputs) {
const prompt = this.summarizePrefix + this.summarize;
return inputs.render(prompt);
}
renderSummarizeShort(inputs) {
const prompt = this.summarizePrefix + this.summarizeShort;
return inputs.render(prompt);
}
renderSummarizeReleaseNotes(inputs) {
const prompt = this.summarizePrefix + this.summarizeReleaseNotes;
return inputs.render(prompt);
}
renderComment(inputs) {
return inputs.render(this.comment);
}
renderReviewFileDiff(inputs) {
return inputs.render(this.reviewFileDiff);
}
renderReviewFileBatch(inputs) {
return inputs.render(this.reviewFileBatch);
}
renderFixSuggestion(inputs, suggestion, error) {
const ins = inputs.clone();
ins.suggestion = suggestion;
ins.error = error;
return ins.render(this.fixSuggestion);
}
renderContextAwareFixSuggestion(inputs, suggestion, error) {
const ins = inputs.clone();
ins.suggestion = suggestion;
ins.error = error;
return ins.render(this.contextAwareFixSuggestion);
}
renderIssueAnalysis(inputs) {
return inputs.render(this.issueAnalysis);
}
}
exports.Prompts = Prompts;
//# sourceMappingURL=prompts.js.map