diff --git a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap index 2de14d7fbb..20eff3ed27 100644 --- a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap +++ b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap @@ -3597,7 +3597,7 @@ Mock generic rules" `; exports[`addCustomInstructions should generate correct prompt for architect mode 1`] = ` -"You are Roo, a software architecture expert specializing in analyzing codebases, identifying patterns, and providing high-level technical guidance. You excel at understanding complex systems, evaluating architectural decisions, and suggesting improvements. You can edit markdown documentation files to help document architectural decisions and patterns. +"You are Roo, an experienced technical leader who is inquisitive and an excellent planner. Your goal is to gather information and get context to create a detailed plan for accomplishing the user's task, which the user will review and approve before they switch into another mode to implement the solution. ==== @@ -3898,6 +3898,11 @@ USER'S CUSTOM INSTRUCTIONS The following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the TOOL USE guidelines. +Mode-specific Instructions: +Depending on the user's request, you may need to do some information gathering (for example using read_file or search_files) to get more context about the task. You may also ask the user clarifying questions to get a better understanding of the task. Once you've gained more context about the user's request, you should create a detailed plan for how to accomplish the task. (You can write the plan to a markdown file if it seems appropriate.) + +Then you might ask the user if they are pleased with this plan, or if they would like to make any changes. Think of this as a brainstorming session where you can discuss the task and plan the best way to accomplish it. Finally once it seems like you've reached a good plan, use the switch_mode tool to request that the user switch to another mode to implement the solution. + Rules: # Rules from .clinerules-architect: Mock mode-specific rules @@ -3906,7 +3911,7 @@ Mock generic rules" `; exports[`addCustomInstructions should generate correct prompt for ask mode 1`] = ` -"You are Roo, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics. You can analyze code, explain concepts, and access external resources. While you primarily maintain a read-only approach to the codebase, you can create and edit markdown files to better document and explain concepts. Make sure to answer the user's questions and don't rush to switch to implementing code. +"You are Roo, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics. ==== @@ -4207,6 +4212,9 @@ USER'S CUSTOM INSTRUCTIONS The following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the TOOL USE guidelines. +Mode-specific Instructions: +You can analyze code, explain concepts, and access external resources. While you primarily maintain a read-only approach to the codebase, you can create and edit markdown files to better document and explain concepts. Make sure to answer the user's questions and don't rush to switch to implementing code. + Rules: # Rules from .clinerules-ask: Mock mode-specific rules diff --git a/src/shared/modes.ts b/src/shared/modes.ts index 3e9b0a32e2..f1b899cc5c 100644 --- a/src/shared/modes.ts +++ b/src/shared/modes.ts @@ -82,15 +82,19 @@ export const modes: readonly ModeConfig[] = [ slug: "architect", name: "Architect", roleDefinition: - "You are Roo, a software architecture expert specializing in analyzing codebases, identifying patterns, and providing high-level technical guidance. You excel at understanding complex systems, evaluating architectural decisions, and suggesting improvements. You can edit markdown documentation files to help document architectural decisions and patterns.", + "You are Roo, an experienced technical leader who is inquisitive and an excellent planner. Your goal is to gather information and get context to create a detailed plan for accomplishing the user's task, which the user will review and approve before they switch into another mode to implement the solution.", groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"], + customInstructions: + "Depending on the user's request, you may need to do some information gathering (for example using read_file or search_files) to get more context about the task. You may also ask the user clarifying questions to get a better understanding of the task. Once you've gained more context about the user's request, you should create a detailed plan for how to accomplish the task. (You can write the plan to a markdown file if it seems appropriate.)\n\nThen you might ask the user if they are pleased with this plan, or if they would like to make any changes. Think of this as a brainstorming session where you can discuss the task and plan the best way to accomplish it. Finally once it seems like you've reached a good plan, use the switch_mode tool to request that the user switch to another mode to implement the solution.", }, { slug: "ask", name: "Ask", roleDefinition: - "You are Roo, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics. You can analyze code, explain concepts, and access external resources. While you primarily maintain a read-only approach to the codebase, you can create and edit markdown files to better document and explain concepts. Make sure to answer the user's questions and don't rush to switch to implementing code.", + "You are Roo, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics.", groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"], + customInstructions: + "You can analyze code, explain concepts, and access external resources. While you primarily maintain a read-only approach to the codebase, you can create and edit markdown files to better document and explain concepts. Make sure to answer the user's questions and don't rush to switch to implementing code.", }, ] as const @@ -223,7 +227,15 @@ export function isToolAllowedForMode( // Create the mode-specific default prompts export const defaultPrompts: Readonly = Object.freeze( - Object.fromEntries(modes.map((mode) => [mode.slug, { roleDefinition: mode.roleDefinition }])), + Object.fromEntries( + modes.map((mode) => [ + mode.slug, + { + roleDefinition: mode.roleDefinition, + customInstructions: mode.customInstructions, + }, + ]), + ), ) // Helper function to safely get role definition @@ -235,3 +247,13 @@ export function getRoleDefinition(modeSlug: string, customModes?: ModeConfig[]): } return mode.roleDefinition } + +// Helper function to safely get custom instructions +export function getCustomInstructions(modeSlug: string, customModes?: ModeConfig[]): string { + const mode = getModeBySlug(modeSlug, customModes) + if (!mode) { + console.warn(`No mode found for slug: ${modeSlug}`) + return "" + } + return mode.customInstructions ?? "" +} diff --git a/webview-ui/src/components/prompts/PromptsView.tsx b/webview-ui/src/components/prompts/PromptsView.tsx index e76e5e43ac..caef1cf94e 100644 --- a/webview-ui/src/components/prompts/PromptsView.tsx +++ b/webview-ui/src/components/prompts/PromptsView.tsx @@ -12,6 +12,7 @@ import { Mode, PromptComponent, getRoleDefinition, + getCustomInstructions, getAllModes, ModeConfig, GroupEntry, @@ -272,12 +273,16 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { }) } - const handleAgentReset = (modeSlug: string) => { - // Only reset role definition for built-in modes + const handleAgentReset = (modeSlug: string, type: "roleDefinition" | "customInstructions") => { + // Only reset for built-in modes const existingPrompt = customModePrompts?.[modeSlug] as PromptComponent - updateAgentPrompt(modeSlug, { - ...existingPrompt, - roleDefinition: undefined, + const updatedPrompt = { ...existingPrompt } + delete updatedPrompt[type] // Remove the field entirely to ensure it reloads from defaults + + vscode.postMessage({ + type: "updatePrompt", + promptMode: modeSlug, + customPrompt: updatedPrompt, }) } @@ -554,7 +559,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { onClick={() => { const currentMode = getCurrentMode() if (currentMode?.slug) { - handleAgentReset(currentMode.slug) + handleAgentReset(currentMode.slug, "roleDefinition") } }} title="Reset to default" @@ -749,7 +754,29 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { {/* Role definition for both built-in and custom modes */}
-
Mode-specific Custom Instructions
+
+
Mode-specific Custom Instructions
+ {!findModeBySlug(selectedModeTab, customModes) && ( + { + const currentMode = getCurrentMode() + if (currentMode?.slug) { + handleAgentReset(currentMode.slug, "customInstructions") + } + }} + title="Reset to default" + data-testid="custom-instructions-reset"> + + + )} +
{ value={(() => { const customMode = findModeBySlug(selectedModeTab, customModes) const prompt = customModePrompts?.[selectedModeTab] as PromptComponent - return customMode?.customInstructions ?? prompt?.customInstructions ?? "" + return ( + customMode?.customInstructions ?? + prompt?.customInstructions ?? + getCustomInstructions(selectedModeTab, customModes) + ) })()} onChange={(e) => { const value =