@@ -5,7 +5,7 @@ import * as vscode from "vscode"
55import matter from "gray-matter"
66
77import type { ClineProvider } from "../../core/webview/ClineProvider"
8- import { getGlobalRooDirectory } from "../roo-config"
8+ import { getGlobalRooDirectory , getGlobalAgentsDirectory , getProjectAgentsDirectoryForCwd } from "../roo-config"
99import { directoryExists , fileExists } from "../roo-config"
1010import { SkillMetadata , SkillContent } from "../../shared/skills"
1111import { modes , getAllModes } from "../../shared/modes"
@@ -590,19 +590,41 @@ Add your skill instructions here.
590590 > {
591591 const dirs : Array < { dir : string ; source : "global" | "project" ; mode ?: string } > = [ ]
592592 const globalRooDir = getGlobalRooDirectory ( )
593+ const globalAgentsDir = getGlobalAgentsDirectory ( )
593594 const provider = this . providerRef . deref ( )
594595 const projectRooDir = provider ?. cwd ? path . join ( provider . cwd , ".roo" ) : null
596+ const projectAgentsDir = provider ?. cwd ? getProjectAgentsDirectoryForCwd ( provider . cwd ) : null
595597
596598 // Get list of modes to check for mode-specific skills
597599 const modesList = await this . getAvailableModes ( )
598600
599- // Global directories
601+ // Priority order (later entries override earlier ones with same skill name):
602+ // 1. Global .agents/skills (shared across AI coding tools, lowest priority)
603+ // 2. Project .agents/skills
604+ // 3. Global .roo/skills (Roo-specific)
605+ // 4. Project .roo/skills (highest priority)
606+
607+ // Global .agents directories (lowest priority - shared across agents)
608+ dirs . push ( { dir : path . join ( globalAgentsDir , "skills" ) , source : "global" } )
609+ for ( const mode of modesList ) {
610+ dirs . push ( { dir : path . join ( globalAgentsDir , `skills-${ mode } ` ) , source : "global" , mode } )
611+ }
612+
613+ // Project .agents directories
614+ if ( projectAgentsDir ) {
615+ dirs . push ( { dir : path . join ( projectAgentsDir , "skills" ) , source : "project" } )
616+ for ( const mode of modesList ) {
617+ dirs . push ( { dir : path . join ( projectAgentsDir , `skills-${ mode } ` ) , source : "project" , mode } )
618+ }
619+ }
620+
621+ // Global .roo directories (Roo-specific, higher priority than .agents)
600622 dirs . push ( { dir : path . join ( globalRooDir , "skills" ) , source : "global" } )
601623 for ( const mode of modesList ) {
602624 dirs . push ( { dir : path . join ( globalRooDir , `skills-${ mode } ` ) , source : "global" , mode } )
603625 }
604626
605- // Project directories
627+ // Project .roo directories (highest priority)
606628 if ( projectRooDir ) {
607629 dirs . push ( { dir : path . join ( projectRooDir , "skills" ) , source : "project" } )
608630 for ( const mode of modesList ) {
@@ -647,20 +669,32 @@ Add your skill instructions here.
647669 if ( ! provider ?. cwd ) return
648670
649671 // Watch for changes in skills directories
650- const globalSkillsDir = path . join ( getGlobalRooDirectory ( ) , "skills" )
651- const projectSkillsDir = path . join ( provider . cwd , ".roo" , "skills" )
672+ const globalRooDir = getGlobalRooDirectory ( )
673+ const globalAgentsDir = getGlobalAgentsDirectory ( )
674+ const projectRooDir = path . join ( provider . cwd , ".roo" )
675+ const projectAgentsDir = getProjectAgentsDirectoryForCwd ( provider . cwd )
676+
677+ // Watch global .roo skills directory
678+ this . watchDirectory ( path . join ( globalRooDir , "skills" ) )
679+
680+ // Watch global .agents skills directory
681+ this . watchDirectory ( path . join ( globalAgentsDir , "skills" ) )
652682
653- // Watch global skills directory
654- this . watchDirectory ( globalSkillsDir )
683+ // Watch project .roo skills directory
684+ this . watchDirectory ( path . join ( projectRooDir , "skills" ) )
655685
656- // Watch project skills directory
657- this . watchDirectory ( projectSkillsDir )
686+ // Watch project .agents skills directory
687+ this . watchDirectory ( path . join ( projectAgentsDir , "skills" ) )
658688
659689 // Watch mode-specific directories for all available modes
660690 const modesList = await this . getAvailableModes ( )
661691 for ( const mode of modesList ) {
662- this . watchDirectory ( path . join ( getGlobalRooDirectory ( ) , `skills-${ mode } ` ) )
663- this . watchDirectory ( path . join ( provider . cwd , ".roo" , `skills-${ mode } ` ) )
692+ // .roo mode-specific
693+ this . watchDirectory ( path . join ( globalRooDir , `skills-${ mode } ` ) )
694+ this . watchDirectory ( path . join ( projectRooDir , `skills-${ mode } ` ) )
695+ // .agents mode-specific
696+ this . watchDirectory ( path . join ( globalAgentsDir , `skills-${ mode } ` ) )
697+ this . watchDirectory ( path . join ( projectAgentsDir , `skills-${ mode } ` ) )
664698 }
665699 }
666700
0 commit comments