diff --git a/package.json b/package.json index e5cf882..7eab96e 100644 --- a/package.json +++ b/package.json @@ -104,17 +104,17 @@ }, { "command": "roo-cline.explainCode", - "title": "Explain Code", + "title": "Roo Code: Explain Code", "category": "Roo Code" }, { "command": "roo-cline.fixCode", - "title": "Fix Code", + "title": "Roo Code: Fix Code", "category": "Roo Code" }, { "command": "roo-cline.improveCode", - "title": "Improve Code", + "title": "Roo Code: Improve Code", "category": "Roo Code" } ], diff --git a/src/extension.ts b/src/extension.ts index b03e9e5..472968a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -171,17 +171,21 @@ export function activate(context: vscode.ExtensionContext) { context: vscode.ExtensionContext, command: string, promptType: keyof typeof ACTION_NAMES, - inputPrompt: string, - inputPlaceholder: string, + inputPrompt?: string, + inputPlaceholder?: string, ) => { + let userInput: string | undefined + context.subscriptions.push( vscode.commands.registerCommand( command, async (filePath: string, selectedText: string, diagnostics?: any[]) => { - const userInput = await vscode.window.showInputBox({ - prompt: inputPrompt, - placeHolder: inputPlaceholder, - }) + if (inputPrompt) { + userInput = await vscode.window.showInputBox({ + prompt: inputPrompt, + placeHolder: inputPlaceholder, + }) + } const params = { filePath, @@ -197,29 +201,11 @@ export function activate(context: vscode.ExtensionContext) { } // Register code action commands - registerCodeAction( - context, - "roo-cline.explainCode", - "EXPLAIN", - "What would you like Roo to explain?", - "E.g. How does the error handling work?", - ) + registerCodeAction(context, "roo-cline.explainCode", "EXPLAIN") - registerCodeAction( - context, - "roo-cline.fixCode", - "FIX", - "What would you like Roo to fix?", - "E.g. Maintain backward compatibility", - ) + registerCodeAction(context, "roo-cline.fixCode", "FIX") - registerCodeAction( - context, - "roo-cline.improveCode", - "IMPROVE", - "What would you like Roo to improve?", - "E.g. Focus on performance optimization", - ) + registerCodeAction(context, "roo-cline.improveCode", "IMPROVE") return createClineAPI(outputChannel, sidebarProvider) } diff --git a/src/shared/support-prompt.ts b/src/shared/support-prompt.ts index 9f18b1a..881c060 100644 --- a/src/shared/support-prompt.ts +++ b/src/shared/support-prompt.ts @@ -24,7 +24,26 @@ export const createPrompt = (template: string, params: PromptParams): string => return result } -const EXPLAIN_TEMPLATE = `Explain the following code from file path @/\${filePath}: +interface SupportPromptConfig { + label: string + description: string + template: string +} + +const supportPromptConfigs: Record = { + ENHANCE: { + label: "Enhance Prompt", + description: + "Use prompt enhancement to get tailored suggestions or improvements for your inputs. This ensures Roo understands your intent and provides the best possible responses. Available via the ✨ icon in chat.", + template: `Generate an enhanced version of this prompt (reply with only the enhanced prompt - no conversation, explanations, lead-in, bullet points, placeholders, or surrounding quotes): + +\${userInput}`, + }, + EXPLAIN: { + label: "Explain Code", + description: + "Get detailed explanations of code snippets, functions, or entire files. Useful for understanding complex code or learning new patterns. Available in the editor context menu (right-click on selected code).", + template: `Explain the following code from file path @/\${filePath}: \${userInput} \`\`\` @@ -34,10 +53,13 @@ const EXPLAIN_TEMPLATE = `Explain the following code from file path @/\${filePat Please provide a clear and concise explanation of what this code does, including: 1. The purpose and functionality 2. Key components and their interactions -3. Important patterns or techniques used -` - -const FIX_TEMPLATE = `Fix any issues in the following code from file path @/\${filePath} +3. Important patterns or techniques used`, + }, + FIX: { + label: "Fix Issues", + description: + "Get help identifying and resolving bugs, errors, or code quality issues. Provides step-by-step guidance for fixing problems. Available in the editor context menu (right-click on selected code).", + template: `Fix any issues in the following code from file path @/\${filePath} \${diagnosticText} \${userInput} @@ -49,10 +71,13 @@ Please: 1. Address all detected problems listed above (if any) 2. Identify any other potential bugs or issues 3. Provide corrected code -4. Explain what was fixed and why -` - -const IMPROVE_TEMPLATE = `Improve the following code from file path @/\${filePath}: +4. Explain what was fixed and why`, + }, + IMPROVE: { + label: "Improve Code", + description: + "Receive suggestions for code optimization, better practices, and architectural improvements while maintaining functionality. Available in the editor context menu (right-click on selected code).", + template: `Improve the following code from file path @/\${filePath}: \${userInput} \`\`\` @@ -65,27 +90,16 @@ Please suggest improvements for: 3. Best practices and patterns 4. Error handling and edge cases -Provide the improved code along with explanations for each enhancement. -` - -const ENHANCE_TEMPLATE = `Generate an enhanced version of this prompt (reply with only the enhanced prompt - no conversation, explanations, lead-in, bullet points, placeholders, or surrounding quotes): - -\${userInput}` - -// Get template based on prompt type -const defaultTemplates = { - EXPLAIN: EXPLAIN_TEMPLATE, - FIX: FIX_TEMPLATE, - IMPROVE: IMPROVE_TEMPLATE, - ENHANCE: ENHANCE_TEMPLATE, +Provide the improved code along with explanations for each enhancement.`, + }, } as const -type SupportPromptType = keyof typeof defaultTemplates +type SupportPromptType = keyof typeof supportPromptConfigs export const supportPrompt = { - default: defaultTemplates, + default: Object.fromEntries(Object.entries(supportPromptConfigs).map(([key, config]) => [key, config.template])), get: (customSupportPrompts: Record | undefined, type: SupportPromptType): string => { - return customSupportPrompts?.[type] ?? defaultTemplates[type] + return customSupportPrompts?.[type] ?? supportPromptConfigs[type].template }, create: (type: SupportPromptType, params: PromptParams, customSupportPrompts?: Record): string => { const template = supportPrompt.get(customSupportPrompts, type) @@ -95,13 +109,14 @@ export const supportPrompt = { export type { SupportPromptType } -// User-friendly labels for support prompt types -export const supportPromptLabels: Record = { - FIX: "Fix Issues", - EXPLAIN: "Explain Code", - IMPROVE: "Improve Code", - ENHANCE: "Enhance Prompt", -} as const +// Expose labels and descriptions for UI +export const supportPromptLabels = Object.fromEntries( + Object.entries(supportPromptConfigs).map(([key, config]) => [key, config.label]), +) as Record + +export const supportPromptDescriptions = Object.fromEntries( + Object.entries(supportPromptConfigs).map(([key, config]) => [key, config.description]), +) as Record export type CustomSupportPrompts = { [key: string]: string | undefined diff --git a/webview-ui/src/components/prompts/PromptsView.tsx b/webview-ui/src/components/prompts/PromptsView.tsx index c2f3cad..c05f70f 100644 --- a/webview-ui/src/components/prompts/PromptsView.tsx +++ b/webview-ui/src/components/prompts/PromptsView.tsx @@ -9,7 +9,12 @@ import { } from "@vscode/webview-ui-toolkit/react" import { useExtensionState } from "../../context/ExtensionStateContext" import { Mode, PromptComponent, getRoleDefinition, getAllModes, ModeConfig } from "../../../../src/shared/modes" -import { supportPrompt, SupportPromptType, supportPromptLabels } from "../../../../src/shared/support-prompt" +import { + supportPrompt, + SupportPromptType, + supportPromptLabels, + supportPromptDescriptions, +} from "../../../../src/shared/support-prompt" import { TOOL_GROUPS, GROUP_DISPLAY_NAMES, ToolGroup } from "../../../../src/shared/tool-groups" import { vscode } from "../../utils/vscode" @@ -46,7 +51,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { const [selectedPromptTitle, setSelectedPromptTitle] = useState("") const [isToolsEditMode, setIsToolsEditMode] = useState(false) const [isCreateModeDialogOpen, setIsCreateModeDialogOpen] = useState(false) - const [activeSupportTab, setActiveSupportTab] = useState("EXPLAIN") + const [activeSupportTab, setActiveSupportTab] = useState("ENHANCE") // Direct update functions const updateAgentPrompt = useCallback( @@ -313,7 +318,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
-
+
Preferred Language