11import { describe , expect , test } from "bun:test" ;
2- import { createAgents , getAgentConfigs , getSubagentNames , getPrimaryAgentNames } from "./index" ;
2+ import { createAgents , getAgentConfigs , isSubagent } from "./index" ;
3+ import { SUBAGENT_NAMES } from "../config" ;
34import type { PluginConfig } from "../config" ;
45
56describe ( "agent alias backward compatibility" , ( ) => {
@@ -63,31 +64,94 @@ describe("agent alias backward compatibility", () => {
6364 } ) ;
6465} ) ;
6566
66- describe ( "agent classification" , ( ) => {
67- test ( "getPrimaryAgentNames returns only orchestrator" , ( ) => {
68- const names = getPrimaryAgentNames ( ) ;
69- expect ( names ) . toEqual ( [ "orchestrator" ] ) ;
67+ describe ( "fixer agent fallback" , ( ) => {
68+ test ( "fixer inherits librarian model when no fixer config provided" , ( ) => {
69+ const config : PluginConfig = {
70+ agents : {
71+ librarian : { model : "librarian-custom-model" } ,
72+ } ,
73+ } ;
74+ const agents = createAgents ( config ) ;
75+ const fixer = agents . find ( ( a ) => a . name === "fixer" ) ;
76+ const librarian = agents . find ( ( a ) => a . name === "librarian" ) ;
77+ expect ( fixer ! . config . model ) . toBe ( librarian ! . config . model ) ;
7078 } ) ;
7179
72- test ( "getSubagentNames excludes orchestrator" , ( ) => {
73- const names = getSubagentNames ( ) ;
74- expect ( names ) . not . toContain ( "orchestrator" ) ;
75- expect ( names ) . toContain ( "explorer" ) ;
76- expect ( names ) . toContain ( "fixer" ) ;
80+ test ( "fixer uses its own model when explicitly configured" , ( ) => {
81+ const config : PluginConfig = {
82+ agents : {
83+ librarian : { model : "librarian-model" } ,
84+ fixer : { model : "fixer-specific-model" } ,
85+ } ,
86+ } ;
87+ const agents = createAgents ( config ) ;
88+ const fixer = agents . find ( ( a ) => a . name === "fixer" ) ;
89+ expect ( fixer ! . config . model ) . toBe ( "fixer-specific-model" ) ;
90+ } ) ;
91+ } ) ;
92+
93+ describe ( "orchestrator agent" , ( ) => {
94+ test ( "orchestrator is first in agents array" , ( ) => {
95+ const agents = createAgents ( ) ;
96+ expect ( agents [ 0 ] . name ) . toBe ( "orchestrator" ) ;
97+ } ) ;
98+
99+ test ( "orchestrator has question permission set to allow" , ( ) => {
100+ const agents = createAgents ( ) ;
101+ const orchestrator = agents . find ( ( a ) => a . name === "orchestrator" ) ;
102+ expect ( orchestrator ! . config . permission ) . toBeDefined ( ) ;
103+ expect ( ( orchestrator ! . config . permission as any ) . question ) . toBe ( "allow" ) ;
104+ } ) ;
105+
106+ test ( "orchestrator accepts overrides" , ( ) => {
107+ const config : PluginConfig = {
108+ agents : {
109+ orchestrator : { model : "custom-orchestrator-model" , temperature : 0.3 } ,
110+ } ,
111+ } ;
112+ const agents = createAgents ( config ) ;
113+ const orchestrator = agents . find ( ( a ) => a . name === "orchestrator" ) ;
114+ expect ( orchestrator ! . config . model ) . toBe ( "custom-orchestrator-model" ) ;
115+ expect ( orchestrator ! . config . temperature ) . toBe ( 0.3 ) ;
116+ } ) ;
117+ } ) ;
118+
119+ describe ( "isSubagent type guard" , ( ) => {
120+ test ( "returns true for valid subagent names" , ( ) => {
121+ expect ( isSubagent ( "explorer" ) ) . toBe ( true ) ;
122+ expect ( isSubagent ( "librarian" ) ) . toBe ( true ) ;
123+ expect ( isSubagent ( "oracle" ) ) . toBe ( true ) ;
124+ expect ( isSubagent ( "designer" ) ) . toBe ( true ) ;
125+ expect ( isSubagent ( "fixer" ) ) . toBe ( true ) ;
126+ } ) ;
127+
128+ test ( "returns false for orchestrator" , ( ) => {
129+ expect ( isSubagent ( "orchestrator" ) ) . toBe ( false ) ;
130+ } ) ;
131+
132+ test ( "returns false for invalid agent names" , ( ) => {
133+ expect ( isSubagent ( "invalid-agent" ) ) . toBe ( false ) ;
134+ expect ( isSubagent ( "" ) ) . toBe ( false ) ;
135+ expect ( isSubagent ( "explore" ) ) . toBe ( false ) ; // old alias, not actual agent name
136+ } ) ;
137+ } ) ;
138+
139+ describe ( "agent classification" , ( ) => {
140+ test ( "SUBAGENT_NAMES excludes orchestrator" , ( ) => {
141+ expect ( SUBAGENT_NAMES ) . not . toContain ( "orchestrator" ) ;
142+ expect ( SUBAGENT_NAMES ) . toContain ( "explorer" ) ;
143+ expect ( SUBAGENT_NAMES ) . toContain ( "fixer" ) ;
77144 } ) ;
78145
79146 test ( "getAgentConfigs applies correct classification visibility and mode" , ( ) => {
80147 const configs = getAgentConfigs ( ) ;
81148
82149 // Primary agent
83150 expect ( configs [ "orchestrator" ] . mode ) . toBe ( "primary" ) ;
84- expect ( configs [ "orchestrator" ] . hidden ) . toBeFalsy ( ) ;
85151
86152 // Subagents
87- const subagents = getSubagentNames ( ) ;
88- for ( const name of subagents ) {
153+ for ( const name of SUBAGENT_NAMES ) {
89154 expect ( configs [ name ] . mode ) . toBe ( "subagent" ) ;
90- expect ( configs [ name ] . hidden ) . toBe ( true ) ;
91155 }
92156 } ) ;
93157} ) ;
@@ -101,18 +165,12 @@ describe("createAgents", () => {
101165 expect ( names ) . toContain ( "designer" ) ;
102166 expect ( names ) . toContain ( "oracle" ) ;
103167 expect ( names ) . toContain ( "librarian" ) ;
168+ expect ( names ) . toContain ( "fixer" ) ;
104169 } ) ;
105170
106- test ( "respects disabled_agents" , ( ) => {
107- const config : PluginConfig = {
108- disabled_agents : [ "explorer" , "designer" ] ,
109- } ;
110- const agents = createAgents ( config ) ;
111- const names = agents . map ( ( a ) => a . name ) ;
112- expect ( names ) . not . toContain ( "explorer" ) ;
113- expect ( names ) . not . toContain ( "designer" ) ;
114- expect ( names ) . toContain ( "orchestrator" ) ;
115- expect ( names ) . toContain ( "oracle" ) ;
171+ test ( "creates exactly 6 agents (1 primary + 5 subagents)" , ( ) => {
172+ const agents = createAgents ( ) ;
173+ expect ( agents . length ) . toBe ( 6 ) ;
116174 } ) ;
117175} ) ;
118176
@@ -123,4 +181,10 @@ describe("getAgentConfigs", () => {
123181 expect ( configs [ "explorer" ] ) . toBeDefined ( ) ;
124182 expect ( configs [ "orchestrator" ] . model ) . toBeDefined ( ) ;
125183 } ) ;
184+
185+ test ( "includes description in SDK config" , ( ) => {
186+ const configs = getAgentConfigs ( ) ;
187+ expect ( configs [ "orchestrator" ] . description ) . toBeDefined ( ) ;
188+ expect ( configs [ "explorer" ] . description ) . toBeDefined ( ) ;
189+ } ) ;
126190} ) ;
0 commit comments