@@ -85,6 +85,110 @@ describe('config_file.setup', function()
8585 end ):wait ()
8686 end )
8787
88+ it (' get_opencode_agents filters out hidden agents' , function ()
89+ Promise .spawn (function ()
90+ state .api_client = {
91+ get_config = function ()
92+ return Promise .new ():resolve ({
93+ agent = {
94+ [' custom' ] = { mode = ' primary' },
95+ [' compaction' ] = { mode = ' primary' , hidden = true },
96+ [' title' ] = { mode = ' primary' , hidden = true },
97+ },
98+ })
99+ end ,
100+ get_current_project = function ()
101+ return Promise .new ():resolve ({ id = ' p1' })
102+ end ,
103+ }
104+ local agents = config_file .get_opencode_agents ():await ()
105+ assert .True (vim .tbl_contains (agents , ' custom' ))
106+ assert .False (vim .tbl_contains (agents , ' compaction' ))
107+ assert .False (vim .tbl_contains (agents , ' title' ))
108+ end ):wait ()
109+ end )
110+
111+ it (' get_subagents filters out hidden agents' , function ()
112+ Promise .spawn (function ()
113+ state .api_client = {
114+ get_config = function ()
115+ return Promise .new ():resolve ({
116+ agent = {
117+ [' explore' ] = { mode = ' all' },
118+ [' compaction' ] = { mode = ' all' , hidden = true },
119+ [' summary' ] = { hidden = true },
120+ },
121+ })
122+ end ,
123+ get_current_project = function ()
124+ return Promise .new ():resolve ({ id = ' p1' })
125+ end ,
126+ }
127+ local agents = config_file .get_subagents ():await ()
128+ assert .True (vim .tbl_contains (agents , ' general' ))
129+ assert .True (vim .tbl_contains (agents , ' explore' ))
130+ assert .False (vim .tbl_contains (agents , ' compaction' ))
131+ assert .False (vim .tbl_contains (agents , ' summary' ))
132+ end ):wait ()
133+ end )
134+
135+ it (' get_subagents does not duplicate built-in agents when configured' , function ()
136+ Promise .spawn (function ()
137+ state .api_client = {
138+ get_config = function ()
139+ return Promise .new ():resolve ({
140+ agent = {
141+ [' general' ] = { mode = ' subagent' , model = ' custom/model' },
142+ [' explore' ] = { mode = ' all' , temperature = 0.5 },
143+ [' custom' ] = { mode = ' subagent' },
144+ },
145+ })
146+ end ,
147+ get_current_project = function ()
148+ return Promise .new ():resolve ({ id = ' p1' })
149+ end ,
150+ }
151+ local agents = config_file .get_subagents ():await ()
152+
153+ -- Count occurrences of each agent
154+ local general_count = 0
155+ local explore_count = 0
156+ for _ , agent in ipairs (agents ) do
157+ if agent == ' general' then
158+ general_count = general_count + 1
159+ elseif agent == ' explore' then
160+ explore_count = explore_count + 1
161+ end
162+ end
163+
164+ -- Each should appear exactly once
165+ assert .equal (1 , general_count , ' general should appear exactly once' )
166+ assert .equal (1 , explore_count , ' explore should appear exactly once' )
167+ assert .True (vim .tbl_contains (agents , ' custom' ))
168+ end ):wait ()
169+ end )
170+
171+ it (' get_subagents respects disabled built-in agents' , function ()
172+ Promise .spawn (function ()
173+ state .api_client = {
174+ get_config = function ()
175+ return Promise .new ():resolve ({
176+ agent = {
177+ [' general' ] = { disable = true },
178+ [' explore' ] = { hidden = true },
179+ },
180+ })
181+ end ,
182+ get_current_project = function ()
183+ return Promise .new ():resolve ({ id = ' p1' })
184+ end ,
185+ }
186+ local agents = config_file .get_subagents ():await ()
187+ assert .False (vim .tbl_contains (agents , ' general' ))
188+ assert .False (vim .tbl_contains (agents , ' explore' ))
189+ end ):wait ()
190+ end )
191+
88192 it (' get_opencode_project returns project' , function ()
89193 Promise .spawn (function ()
90194 local project = { id = ' p1' , name = ' X' }
0 commit comments