Skip to content

Commit ee06841

Browse files
committed
refactor(cli): consolidate agent mode definitions into single source of truth
1 parent a83b25a commit ee06841

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

cli/src/commands/command-registry.ts

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import type { InputValue, PendingImage } from '../state/chat-store'
1414
import type { ChatMessage } from '../types/chat'
1515
import type { SendMessageFn } from '../types/contracts/send-message'
1616
import type { User } from '../utils/auth'
17+
import { AGENT_MODES } from '../utils/constants'
18+
1719
import type { AgentMode } from '../utils/constants'
1820
import type { UseMutationResult } from '@tanstack/react-query'
1921

@@ -248,48 +250,21 @@ export const COMMAND_REGISTRY: CommandDefinition[] = [
248250
clearInput(params)
249251
},
250252
},
251-
{
252-
name: 'mode:default',
253-
aliases: [],
254-
handler: (params) => {
255-
useChatStore.getState().setAgentMode('DEFAULT')
253+
// Mode commands generated from AGENT_MODES
254+
...AGENT_MODES.map((mode) => ({
255+
name: `mode:${mode.toLowerCase()}`,
256+
aliases: [] as string[],
257+
handler: (params: RouterParams) => {
258+
useChatStore.getState().setAgentMode(mode)
256259
params.setMessages((prev) => [
257260
...prev,
258261
getUserMessage(params.inputValue.trim()),
259-
getSystemMessage('Switched to DEFAULT mode.'),
262+
getSystemMessage(`Switched to ${mode} mode.`),
260263
])
261264
params.saveToHistory(params.inputValue.trim())
262265
clearInput(params)
263266
},
264-
},
265-
{
266-
name: 'mode:max',
267-
aliases: [],
268-
handler: (params) => {
269-
useChatStore.getState().setAgentMode('MAX')
270-
params.setMessages((prev) => [
271-
...prev,
272-
getUserMessage(params.inputValue.trim()),
273-
getSystemMessage('Switched to MAX mode.'),
274-
])
275-
params.saveToHistory(params.inputValue.trim())
276-
clearInput(params)
277-
},
278-
},
279-
{
280-
name: 'mode:plan',
281-
aliases: [],
282-
handler: (params) => {
283-
useChatStore.getState().setAgentMode('PLAN')
284-
params.setMessages((prev) => [
285-
...prev,
286-
getUserMessage(params.inputValue.trim()),
287-
getSystemMessage('Switched to PLAN mode.'),
288-
])
289-
params.saveToHistory(params.inputValue.trim())
290-
clearInput(params)
291-
},
292-
},
267+
})),
293268
]
294269

295270
export function findCommand(cmd: string): CommandDefinition | undefined {

0 commit comments

Comments
 (0)