@@ -44,16 +44,31 @@ export namespace Config {
44
44
45
45
result . agent = result . agent || { }
46
46
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 ) ) ,
49
49
]
50
50
for ( const item of markdownAgents ) {
51
51
const content = await Bun . file ( item ) . text ( )
52
52
const md = matter ( content )
53
53
if ( ! md . data ) continue
54
54
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
+
55
70
const config = {
56
- name : path . basename ( item , ".md" ) ,
71
+ name : agentName ,
57
72
...md . data ,
58
73
prompt : md . content . trim ( ) ,
59
74
}
0 commit comments