Skip to content

Commit 55e8170

Browse files
authored
Merge pull request RooCodeInc#763 from RooVetGit/improve_default_roles
Improve the default prompts for Architect and Ask
2 parents 4c494ca + 624c449 commit 55e8170

File tree

3 files changed

+74
-13
lines changed

3 files changed

+74
-13
lines changed

src/core/prompts/__tests__/__snapshots__/system.test.ts.snap

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,7 +3597,7 @@ Mock generic rules"
35973597
`;
35983598
35993599
exports[`addCustomInstructions should generate correct prompt for architect mode 1`] = `
3600-
"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.
3600+
"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.
36013601
36023602
====
36033603
@@ -3898,6 +3898,11 @@ USER'S CUSTOM INSTRUCTIONS
38983898
38993899
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.
39003900
3901+
Mode-specific Instructions:
3902+
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.)
3903+
3904+
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.
3905+
39013906
Rules:
39023907
# Rules from .clinerules-architect:
39033908
Mock mode-specific rules
@@ -3906,7 +3911,7 @@ Mock generic rules"
39063911
`;
39073912
39083913
exports[`addCustomInstructions should generate correct prompt for ask mode 1`] = `
3909-
"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.
3914+
"You are Roo, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics.
39103915
39113916
====
39123917
@@ -4207,6 +4212,9 @@ USER'S CUSTOM INSTRUCTIONS
42074212
42084213
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.
42094214
4215+
Mode-specific Instructions:
4216+
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.
4217+
42104218
Rules:
42114219
# Rules from .clinerules-ask:
42124220
Mock mode-specific rules

src/shared/modes.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,19 @@ export const modes: readonly ModeConfig[] = [
8282
slug: "architect",
8383
name: "Architect",
8484
roleDefinition:
85-
"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.",
85+
"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.",
8686
groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"],
87+
customInstructions:
88+
"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.",
8789
},
8890
{
8991
slug: "ask",
9092
name: "Ask",
9193
roleDefinition:
92-
"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.",
94+
"You are Roo, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics.",
9395
groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"],
96+
customInstructions:
97+
"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.",
9498
},
9599
] as const
96100

@@ -223,7 +227,15 @@ export function isToolAllowedForMode(
223227

224228
// Create the mode-specific default prompts
225229
export const defaultPrompts: Readonly<CustomModePrompts> = Object.freeze(
226-
Object.fromEntries(modes.map((mode) => [mode.slug, { roleDefinition: mode.roleDefinition }])),
230+
Object.fromEntries(
231+
modes.map((mode) => [
232+
mode.slug,
233+
{
234+
roleDefinition: mode.roleDefinition,
235+
customInstructions: mode.customInstructions,
236+
},
237+
]),
238+
),
227239
)
228240

229241
// Helper function to safely get role definition
@@ -235,3 +247,13 @@ export function getRoleDefinition(modeSlug: string, customModes?: ModeConfig[]):
235247
}
236248
return mode.roleDefinition
237249
}
250+
251+
// Helper function to safely get custom instructions
252+
export function getCustomInstructions(modeSlug: string, customModes?: ModeConfig[]): string {
253+
const mode = getModeBySlug(modeSlug, customModes)
254+
if (!mode) {
255+
console.warn(`No mode found for slug: ${modeSlug}`)
256+
return ""
257+
}
258+
return mode.customInstructions ?? ""
259+
}

webview-ui/src/components/prompts/PromptsView.tsx

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
Mode,
1313
PromptComponent,
1414
getRoleDefinition,
15+
getCustomInstructions,
1516
getAllModes,
1617
ModeConfig,
1718
GroupEntry,
@@ -272,12 +273,16 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
272273
})
273274
}
274275

275-
const handleAgentReset = (modeSlug: string) => {
276-
// Only reset role definition for built-in modes
276+
const handleAgentReset = (modeSlug: string, type: "roleDefinition" | "customInstructions") => {
277+
// Only reset for built-in modes
277278
const existingPrompt = customModePrompts?.[modeSlug] as PromptComponent
278-
updateAgentPrompt(modeSlug, {
279-
...existingPrompt,
280-
roleDefinition: undefined,
279+
const updatedPrompt = { ...existingPrompt }
280+
delete updatedPrompt[type] // Remove the field entirely to ensure it reloads from defaults
281+
282+
vscode.postMessage({
283+
type: "updatePrompt",
284+
promptMode: modeSlug,
285+
customPrompt: updatedPrompt,
281286
})
282287
}
283288

@@ -554,7 +559,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
554559
onClick={() => {
555560
const currentMode = getCurrentMode()
556561
if (currentMode?.slug) {
557-
handleAgentReset(currentMode.slug)
562+
handleAgentReset(currentMode.slug, "roleDefinition")
558563
}
559564
}}
560565
title="Reset to default"
@@ -749,7 +754,29 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
749754

750755
{/* Role definition for both built-in and custom modes */}
751756
<div style={{ marginBottom: "8px" }}>
752-
<div style={{ fontWeight: "bold", marginBottom: "4px" }}>Mode-specific Custom Instructions</div>
757+
<div
758+
style={{
759+
display: "flex",
760+
justifyContent: "space-between",
761+
alignItems: "center",
762+
marginBottom: "4px",
763+
}}>
764+
<div style={{ fontWeight: "bold" }}>Mode-specific Custom Instructions</div>
765+
{!findModeBySlug(selectedModeTab, customModes) && (
766+
<VSCodeButton
767+
appearance="icon"
768+
onClick={() => {
769+
const currentMode = getCurrentMode()
770+
if (currentMode?.slug) {
771+
handleAgentReset(currentMode.slug, "customInstructions")
772+
}
773+
}}
774+
title="Reset to default"
775+
data-testid="custom-instructions-reset">
776+
<span className="codicon codicon-discard"></span>
777+
</VSCodeButton>
778+
)}
779+
</div>
753780
<div
754781
style={{
755782
fontSize: "13px",
@@ -762,7 +789,11 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
762789
value={(() => {
763790
const customMode = findModeBySlug(selectedModeTab, customModes)
764791
const prompt = customModePrompts?.[selectedModeTab] as PromptComponent
765-
return customMode?.customInstructions ?? prompt?.customInstructions ?? ""
792+
return (
793+
customMode?.customInstructions ??
794+
prompt?.customInstructions ??
795+
getCustomInstructions(selectedModeTab, customModes)
796+
)
766797
})()}
767798
onChange={(e) => {
768799
const value =

0 commit comments

Comments
 (0)