From 80fe47b5320cdcd5932d52b03508b22cbfc0ac3c Mon Sep 17 00:00:00 2001 From: Roo Code Date: Fri, 17 Oct 2025 18:22:55 +0000 Subject: [PATCH] feat: add PR Creator mode and PR workflow improvements - Add PR Creator built-in mode for generating professional PR descriptions - Add offer_pr message after task completion (except in PR Creator mode) - Add pr_reviewer_upsell message after PR Creator completes - Add translations for new UI elements - Update message types to support new features --- packages/types/src/message.ts | 2 ++ packages/types/src/mode.ts | 12 +++++++ src/core/tools/attemptCompletionTool.ts | 8 +++++ webview-ui/src/components/chat/ChatRow.tsx | 41 +++++++++++++++++++++- webview-ui/src/i18n/locales/en/chat.json | 11 +++++- 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/packages/types/src/message.ts b/packages/types/src/message.ts index 77c055c6e1..8321d5d27d 100644 --- a/packages/types/src/message.ts +++ b/packages/types/src/message.ts @@ -166,6 +166,8 @@ export const clineSays = [ "condense_context_error", "codebase_search_result", "user_edit_todos", + "offer_pr", + "pr_reviewer_upsell", ] as const export const clineSaySchema = z.enum(clineSays) diff --git a/packages/types/src/mode.ts b/packages/types/src/mode.ts index 88dcbb9574..d665e1ab18 100644 --- a/packages/types/src/mode.ts +++ b/packages/types/src/mode.ts @@ -192,4 +192,16 @@ export const DEFAULT_MODES: readonly ModeConfig[] = [ customInstructions: "Your role is to coordinate complex workflows by delegating tasks to specialized modes. As an orchestrator, you should:\n\n1. When given a complex task, break it down into logical subtasks that can be delegated to appropriate specialized modes.\n\n2. For each subtask, use the `new_task` tool to delegate. Choose the most appropriate mode for the subtask's specific goal and provide comprehensive instructions in the `message` parameter. These instructions must include:\n * All necessary context from the parent task or previous subtasks required to complete the work.\n * A clearly defined scope, specifying exactly what the subtask should accomplish.\n * An explicit statement that the subtask should *only* perform the work outlined in these instructions and not deviate.\n * An instruction for the subtask to signal completion by using the `attempt_completion` tool, providing a concise yet thorough summary of the outcome in the `result` parameter, keeping in mind that this summary will be the source of truth used to keep track of what was completed on this project.\n * A statement that these specific instructions supersede any conflicting general instructions the subtask's mode might have.\n\n3. Track and manage the progress of all subtasks. When a subtask is completed, analyze its results and determine the next steps.\n\n4. Help the user understand how the different subtasks fit together in the overall workflow. Provide clear reasoning about why you're delegating specific tasks to specific modes.\n\n5. When all subtasks are completed, synthesize the results and provide a comprehensive overview of what was accomplished.\n\n6. Ask clarifying questions when necessary to better understand how to break down complex tasks effectively.\n\n7. Suggest improvements to the workflow based on the results of completed subtasks.\n\nUse subtasks to maintain clarity. If a request significantly shifts focus or requires a different expertise (mode), consider creating a subtask rather than overloading the current one.", }, + { + slug: "pr-creator", + name: "📝 PR Creator", + roleDefinition: + "You are Roo, a pull request documentation specialist focused on creating comprehensive, well-structured PR descriptions that follow conventional commit standards and best practices.", + whenToUse: + "Use this mode when you need to create a pull request. Analyzes git changes, commit history, and test coverage to generate professional PR descriptions with proper commit prefixes.", + description: "Create professional pull request descriptions", + groups: ["read", "command"], + customInstructions: + "Your workflow:\n\n1. Analyze the current branch and changes:\n - Run 'git branch --show-current' to get current branch\n - Run 'git diff origin/main...HEAD' to see all changes\n - Run 'git log origin/main..HEAD --oneline' to see commits\n\n2. Determine the commit type prefix by analyzing changes:\n - feat: New features or capabilities\n - fix: Bug fixes\n - ux: User experience improvements\n - docs: Documentation changes\n - chore: Maintenance tasks\n - refactor: Code restructuring\n - test: Test additions or updates\n - perf: Performance improvements\n - style: Code style/formatting changes\n\n3. Create a comprehensive PR description with:\n - Clear title with conventional commit prefix\n - Summary of changes (what & why)\n - Key modifications organized by category\n - Test coverage summary (new tests, modified tests, coverage %)\n - Breaking changes section (if applicable)\n - Related issues/tickets\n\n4. Execute PR creation:\n - Use: gh pr create --repo OWNER/REPO --head --base main --title \": \" --body \"\"\n - Always target 'main' as base branch\n - Ensure title follows conventional commits format\n\n5. After successful PR creation:\n - Report the PR URL\n - Summarize what was included\n - Use attempt_completion to finish\n\nStay focused on PR creation - do not switch modes or perform other tasks.", + }, ] as const diff --git a/src/core/tools/attemptCompletionTool.ts b/src/core/tools/attemptCompletionTool.ts index 5074d7f4e8..3709bb1a87 100644 --- a/src/core/tools/attemptCompletionTool.ts +++ b/src/core/tools/attemptCompletionTool.ts @@ -107,6 +107,14 @@ export async function attemptCompletionTool( return } + // Send offer_pr message if not in PR Creator mode + if (cline.mode !== "pr-creator") { + await cline.say("offer_pr", "", undefined, false) + } else { + // In PR Creator mode, send PR Reviewer upsell after completion + await cline.say("pr_reviewer_upsell", "", undefined, false) + } + // We already sent completion_result says, an // empty string asks relinquishes control over // button and field. diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index b0b87e7a2d..b7521f8368 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -59,6 +59,7 @@ import { FolderTree, TerminalSquare, MessageCircle, + GitPullRequest, } from "lucide-react" import { cn } from "@/lib/utils" @@ -130,8 +131,13 @@ export const ChatRowContent = ({ }: ChatRowContentProps) => { const { t } = useTranslation() - const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration } = useExtensionState() + const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration, cloudApiUrl } = useExtensionState() const { info: model } = useSelectedModel(apiConfiguration) + + // Function to switch modes + const switchToMode = useCallback((modeSlug: string) => { + vscode.postMessage({ type: "mode", text: modeSlug }) + }, []) const [isEditing, setIsEditing] = useState(false) const [editedContent, setEditedContent] = useState("") const [editMode, setEditMode] = useState(mode || "code") @@ -1254,6 +1260,39 @@ export const ChatRowContent = ({ return case "user_edit_todos": return {}} /> + case "offer_pr": + return ( + <> +
+ + {t("chat:offerPr.title")} +
+
+ {t("chat:offerPr.description")} + +
+ + ) + case "pr_reviewer_upsell": + return ( +
+ {t("chat:prReviewerUpsell.message")}{" "} + +
+ ) case "tool" as any: // Handle say tool messages const sayTool = safeJsonParse(message.text) diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index 1db0b04d17..2be637636e 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -402,8 +402,17 @@ "cloudAgents": { "create": "Create", "title": "Cloud Agents", - "description": "You haven’t created any Cloud Agents yet.", + "description": "You haven't created any Cloud Agents yet.", "createFirst": "Create your first", "clickToRun": "Click to run {{name}}" + }, + "offerPr": { + "title": "Create Pull Request", + "description": "Would you like to create a pull request for these changes?", + "switchToPrCreator": "Switch to PR Creator" + }, + "prReviewerUpsell": { + "message": "Get Roo to review this in the Cloud", + "createLink": "Create a PR Reviewer Agent" } }