Skip to content

Commit

Permalink
Merge pull request RooVetGit#763 from RooVetGit/improve_default_roles
Browse files Browse the repository at this point in the history
Improve the default prompts for Architect and Ask
  • Loading branch information
mrubens authored Feb 4, 2025
2 parents 4c494ca + 624c449 commit 55e8170
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 13 deletions.
12 changes: 10 additions & 2 deletions src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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.
====
Expand Down Expand Up @@ -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
Expand All @@ -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.
====
Expand Down Expand Up @@ -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
Expand Down
28 changes: 25 additions & 3 deletions src/shared/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -223,7 +227,15 @@ export function isToolAllowedForMode(

// Create the mode-specific default prompts
export const defaultPrompts: Readonly<CustomModePrompts> = 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
Expand All @@ -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 ?? ""
}
47 changes: 39 additions & 8 deletions webview-ui/src/components/prompts/PromptsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Mode,
PromptComponent,
getRoleDefinition,
getCustomInstructions,
getAllModes,
ModeConfig,
GroupEntry,
Expand Down Expand Up @@ -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,
})
}

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -749,7 +754,29 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {

{/* Role definition for both built-in and custom modes */}
<div style={{ marginBottom: "8px" }}>
<div style={{ fontWeight: "bold", marginBottom: "4px" }}>Mode-specific Custom Instructions</div>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: "4px",
}}>
<div style={{ fontWeight: "bold" }}>Mode-specific Custom Instructions</div>
{!findModeBySlug(selectedModeTab, customModes) && (
<VSCodeButton
appearance="icon"
onClick={() => {
const currentMode = getCurrentMode()
if (currentMode?.slug) {
handleAgentReset(currentMode.slug, "customInstructions")
}
}}
title="Reset to default"
data-testid="custom-instructions-reset">
<span className="codicon codicon-discard"></span>
</VSCodeButton>
)}
</div>
<div
style={{
fontSize: "13px",
Expand All @@ -762,7 +789,11 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
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 =
Expand Down

0 comments on commit 55e8170

Please sign in to comment.