|
| 1 | +import type { SlashCommand } from '../types.js'; |
| 2 | + |
| 3 | +export const coreCommands: SlashCommand[] = [ |
| 4 | + { |
| 5 | + aliases: ['h'], |
| 6 | + help: 'list available commands', |
| 7 | + name: 'help', |
| 8 | + run: (_arg, ctx) => { |
| 9 | + const lines = [ |
| 10 | + 'Available commands:', |
| 11 | + '', |
| 12 | + ' /help List available commands', |
| 13 | + ' /quit, /exit Exit the application', |
| 14 | + ' /clear, /new Start a new conversation', |
| 15 | + ' /model [name] Show or change the model', |
| 16 | + ' /compact Trigger conversation compaction', |
| 17 | + ' /status Show session status', |
| 18 | + ' /undo Undo last exchange', |
| 19 | + ' /retry Retry last user message', |
| 20 | + ' /verbose Cycle verbose tool output mode', |
| 21 | + ' /statusbar Toggle status bar (top/off)', |
| 22 | + '', |
| 23 | + 'Hotkeys:', |
| 24 | + ' Enter Send message', |
| 25 | + ' Esc Clear input', |
| 26 | + ' Ctrl+E Toggle thinking display', |
| 27 | + ' ← → Home End Cursor movement', |
| 28 | + ' Backspace/Del Delete character', |
| 29 | + ]; |
| 30 | + ctx.sys(lines.join('\n')); |
| 31 | + }, |
| 32 | + }, |
| 33 | + |
| 34 | + { |
| 35 | + aliases: ['exit'], |
| 36 | + help: 'exit the application', |
| 37 | + name: 'quit', |
| 38 | + run: (_arg, ctx) => { |
| 39 | + ctx.sys('Goodbye.'); |
| 40 | + ctx.exit(); |
| 41 | + }, |
| 42 | + }, |
| 43 | + |
| 44 | + { |
| 45 | + aliases: ['new'], |
| 46 | + help: 'start a new conversation', |
| 47 | + name: 'clear', |
| 48 | + run: (_arg, ctx) => { |
| 49 | + ctx.dispatch({ type: 'CLEAR_CHAT' }); |
| 50 | + ctx.sys('Starting a new conversation.'); |
| 51 | + }, |
| 52 | + }, |
| 53 | + |
| 54 | + { |
| 55 | + help: 'show or change the current model', |
| 56 | + name: 'model', |
| 57 | + usage: '/model [model-name]', |
| 58 | + run: (arg, ctx) => { |
| 59 | + if (!arg.trim()) { |
| 60 | + ctx.sys(`Current model: ${ctx.model}`); |
| 61 | + return; |
| 62 | + } |
| 63 | + ctx.sys(`Model changed to: ${arg.trim()}`); |
| 64 | + }, |
| 65 | + }, |
| 66 | + |
| 67 | + { |
| 68 | + help: 'show session status', |
| 69 | + name: 'status', |
| 70 | + run: (_arg, ctx) => { |
| 71 | + ctx.sys( |
| 72 | + [ |
| 73 | + `Model: ${ctx.model}`, |
| 74 | + `Streaming: ${ctx.isStreaming ? 'yes' : 'no'}`, |
| 75 | + `Input: ${ctx.inputText ? `${ctx.inputText.length} chars` : 'empty'}`, |
| 76 | + ].join('\n'), |
| 77 | + ); |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + { |
| 82 | + help: 'compact the conversation context', |
| 83 | + name: 'compact', |
| 84 | + run: (_arg, ctx) => { |
| 85 | + ctx.sys('Compacting conversation... (context optimization triggered)'); |
| 86 | + }, |
| 87 | + }, |
| 88 | + |
| 89 | + { |
| 90 | + help: 'undo the last exchange', |
| 91 | + name: 'undo', |
| 92 | + run: (_arg, ctx) => { |
| 93 | + ctx.sys('Undo requested — last exchange will be reverted.'); |
| 94 | + }, |
| 95 | + }, |
| 96 | + |
| 97 | + { |
| 98 | + help: 'retry the last user message', |
| 99 | + name: 'retry', |
| 100 | + run: (_arg, ctx) => { |
| 101 | + ctx.sys('Retrying last message...'); |
| 102 | + }, |
| 103 | + }, |
| 104 | + |
| 105 | + { |
| 106 | + help: 'cycle verbose tool output mode', |
| 107 | + name: 'verbose', |
| 108 | + run: (_arg, ctx) => { |
| 109 | + ctx.sys('Verbose mode toggled.'); |
| 110 | + }, |
| 111 | + }, |
| 112 | + |
| 113 | + { |
| 114 | + aliases: ['sb'], |
| 115 | + help: 'toggle status bar (on|off)', |
| 116 | + name: 'statusbar', |
| 117 | + usage: '/statusbar [on|off]', |
| 118 | + run: (arg, ctx) => { |
| 119 | + const mode = arg.trim().toLowerCase(); |
| 120 | + const next = mode === 'off' ? 'off' : 'top'; |
| 121 | + ctx.sys(`Status bar: ${next}`); |
| 122 | + }, |
| 123 | + }, |
| 124 | +]; |
0 commit comments