@@ -83,7 +83,7 @@ export namespace Config {
83
83
...md . data ,
84
84
prompt : md . content . trim ( ) ,
85
85
}
86
- const parsed = Mode . safeParse ( config )
86
+ const parsed = Agent . safeParse ( config )
87
87
if ( parsed . success ) {
88
88
result . mode = mergeDeep ( result . mode , {
89
89
[ config . name ] : parsed . data ,
@@ -92,6 +92,15 @@ export namespace Config {
92
92
}
93
93
throw new InvalidError ( { path : item } , { cause : parsed . error } )
94
94
}
95
+ // Migrate deprecated mode field to agent field
96
+ for ( const [ name , mode ] of Object . entries ( result . mode ) ) {
97
+ result . agent = mergeDeep ( result . agent ?? { } , {
98
+ [ name ] : {
99
+ ...mode ,
100
+ mode : "primary" as const ,
101
+ } ,
102
+ } )
103
+ }
95
104
96
105
result . plugin = result . plugin || [ ]
97
106
result . plugin . push (
@@ -108,6 +117,12 @@ export namespace Config {
108
117
if ( result . keybinds ?. messages_revert && ! result . keybinds . messages_undo ) {
109
118
result . keybinds . messages_undo = result . keybinds . messages_revert
110
119
}
120
+ if ( result . keybinds ?. switch_mode && ! result . keybinds . switch_agent ) {
121
+ result . keybinds . switch_agent = result . keybinds . switch_mode
122
+ }
123
+ if ( result . keybinds ?. switch_mode_reverse && ! result . keybinds . switch_agent_reverse ) {
124
+ result . keybinds . switch_agent_reverse = result . keybinds . switch_mode_reverse
125
+ }
111
126
112
127
if ( ! result . username ) {
113
128
const os = await import ( "os" )
@@ -149,32 +164,34 @@ export namespace Config {
149
164
export const Mcp = z . discriminatedUnion ( "type" , [ McpLocal , McpRemote ] )
150
165
export type Mcp = z . infer < typeof Mcp >
151
166
152
- export const Mode = z
167
+ export const Agent = z
153
168
. object ( {
154
169
model : z . string ( ) . optional ( ) ,
155
170
temperature : z . number ( ) . optional ( ) ,
156
171
top_p : z . number ( ) . optional ( ) ,
157
172
prompt : z . string ( ) . optional ( ) ,
158
173
tools : z . record ( z . string ( ) , z . boolean ( ) ) . optional ( ) ,
159
174
disable : z . boolean ( ) . optional ( ) ,
175
+ description : z . string ( ) . optional ( ) . describe ( "Description of when to use the agent" ) ,
176
+ mode : z . union ( [ z . literal ( "subagent" ) , z . literal ( "primary" ) , z . literal ( "all" ) ] ) . optional ( ) ,
160
177
} )
161
178
. openapi ( {
162
- ref : "ModeConfig " ,
179
+ ref : "AgentConfig " ,
163
180
} )
164
- export type Mode = z . infer < typeof Mode >
165
-
166
- export const Agent = Mode . extend ( {
167
- description : z . string ( ) ,
168
- } ) . openapi ( {
169
- ref : "AgentConfig" ,
170
- } )
181
+ export type Agent = z . infer < typeof Agent >
171
182
172
183
export const Keybinds = z
173
184
. object ( {
174
185
leader : z . string ( ) . optional ( ) . default ( "ctrl+x" ) . describe ( "Leader key for keybind combinations" ) ,
175
186
app_help : z . string ( ) . optional ( ) . default ( "<leader>h" ) . describe ( "Show help dialog" ) ,
176
- switch_mode : z . string ( ) . optional ( ) . default ( "tab" ) . describe ( "Next mode" ) ,
177
- switch_mode_reverse : z . string ( ) . optional ( ) . default ( "shift+tab" ) . describe ( "Previous Mode" ) ,
187
+ switch_mode : z . string ( ) . optional ( ) . default ( "none" ) . describe ( "@deprecated use switch_agent. Next mode" ) ,
188
+ switch_mode_reverse : z
189
+ . string ( )
190
+ . optional ( )
191
+ . default ( "none" )
192
+ . describe ( "@deprecated use switch_agent_reverse. Previous mode" ) ,
193
+ switch_agent : z . string ( ) . optional ( ) . default ( "tab" ) . describe ( "Next agent" ) ,
194
+ switch_agent_reverse : z . string ( ) . optional ( ) . default ( "shift+tab" ) . describe ( "Previous agent" ) ,
178
195
editor_open : z . string ( ) . optional ( ) . default ( "<leader>e" ) . describe ( "Open external editor" ) ,
179
196
session_export : z . string ( ) . optional ( ) . default ( "<leader>x" ) . describe ( "Export session to editor" ) ,
180
197
session_new : z . string ( ) . optional ( ) . default ( "<leader>n" ) . describe ( "Create a new session" ) ,
@@ -257,19 +274,21 @@ export namespace Config {
257
274
. describe ( "Custom username to display in conversations instead of system username" ) ,
258
275
mode : z
259
276
. object ( {
260
- build : Mode . optional ( ) ,
261
- plan : Mode . optional ( ) ,
277
+ build : Agent . optional ( ) ,
278
+ plan : Agent . optional ( ) ,
262
279
} )
263
- . catchall ( Mode )
280
+ . catchall ( Agent )
264
281
. optional ( )
265
- . describe ( "Modes configuration, see https://opencode.ai/docs/modes " ) ,
282
+ . describe ( "@deprecated Use `agent` field instead. " ) ,
266
283
agent : z
267
284
. object ( {
285
+ plan : Agent . optional ( ) ,
286
+ build : Agent . optional ( ) ,
268
287
general : Agent . optional ( ) ,
269
288
} )
270
289
. catchall ( Agent )
271
290
. optional ( )
272
- . describe ( "Modes configuration, see https://opencode.ai/docs/modes " ) ,
291
+ . describe ( "Agent configuration, see https://opencode.ai/docs/agent " ) ,
273
292
provider : z
274
293
. record (
275
294
ModelsDev . Provider . partial ( )
0 commit comments