diff --git a/src/commands.ts b/src/commands.ts index 012a6a9bb..508498c27 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -19,6 +19,7 @@ import { context, contextNonInteractive } from './commands/context/index.js' import diff from './commands/diff/index.js' import doctor from './commands/doctor/index.js' import memory from './commands/memory/index.js' +import mode from './commands/mode/index.js' import help from './commands/help/index.js' import ide from './commands/ide/index.js' import init from './commands/init.js' @@ -327,6 +328,7 @@ const COMMANDS = memoize((): Command[] => [ mcp, memory, mobile, + mode, model, outputStyle, remoteEnv, diff --git a/src/commands/mode/index.ts b/src/commands/mode/index.ts new file mode 100644 index 000000000..d9b9e7339 --- /dev/null +++ b/src/commands/mode/index.ts @@ -0,0 +1,13 @@ +import type { Command } from '../../commands.js' + +const mode = { + type: 'local-jsx', + name: 'mode', + description: + 'Switch interaction mode (default, gentle, sharp, workhorse, token-saver, super-ai)', + isEnabled: () => true, + argumentHint: '', + load: () => import('./mode.js'), +} satisfies Command + +export default mode diff --git a/src/commands/mode/mode.tsx b/src/commands/mode/mode.tsx new file mode 100644 index 000000000..2aad5fde8 --- /dev/null +++ b/src/commands/mode/mode.tsx @@ -0,0 +1,79 @@ +import { useMemo } from 'react'; +import { Box, Text } from '@anthropic/ink'; +import { Select } from '../../components/CustomSelect/select.js'; +import type { LocalJSXCommandCall, LocalJSXCommandOnDone } from '../../types/command.js'; +import { getCurrentModeSlug, listModes, setCurrentMode } from '../../modes/store.js'; + +function ModePicker({ onDone }: { onDone: LocalJSXCommandOnDone }) { + const modes = listModes(); + const currentSlug = getCurrentModeSlug(); + + const options = useMemo( + () => + modes.map(m => ({ + label: ( + + {m.icon} {m.name}{' '} + + ({m.slug}) — {m.description} + + + ), + value: m.slug, + })), + [modes], + ); + + function handleSelect(slug: string) { + setCurrentMode(slug); + const target = modes.find(m => m.slug === slug); + onDone(`${target?.icon} Mode switched to: ${target?.name} (${target?.slug}) — ${target?.description}`, { + display: 'system', + }); + } + + function handleCancel() { + onDone('Mode selection cancelled.', { display: 'system' }); + } + + return ( + + + + Select mode + + Arrow keys to navigate, Enter to select, Esc to cancel. + +