File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " roo-cline " : patch
3+ ---
4+
5+ Fix bug with role definition overrides for built-in modes
Original file line number Diff line number Diff line change @@ -350,6 +350,56 @@ describe("SYSTEM_PROMPT", () => {
350350 expect ( customInstructionsIndex ) . toBeGreaterThan ( userInstructionsHeader )
351351 } )
352352
353+ it ( "should use promptComponent roleDefinition when available" , async ( ) => {
354+ const customPrompts = {
355+ [ defaultModeSlug ] : {
356+ roleDefinition : "Custom prompt role definition" ,
357+ customInstructions : "Custom prompt instructions" ,
358+ } ,
359+ }
360+
361+ const prompt = await SYSTEM_PROMPT (
362+ mockContext ,
363+ "/test/path" ,
364+ false ,
365+ undefined ,
366+ undefined ,
367+ undefined ,
368+ defaultModeSlug ,
369+ customPrompts ,
370+ undefined ,
371+ )
372+
373+ // Role definition from promptComponent should be at the top
374+ expect ( prompt . indexOf ( "Custom prompt role definition" ) ) . toBeLessThan ( prompt . indexOf ( "TOOL USE" ) )
375+ // Should not contain the default mode's role definition
376+ expect ( prompt ) . not . toContain ( modes [ 0 ] . roleDefinition )
377+ } )
378+
379+ it ( "should fallback to modeConfig roleDefinition when promptComponent has no roleDefinition" , async ( ) => {
380+ const customPrompts = {
381+ [ defaultModeSlug ] : {
382+ customInstructions : "Custom prompt instructions" ,
383+ // No roleDefinition provided
384+ } ,
385+ }
386+
387+ const prompt = await SYSTEM_PROMPT (
388+ mockContext ,
389+ "/test/path" ,
390+ false ,
391+ undefined ,
392+ undefined ,
393+ undefined ,
394+ defaultModeSlug ,
395+ customPrompts ,
396+ undefined ,
397+ )
398+
399+ // Should use the default mode's role definition
400+ expect ( prompt . indexOf ( modes [ 0 ] . roleDefinition ) ) . toBeLessThan ( prompt . indexOf ( "TOOL USE" ) )
401+ } )
402+
353403 afterAll ( ( ) => {
354404 jest . restoreAllMocks ( )
355405 } )
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ async function generatePrompt(
5454
5555 // Get the full mode config to ensure we have the role definition
5656 const modeConfig = getModeBySlug ( mode , customModeConfigs ) || modes . find ( ( m ) => m . slug === mode ) || modes [ 0 ]
57- const roleDefinition = modeConfig . roleDefinition
57+ const roleDefinition = promptComponent ?. roleDefinition || modeConfig . roleDefinition
5858
5959 const basePrompt = `${ roleDefinition }
6060
You can’t perform that action at this time.
0 commit comments