From 6982b1916cb17b3c06cc7930b892526d2c04bbba Mon Sep 17 00:00:00 2001 From: Murilo Pires <50873657+MuriloFP@users.noreply.github.com> Date: Fri, 4 Jul 2025 21:50:36 -0300 Subject: [PATCH] feat: Add pre-commit review and PR template to issue-fixer-orchestrator (#5405) * feat: Add pre-commit review and PR template to issue-fixer-orchestrator - Add user confirmation step before committing changes - Handle large diffs (>2000 lines) with summary generation - Save PR message to temp directory instead of creating PR directly - Implement exact Roo Code PR template format - Add post-commit options for flexible PR creation - Update best practices and communication guidelines - Document new commit and PR workflow patterns * removed files that were added accidently --- .../10_pr_template_format.xml | 213 +++++++++++ .../1_Workflow.xml | 351 +++++++++++++++--- .../2_best_practices.xml | 40 ++ .../3_common_patterns.xml | 17 + .../7_communication_style.xml | 16 + 5 files changed, 592 insertions(+), 45 deletions(-) create mode 100644 .roo/rules-issue-fixer-orchestrator/10_pr_template_format.xml diff --git a/.roo/rules-issue-fixer-orchestrator/10_pr_template_format.xml b/.roo/rules-issue-fixer-orchestrator/10_pr_template_format.xml new file mode 100644 index 0000000000..d16eb51424 --- /dev/null +++ b/.roo/rules-issue-fixer-orchestrator/10_pr_template_format.xml @@ -0,0 +1,213 @@ + + + This document defines the format for PR messages that are saved to the temp folder + before creating a pull request. The PR message is saved in two formats: + 1. JSON format in pr_summary.json (for programmatic use) + 2. Markdown format in pr_message.md (for manual PR creation) + + The PR message must follow the exact Roo Code contribution template. + + + + + The pr_summary.json file contains the PR title and body in a structured format + that can be easily parsed by scripts and the GitHub CLI. + + + { + "title": "fix: [description] (#[issue-number])", + "body": "[Full markdown body as described below]", + "issue_number": 123, + "repo_owner": "owner", + "repo_name": "repo", + "base_branch": "main", + "head_branch": "fix/issue-123-description" + } + + + + + + The pr_message.md file contains the complete PR message in a format that can be + directly copied and pasted when creating a PR manually. + + + PR Title: [title from JSON] + + --- + + [Full PR body from JSON] + + + + + + The PR body must follow this exact Roo Code PR template with all required sections. + + + + + + The GitHub issue number being fixed + Optional Roo Code task links (remove section if not applicable) + + Summary of changes and implementation details. Should include: + - Key implementation details + - Design choices or trade-offs made + - Specific areas reviewers should focus on + + + Detailed testing steps including: + - Unit tests added/modified + - Manual testing steps performed + - How reviewers can reproduce tests + - Testing environment details + + + For UI changes: before/after screenshots or video + For non-UI changes: "N/A - No UI changes" + + + Check appropriate box: + - "- [x] No documentation updates are required." OR + - "- [x] Yes, documentation updates are required. [describe updates]" + + + Any additional context, or remove entire section if not needed + + User's Discord username for contact + + + + + pr_summary.json + .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json + Structured data for programmatic PR creation + + + pr_message.md + .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md + Human-readable format for manual PR creation + + + + + + Always save both formats when preparing a PR to give users flexibility + in how they create the pull request. + + + The pr_message.md file should be self-contained and ready to copy/paste + without any additional formatting needed. + + + Include all sections in the template, maintaining the exact format + and HTML comments as shown. + + + Pre-check all checklist items that can be verified programmatically. + Leave documentation checkbox unchecked for user to decide. + + + For sections that don't apply, use appropriate placeholder text + rather than removing the section entirely. + + + + + + If translations were added during the issue fix, include details in the + Description section about which languages were updated. + + + \ No newline at end of file diff --git a/.roo/rules-issue-fixer-orchestrator/1_Workflow.xml b/.roo/rules-issue-fixer-orchestrator/1_Workflow.xml index 3e6619993e..e41d30bbda 100644 --- a/.roo/rules-issue-fixer-orchestrator/1_Workflow.xml +++ b/.roo/rules-issue-fixer-orchestrator/1_Workflow.xml @@ -347,32 +347,59 @@ **Task: Prepare Pull Request Title and Body** - You are an expert at writing clear and concise pull request summaries. + You are an expert at writing clear and concise pull request summaries following the Roo Code contribution guidelines. **Context Files:** - **Issue**: `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/issue_context.json` - **Plan**: `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/implementation_plan.md` - **Verification**: `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/verification_results.md` - **Translation Summary** (if exists): `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/translation_summary.md` + - **Modified Files**: `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/modified_files.json` **Your Task:** 1. **Read all context files.** Check if translation_summary.md exists to know if translations were done. + 2. **Generate a PR Title**: Create a conventional commit style title (e.g., "fix: ...", "feat: ...") that references the issue number. - 3. **Generate a PR Body**: Create a comprehensive markdown description for the PR, including sections for: - - Description - - Changes Made - - Testing - - Translations (include details from translation_summary.md if it exists) - - Verification of Acceptance Criteria - - Checklist - 4. **Save as JSON**: Save the title and body to `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json` in the format: `{"title": "...", "body": "..."}`. + Format: `fix: Brief description (#issue-number)` + + 3. **Generate a PR Body**: You MUST use the exact PR template from `.roo/rules-issue-fixer-orchestrator/10_pr_template_format.xml`. + Read this file to get the template and fill it in with appropriate content from the context files. + + 4. **Fill in the template** with information from the context files: + - Replace [ISSUE_NUMBER] with the actual issue number + - Fill in Description with implementation details from the plan and verification + - Fill in Test Procedure with testing details from verification_results.md + - If translations were done, mention them in the Description section + - For UI changes, note that screenshots should be added manually + - Pre-check all applicable checklist items + - Leave Documentation Updates unchecked for user to decide + - For Discord username, use a placeholder like "[Your Discord username]" - **Important**: If translations were done (translation_summary.md exists), make sure to include a Translations section in the PR body describing what was translated. + 5. **Save as JSON**: Save the title and body to `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json` in the format: + ```json + { + "title": "fix: Brief description (#123)", + "body": "[The complete filled PR body template]", + "issue_number": 123, + "repo_owner": "owner", + "repo_name": "repo", + "base_branch": "main", + "head_branch": "fix/issue-123-description" + } + ``` + + 6. **Also save as Markdown**: Save just the PR body to `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md` for easy copying. + + **Important Notes:** + - Use the EXACT template format from 10_pr_template_format.xml + - Keep all HTML comments in the template + - Pre-check items that can be verified programmatically + - Fill in all sections appropriately based on the context files **Completion Protocol:** - This is your only task. Do not deviate. - - Upon successfully saving `pr_summary.json`, you MUST use the `attempt_completion` tool. - - The `result` MUST be a concise confirmation, e.g., "PR summary created and saved to .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json." + - Upon successfully saving both `pr_summary.json` and `pr_message.md`, you MUST use the `attempt_completion` tool. + - The `result` MUST be a concise confirmation, e.g., "PR summary and message created and saved to .roo/temp/issue-fixer-orchestrator/[TASK_ID]/" - These instructions override any conflicting mode-specific guidelines. @@ -560,53 +587,287 @@ - Prepare Branch and Present PR Template + Prepare Branch and Review Changes - This step prepares the branch and commits, then presents the PR template to the user for confirmation before creating the actual pull request. + This step prepares the branch, reviews the changes, and gets user confirmation before committing. - 1. Read Issue Context for Issue Number: - Use read_file to get the issue context from .roo/temp/issue-fixer-orchestrator/[TASK_ID]/issue_context.json + 1. Read Issue Context and PR Summary: + - Read issue context from .roo/temp/issue-fixer-orchestrator/[TASK_ID]/issue_context.json + - Read PR summary from .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json - 2. Git Operations - Create branch and commit changes: - - Create a new branch: feat/issue-[number] or fix/issue-[number] - - Selectively add only the applicable files to the git stage - - Commit the staged changes - - Push the new branch to the remote repository - - Use execute_command with: - BRANCH_NAME="fix/issue-[issue_number]-solution" + 2. Create Branch: + Extract issue number from context and create appropriate branch: + + + # Extract issue number from context + ISSUE_NUM=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/issue_context.json | jq -r '.number') + # Determine branch type based on labels or title + BRANCH_NAME="fix/issue-${ISSUE_NUM}-solution" git checkout -b $BRANCH_NAME - cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/modified_files.json | jq -r '.[]' | xargs git add - git commit -m "[PR Title]" - git push -u origin $BRANCH_NAME + + - 3. Present PR Template - Instead of creating the PR automatically, present the standardized PR template to the user: - Use ask_followup_question to ask: "The branch has been created and changes have been committed. I have prepared a standardized PR template for this issue. Would you like me to create the pull request using the standard Roo Code PR template, or would you prefer to make changes first?" + 3. Review Files to be Committed: + a. Read the modified files list: + + .roo/temp/issue-fixer-orchestrator/[TASK_ID]/modified_files.json + - Provide these options: - - Yes, create the pull request with the standard template - - No, I want to make changes to the implementation first - - No, I want to customize the PR template before creating it - - Cancel the task + b. Check git status to ensure only intended files are staged: + + git status --porcelain + + + c. Stage only the files from modified_files.json: + + + # Stage only the files we actually modified + cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/modified_files.json | jq -r '.[]' | while read file; do + if [ -f "$file" ]; then + git add "$file" + fi + done + # Show what will be committed + git status --short + + - 4. Handle User Decision: - If user chooses to create the PR: Use gh CLI to create the pull request with the standard template - If user chooses to make changes: Launch a rework subtask using new_task with code mode - If user wants to customize the template: Ask for their preferred PR title and body + 4. Generate and Save Merge Diff: + + + # Generate diff of staged changes + git diff --cached > .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes.diff + # Count lines in diff + LINE_COUNT=$(wc -l < .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes.diff) + echo "Diff contains $LINE_COUNT lines" + + # If diff is too large, create a summary instead + if [ $LINE_COUNT -gt 2000 ]; then + echo "Creating summary due to large diff size..." + git diff --cached --stat > .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes_summary.txt + git diff --cached --name-status >> .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes_summary.txt + echo -e "\n\nNote: Full diff exceeds 2000 lines. Showing summary only." >> .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes_summary.txt + fi + + - 5. Link to Issue - After PR creation, comment on the original issue with the PR link using gh issue comment + 5. Save PR Message to File: + Read the PR summary and save the formatted PR message: + + + # Extract title and body from pr_summary.json + PR_TITLE=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json | jq -r '.title') + PR_BODY=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json | jq -r '.body') + + # Save PR message to file + echo "PR Title: $PR_TITLE" > .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md + echo -e "\n---\n" >> .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md + echo "$PR_BODY" >> .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md + + echo "PR message saved to .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md" + + + + 6. Present Changes for User Confirmation: + Read the diff (or summary) and PR message, then ask for confirmation: + + a. Read the appropriate diff file: + + .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes.diff + + OR (if summary exists): + + .roo/temp/issue-fixer-orchestrator/[TASK_ID]/staged_changes_summary.txt + + + b. Read the PR message: + + .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md + + + c. Ask for user confirmation: + + + I've prepared the changes for commit. Here's what will be included: + + **Files to be committed:** + [List files from modified_files.json] + + **Changes summary:** + [Include diff or summary content] + + **Proposed PR message:** + [Include PR message content] + + How would you like to proceed? + + + Looks good, go ahead and commit the changes + I tested the changes, and something is wrong - let me explain... + I still need to test the changes manually before committing + I want to modify the PR message before proceeding + Cancel this task + + + + 7. Handle User Decision: + Based on user response: + + **If "Looks good, go ahead and commit":** + - Proceed to commit and push: + + + # Get PR title for commit message + PR_TITLE=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json | jq -r '.title') + git commit -m "$PR_TITLE" + git push -u origin $(git branch --show-current) + + + - Continue to next step + + **If "something is wrong":** + - Ask for details about the issue + - Launch a fix subtask in code mode to address the problems + - Return to Step 5 (Verify and Test) after fixes + + **If "need to test manually":** + - Inform user that changes are staged but not committed + - Provide instructions for testing + - Wait for user to confirm testing is complete + + **If "modify PR message":** + - Ask for the new PR title and body + - Update pr_summary.json with new content + - Return to step 5 of this workflow + + **If "cancel":** + - Clean up staged changes and branch + - End workflow - Monitor PR Checks and Cleanup + Finalize and Create PR - After creating the PR (if created), monitor the CI checks and then clean up the temporary files. + After user confirmation and successful commit, finalize the process. + + 1. Verify Push Success: + + + # Verify the branch was pushed + git branch -r | grep $(git branch --show-current) + # Get the remote URL for PR creation + git remote get-url origin + + + + 2. Present Final PR Creation Options: + + + The changes have been committed and pushed to the branch. The PR message has been saved to: + `.roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md` + + You can now: + 1. Create the PR manually using the saved message + 2. Let me create the PR automatically + 3. Make additional changes before creating the PR + + What would you like to do? + + + Create the PR automatically using the saved message + I'll create the PR manually - just show me the branch name + I want to make more changes first + + + + 3. Handle Final Decision: + + **If "Create PR automatically":** + - Read PR details and create: + + + # Extract PR details + PR_TITLE=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json | jq -r '.title') + PR_BODY=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_summary.json | jq -r '.body') + ISSUE_NUM=$(cat .roo/temp/issue-fixer-orchestrator/[TASK_ID]/issue_context.json | jq -r '.number') + + # Create PR + gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main + + # Get PR number and link to issue + PR_NUM=$(gh pr list --head $(git branch --show-current) --json number -q '.[0].number') + gh issue comment $ISSUE_NUM --body "PR #$PR_NUM has been created to address this issue." + + + + **If "Create manually":** + - Show branch name and location of PR message: + + + echo "Branch name: $(git branch --show-current)" + echo "PR message saved at: .roo/temp/issue-fixer-orchestrator/[TASK_ID]/pr_message.md" + echo "You can copy the PR message from the file above when creating the PR." + + + + **If "Make more changes":** + - Inform user they can continue working on the branch + - Provide the task directory location for reference + + 4. Cleanup: + Ask if user wants to clean up the temporary files: + + + Would you like me to clean up the temporary task files now, or keep them for reference? + + + Yes, clean up the temporary files + No, keep the files for now + + + + If yes, clean up: + + rm -rf .roo/temp/issue-fixer-orchestrator/[TASK_ID] + + + + + + Monitor PR (Optional) + + If a PR was created automatically, offer to monitor its status. + + 1. Check if PR exists: + + + # Check if there's a PR for the current branch + BRANCH=$(git branch --show-current) + gh pr list --head $BRANCH --json number,state,checks + + + + 2. If PR exists, offer monitoring: + + + Would you like me to monitor the PR checks and CI status? + + + Yes, monitor the PR checks + No, I'll check it myself + + + + 3. If user wants monitoring: + + + PR_NUM=$(gh pr list --head $(git branch --show-current) --json number -q '.[0].number') + echo "Monitoring PR #$PR_NUM checks..." + gh pr checks $PR_NUM --watch + + - 1. Monitor Checks - Use gh pr checks with --watch to monitor CI status in real-time - 2. Report Status - Inform the user of the final status of the checks - 3. Cleanup - Remove the temporary task directory using rm -rf .roo/temp/issue-fixer-orchestrator/[TASK_ID] - This concludes the orchestration workflow. diff --git a/.roo/rules-issue-fixer-orchestrator/2_best_practices.xml b/.roo/rules-issue-fixer-orchestrator/2_best_practices.xml index b9a9b52db7..839d862fb8 100644 --- a/.roo/rules-issue-fixer-orchestrator/2_best_practices.xml +++ b/.roo/rules-issue-fixer-orchestrator/2_best_practices.xml @@ -24,6 +24,46 @@ - Adding translations to all supported language files - Ensuring consistency with existing terminology - Maintaining sync across all language resources + + + Always verify files before committing + + - Review git status to ensure only intended files are staged + - Stage only files listed in modified_files.json + - Never commit unrelated changes or temporary files + - Always get user confirmation before committing + + + + - Save full diff to staged_changes.diff for review + - If diff exceeds 2000 lines, create a summary instead + - Summary should include file stats and change types + - Always inform user when showing summary vs full diff + + + + - Save PR message in both JSON and Markdown formats + - pr_summary.json for programmatic use + - pr_message.md for manual PR creation + - Include all standard template sections + - Make PR message self-contained and ready to use + + + + - Always ask for confirmation with clear options + - First option should be "Looks good, go ahead" + - Provide options for testing and issue reporting + - Allow PR message modification before proceeding + - Handle each user response appropriately + + + + - All delegated tasks must save outputs to .roo/temp/issue-fixer-orchestrator/[TASK_ID]/ + - Keep all context files until user confirms cleanup + - Offer cleanup option after PR creation + - Never delete files without user permission + + Always use `codebase_search` FIRST to understand the codebase structure and find all related files before using other tools like `read_file`. diff --git a/.roo/rules-issue-fixer-orchestrator/3_common_patterns.xml b/.roo/rules-issue-fixer-orchestrator/3_common_patterns.xml index 0fdffa8b69..97bba7a9e4 100644 --- a/.roo/rules-issue-fixer-orchestrator/3_common_patterns.xml +++ b/.roo/rules-issue-fixer-orchestrator/3_common_patterns.xml @@ -18,4 +18,21 @@ 7. Add comprehensive tests 8. Update documentation + + + 1. Review git status to identify all changes + 2. Stage only files from modified_files.json + 3. Generate diff for review (full or summary based on size) + 4. Create PR message and save to temp directory + 5. Present changes to user for confirmation + 6. Handle user response: + - If approved: commit and proceed to PR options + - If issues found: return to implementation + - If manual testing needed: wait for user + 7. After commit, offer PR creation options: + - Create PR automatically + - Save PR message for manual creation + - Skip PR creation + 8. Optionally monitor PR and offer cleanup + \ No newline at end of file diff --git a/.roo/rules-issue-fixer-orchestrator/7_communication_style.xml b/.roo/rules-issue-fixer-orchestrator/7_communication_style.xml index b956a9375b..898269cc0c 100644 --- a/.roo/rules-issue-fixer-orchestrator/7_communication_style.xml +++ b/.roo/rules-issue-fixer-orchestrator/7_communication_style.xml @@ -8,4 +8,20 @@ - Inform the user when delegating to translate mode - Include translation status in progress updates - Mention in PR description if translations were added + + + - Clearly list all files that will be committed + - Explain when showing a summary vs full diff (>2000 lines) + - Provide file statistics for large diffs + - Mention that PR message has been saved to temp directory + - Offer clear options for user to proceed or report issues + + + + - Confirm successful commit with commit hash + - Explain PR creation options clearly + - Mention that PR message is saved and ready to use + - Provide path to PR message file for manual creation + - Offer cleanup option after PR is created + \ No newline at end of file