feat: Move Create PR from slash command to customizable Support Prompt

- Remove /create-pr built-in slash command from built-in-commands.ts
- Add CREATE_PR Support Prompt type with same functionality
- Update Chat UI button to use supportPrompt.create('CREATE_PR')
- Add CREATE_PR translations to all 17 locales
- Revert unrelated slash command tool changes to original state
- Add comprehensive tests for CREATE_PR prompt

The Create PR button now uses a customizable prompt template editable in Settings > Prompts, while maintaining the same user experience.
This commit is contained in:
daniel-lxs 2025-11-04 11:15:44 -05:00
parent b924e46d9f
commit 81c5d19d98
No known key found for this signature in database
GPG key ID: 21C74479048B3AA6
22 changed files with 147 additions and 60 deletions

View file

@ -284,62 +284,6 @@ Please analyze this codebase and create an AGENTS.md file containing:
Remember: The goal is to create documentation that enables AI assistants to be immediately productive in this codebase, focusing on project-specific knowledge that isn't obvious from the code structure alone.`,
},
create_pr: {
name: "create-pr",
description: "Create a GitHub pull request from current branch",
content: `<task>
Stage and commit any outstanding changes, then review the changes made in this branch versus main/master and create a pull request using the gh CLI.
</task>
<instructions>
1. Check if there are any unstaged/uncommitted changes:
- Run: git status
- If changes exist, stage and commit them with a descriptive message
2. Identify the base branch (main or master):
- Check which exists: git branch --list main master
- Use the one that exists as base branch
3. Get current branch name:
- Run: git branch --show-current
4. Analyze all changes between current branch and base:
- Run: git diff <base-branch>...HEAD
- Also get commit messages: git log <base-branch>..HEAD --oneline
5. Generate PR title and description:
- Analyze the diff and commit messages
- Create concise, descriptive title (50 chars max)
- Write clear PR description explaining:
* What changed and why
* Key implementation details
* Any breaking changes or important notes
6. Get repository info:
- Extract from: git remote get-url origin
- Parse to get org/repo format
7. Check if gh CLI is installed:
- Run: gh --version
- If not found, guide user to install:
* macOS: brew install gh
* Windows: winget install GitHub.cli
* Linux: See https://github.com/cli/cli#installation
* After install: gh auth login
8. Create the pull request:
- Run: gh pr create --repo <org/repo> --head <current-branch> --title "<generated-title>" --body "<generated-description>"
9. After successful PR creation:
- Extract PR URL from gh output
- Present success message with:
* Link to the created PR
* Offer to have it reviewed by Roo Code Cloud's PR Reviewer agent
* Link: https://roocode.com/reviewer
If gh CLI is not installed or authenticated, provide clear setup instructions and wait for user to complete setup before proceeding.
</instructions>`,
},
}
/**

View file

@ -227,6 +227,19 @@ describe("Code Action Prompts", () => {
})
})
describe("CREATE_PR prompt", () => {
it("should return default template when no custom prompts provided", () => {
const template = supportPrompt.get(undefined, "CREATE_PR")
expect(template).toBe(supportPrompt.default.CREATE_PR)
})
it("should create CREATE_PR prompt containing key instructions", () => {
const prompt = supportPrompt.create("CREATE_PR", {}, undefined)
expect(prompt).toContain("Stage and commit")
expect(prompt).toContain("gh pr create")
})
})
describe("create with custom prompts", () => {
it("should use custom template when provided", () => {
const customTemplate = "Custom template for ${filePath}"

View file

@ -44,6 +44,7 @@ type SupportPromptType =
| "TERMINAL_FIX"
| "TERMINAL_EXPLAIN"
| "NEW_TASK"
| "CREATE_PR"
const supportPromptConfigs: Record<SupportPromptType, SupportPromptConfig> = {
ENHANCE: {
@ -174,6 +175,60 @@ Please provide:
NEW_TASK: {
template: `\${userInput}`,
},
CREATE_PR: {
template: `<task>
Stage and commit any outstanding changes, then review the changes made in this branch versus main/master and create a pull request using the gh CLI.
</task>
<instructions>
1. Check if there are any unstaged/uncommitted changes:
- Run: git status
- If changes exist, stage and commit them with a descriptive message
2. Identify the base branch (main or master):
- Check which exists: git branch --list main master
- Use the one that exists as base branch
3. Get current branch name:
- Run: git branch --show-current
4. Analyze all changes between current branch and base:
- Run: git diff <base-branch>...HEAD
- Also get commit messages: git log <base-branch>..HEAD --oneline
5. Generate PR title and description:
- Analyze the diff and commit messages
- Create concise, descriptive title (50 chars max)
- Write clear PR description explaining:
* What changed and why
* Key implementation details
* Any breaking changes or important notes
6. Get repository info:
- Extract from: git remote get-url origin
- Parse to get org/repo format
7. Check if gh CLI is installed:
- Run: gh --version
- If not found, guide user to install:
* macOS: brew install gh
* Windows: winget install GitHub.cli
* Linux: See https://github.com/cli/cli#installation
* After install: gh auth login
8. Create the pull request:
- Run: gh pr create --repo <org/repo> --head <current-branch> --title "<generated-title>" --body "<generated-description>"
9. After successful PR creation:
- Extract PR URL from gh output
- Present success message with:
* Link to the created PR
* Offer to have it reviewed by Roo Code Cloud's PR Reviewer agent
* Link: https://roocode.com/reviewer
If gh CLI is not installed or authenticated, provide clear setup instructions and wait for user to complete setup before proceeding.
</instructions>`,
},
} as const
export const supportPrompt = {

View file

@ -59,6 +59,7 @@ import DismissibleUpsell from "../common/DismissibleUpsell"
import { useCloudUpsell } from "@src/hooks/useCloudUpsell"
import { Cloud } from "lucide-react"
import { safeJsonParse } from "../../../../src/shared/safeJsonParse"
import { supportPrompt } from "@roo/support-prompt"
export interface ChatViewProps {
isHidden: boolean
@ -126,6 +127,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
messageQueue = [],
isGitRepository = false,
isGithubRepository = false,
customSupportPrompts,
} = useExtensionState()
const messagesRef = useRef(messages)
@ -743,8 +745,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
if (primaryButtonText === t("chat:createPR.title")) {
// Mark that PR creation was requested
setPrCreationRequested(true)
// Send /create-pr command
handleSendMessage("/create-pr", [])
// Send message using the Support Prompt for PR creation
const text = supportPrompt.create("CREATE_PR", {}, customSupportPrompts)
handleSendMessage(text, [])
} else {
// Original behavior: start new task
startNewTask()
@ -759,7 +762,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
setClineAsk(undefined)
setEnableButtons(false)
},
[clineAsk, primaryButtonText, t, handleSendMessage, startNewTask],
[clineAsk, primaryButtonText, t, startNewTask, customSupportPrompts, handleSendMessage],
)
const handleSecondaryButtonClick = useCallback(

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Iniciar nova tasca",
"description": "Inicieu una nova tasca amb l'entrada proporcionada. Disponible a la paleta de comandes."
},
"CREATE_PR": {
"label": "Crear Sol·licitud d'Extracció",
"description": "Genera instruccions per preparar, revisar i crear una sol·licitud d'extracció (PR) utilitzant el CLI de GitHub. Pots personalitzar aquesta plantilla."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Neue Aufgabe starten",
"description": "Starte eine neue Aufgabe mit deiner Eingabe. Verfügbar in der Befehlspalette."
},
"CREATE_PR": {
"label": "Pull Request erstellen",
"description": "Erzeuge Anweisungen zum Stagen, Überprüfen und Erstellen eines PR mit dem GitHub CLI. Du kannst diese Vorlage anpassen."
}
}
},

View file

@ -142,6 +142,10 @@
"NEW_TASK": {
"label": "Start New Task",
"description": "Start a new task with user input. Available in the Command Palette."
},
"CREATE_PR": {
"label": "Create Pull Request",
"description": "Generate instructions to stage, review, and create a PR using the GitHub CLI. You can customize this template."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Iniciar nueva tarea",
"description": "Inicia una nueva tarea con entrada del usuario. Disponible en la Paleta de comandos."
},
"CREATE_PR": {
"label": "Crear Pull Request",
"description": "Genera instrucciones para preparar, revisar y crear un PR usando el CLI de GitHub. Puedes personalizar esta plantilla."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Démarrer une nouvelle tâche",
"description": "Démarre une nouvelle tâche avec ton entrée. Disponible dans la palette de commandes."
},
"CREATE_PR": {
"label": "Créer une Pull Request",
"description": "Génère des instructions pour préparer, réviser et créer une PR en utilisant le CLI de GitHub. Vous pouvez personnaliser ce modèle."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "नया कार्य शुरू करें",
"description": "इनपुट के साथ नया कार्य शुरू करें। कमांड पैलेट में उपलब्ध है।"
},
"CREATE_PR": {
"label": "पुल रिक्वेस्ट बनाएं",
"description": "गिटहब सीएलआई का उपयोग करके पीआर को स्टेज, समीक्षा और बनाने के लिए निर्देश उत्पन्न करें। आप इस टेम्पलेट को अनुकूलित कर सकते हैं।"
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Mulai Tugas Baru",
"description": "Mulai tugas baru dengan input pengguna. Tersedia di Command Palette."
},
"CREATE_PR": {
"label": "Buat Pull Request",
"description": "Hasilkan instruksi untuk menyiapkan, meninjau, dan membuat PR menggunakan GitHub CLI. Anda dapat menyesuaikan template ini."
}
}
},

View file

@ -142,7 +142,11 @@
},
"NEW_TASK": {
"label": "Avvia nuova attività",
"description": "Avvia una nuova attività con il tuo input. Disponibile nella palette dei comandi."
"description": "Avvia una newa attività con il tuo input. Disponibile nella palette dei comandi."
},
"CREATE_PR": {
"label": "Crea Pull Request",
"description": "Genera istruzioni per preparare, revisionare e creare una PR utilizzando la CLI di GitHub. Puoi personalizzare questo template."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "新しいタスクを開始",
"description": "入力内容で新しいタスクを開始できます。コマンドパレットから利用できます。"
},
"CREATE_PR": {
"label": "プルリクエストの作成",
"description": "GitHub CLI を使用して、PR のステージング、レビュー、作成の手順を生成します。このテンプレートはカスタマイズできます。"
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "새 작업 시작",
"description": "입력한 내용으로 새 작업을 시작할 수 있습니다. 명령 팔레트에서 이용 가능합니다."
},
"CREATE_PR": {
"label": "풀 리퀘스트 생성",
"description": "GitHub CLI를 사용하여 PR을 스테이징, 검토하고 생성하는 지침을 생성합니다. 이 템플릿을 사용자 정의할 수 있습니다."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Nieuwe taak starten",
"description": "Start een nieuwe taak met gebruikersinvoer. Beschikbaar via de Command Palette."
},
"CREATE_PR": {
"label": "Pull Request aanmaken",
"description": "Genereer instructies om een PR voor te bereiden, te beoordelen en aan te maken met de GitHub CLI. Je kunt dit sjabloon aanpassen."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Rozpocznij nowe zadanie",
"description": "Rozpocznij nowe zadanie z wprowadzonymi danymi. Dostępne w palecie poleceń."
},
"CREATE_PR": {
"label": "Utwórz Pull Request",
"description": "Wygeneruj instrukcje dotyczące przygotowania, przeglądu i utworzenia PR za pomocą GitHub CLI. Możesz dostosować ten szablon."
}
}
},

View file

@ -143,6 +143,10 @@
"NEW_TASK": {
"label": "Iniciar Nova Tarefa",
"description": "Inicie uma nova tarefa com a entrada fornecida. Disponível na paleta de comandos."
},
"CREATE_PR": {
"label": "Criar Pull Request",
"description": "Gere instruções para preparar, revisar e criar um PR usando a CLI do GitHub. Você pode personalizar este modelo."
}
}
},

View file

@ -140,6 +140,10 @@
"NEW_TASK": {
"label": "Начать новую задачу",
"description": "Начать новую задачу с пользовательским вводом. Доступно в палитре команд."
},
"CREATE_PR": {
"label": "Создать Pull Request",
"description": "Создайте инструкции для подготовки, проверки и создания PR с помощью GitHub CLI. Вы можете настроить этот шаблон."
}
}
},

View file

@ -140,6 +140,10 @@
"NEW_TASK": {
"label": "Yeni Görev Başlat",
"description": "Girdiyle yeni bir görev başlat. Komut paletinde kullanılabilir."
},
"CREATE_PR": {
"label": "Pull Request Oluştur",
"description": "GitHub CLI'yi kullanarak bir PR'ı hazırlamak, incelemek ve oluşturmak için talimatlar oluşturun. Bu şablonu özelleştirebilirsiniz."
}
}
},

View file

@ -140,6 +140,10 @@
"NEW_TASK": {
"label": "Bắt đầu tác vụ mới",
"description": "Bắt đầu tác vụ mới với nội dung đã nhập. Có sẵn trong bảng lệnh."
},
"CREATE_PR": {
"label": "Tạo Pull Request",
"description": "Tạo hướng dẫn để chuẩn bị, xem xét và tạo một PR bằng GitHub CLI. Bạn có thể tùy chỉnh mẫu này."
}
}
},

View file

@ -140,6 +140,10 @@
"NEW_TASK": {
"label": "新任务",
"description": "控制开始新任务时的用户提示词。可在首页对话框中使用。"
},
"CREATE_PR": {
"label": "创建拉取请求",
"description": "生成使用 GitHub CLI 来暂存、审查和创建 PR 的说明。你可以自定义此模板。"
}
}
},

View file

@ -142,6 +142,10 @@
"NEW_TASK": {
"label": "開始新工作",
"description": "根據使用者輸入開始一個新的任務。可在命令選擇區使用。"
},
"CREATE_PR": {
"label": "建立拉取請求",
"description": "產生使用 GitHub CLI 來暫存、審查和建立 PR 的說明。您可以自訂此範本。"
}
}
},