@@ -44,16 +44,31 @@ export namespace Config {
4444
4545 result . agent = result . agent || { }
4646 const markdownAgents = [
47- ...( await Filesystem . globUp ( "agent/*.md" , Global . Path . config , Global . Path . config ) ) ,
48- ...( await Filesystem . globUp ( ".opencode/agent/*.md" , app . path . cwd , app . path . root ) ) ,
47+ ...( await Filesystem . globUp ( "agent/**/* .md" , Global . Path . config , Global . Path . config ) ) ,
48+ ...( await Filesystem . globUp ( ".opencode/agent/**/* .md" , app . path . cwd , app . path . root ) ) ,
4949 ]
5050 for ( const item of markdownAgents ) {
5151 const content = await Bun . file ( item ) . text ( )
5252 const md = matter ( content )
5353 if ( ! md . data ) continue
5454
55+ // Extract relative path from agent folder for nested agents
56+ let agentName = path . basename ( item , ".md" )
57+ const agentFolderPath = item . includes ( "/.opencode/agent/" )
58+ ? item . split ( "/.opencode/agent/" ) [ 1 ]
59+ : item . includes ( "/agent/" )
60+ ? item . split ( "/agent/" ) [ 1 ]
61+ : agentName + ".md"
62+
63+ // If agent is in a subfolder, include folder path in name
64+ if ( agentFolderPath . includes ( "/" ) ) {
65+ const relativePath = agentFolderPath . replace ( ".md" , "" )
66+ const pathParts = relativePath . split ( "/" )
67+ agentName = pathParts . slice ( 0 , - 1 ) . join ( "/" ) . toUpperCase ( ) + "/" + pathParts [ pathParts . length - 1 ] . toUpperCase ( )
68+ }
69+
5570 const config = {
56- name : path . basename ( item , ".md" ) ,
71+ name : agentName ,
5772 ...md . data ,
5873 prompt : md . content . trim ( ) ,
5974 }
0 commit comments