execute method
Execute the command.
Implementation
@override
Future<CommandResult> execute(String args, ToolUseContext context) async {
final buffer = StringBuffer();
buffer.writeln('Terminal Setup Guide');
buffer.writeln('====================');
buffer.writeln();
buffer.writeln('Recommended configuration for best experience:');
buffer.writeln();
buffer.writeln('1. Shell Integration');
buffer.writeln(' Add to your shell profile (~/.zshrc or ~/.bashrc):');
buffer.writeln(' export MAGE_TERM=1');
buffer.writeln();
buffer.writeln('2. Font');
buffer.writeln(' Use a Nerd Font for icon support:');
buffer.writeln(' https://www.nerdfonts.com/');
buffer.writeln();
buffer.writeln('3. Terminal Emulator');
buffer.writeln(' Recommended: iTerm2, Alacritty, Kitty, WezTerm');
buffer.writeln(' Minimum: 80x24 terminal size, 256-color support');
buffer.writeln();
buffer.writeln('4. Environment variables');
buffer.writeln(' ANTHROPIC_API_KEY — your API key');
buffer.writeln(' MAGE_MODEL — default model (optional)');
buffer.writeln(' MAGE_MAX_TOKENS — max output tokens (optional)');
buffer.writeln();
// Detect current terminal
final term = Platform.environment['TERM'] ?? 'unknown';
final termProgram = Platform.environment['TERM_PROGRAM'] ?? 'unknown';
final colorterm = Platform.environment['COLORTERM'] ?? 'none';
buffer.writeln('Current terminal:');
buffer.writeln(' TERM=$term');
buffer.writeln(' TERM_PROGRAM=$termProgram');
buffer.writeln(' COLORTERM=$colorterm');
return TextCommandResult(buffer.toString());
}