diff --git a/shell/AIShell.Kernel/Command/ClearCommand.cs b/shell/AIShell.Kernel/Command/ClearCommand.cs index 995a3189..8f775e31 100644 --- a/shell/AIShell.Kernel/Command/ClearCommand.cs +++ b/shell/AIShell.Kernel/Command/ClearCommand.cs @@ -6,9 +6,10 @@ namespace AIShell.Kernel.Commands; internal sealed class ClearCommand : CommandBase { public ClearCommand() - : base("cls", "Clear the screen.") + : base("clear", "Clear the screen.") { this.SetHandler(ClearAction); + this.AddAlias("cls"); } private void ClearAction() diff --git a/shell/AIShell.Kernel/Command/CommandRunner.cs b/shell/AIShell.Kernel/Command/CommandRunner.cs index 51048a72..515d430f 100644 --- a/shell/AIShell.Kernel/Command/CommandRunner.cs +++ b/shell/AIShell.Kernel/Command/CommandRunner.cs @@ -57,7 +57,14 @@ internal void LoadCommands(IEnumerable commands, string agentName) { command.Shell = _shell; command.Source = agentName; - _commands.Add(command.Name, command); + + // The 'command.Name' is included in the 'command.Aliases' collection. + // TODO: need to think about how to handle command names/aliases collision. + // We don't handle collision today -- it will throw when collision happens. + foreach (string alias in command.Aliases) + { + _commands.Add(alias, command); + } } } @@ -79,7 +86,13 @@ internal void UnloadAgentCommands() foreach (var command in agentCommands) { - _commands.Remove(command.Name); + // The 'command.Name' is included in the 'command.Aliases' collection. + // TODO: need to update accordingly when we handle command names/aliases collision. + foreach (string alias in command.Aliases) + { + _commands.Remove(alias); + } + command.Dispose(); } } diff --git a/shell/AIShell.Kernel/Command/HelpCommand.cs b/shell/AIShell.Kernel/Command/HelpCommand.cs index 30a9751f..5ad0c29b 100644 --- a/shell/AIShell.Kernel/Command/HelpCommand.cs +++ b/shell/AIShell.Kernel/Command/HelpCommand.cs @@ -17,7 +17,7 @@ private void HelpAction() var host = shellImpl.Host; var commands = shellImpl.CommandRunner.Commands; - var list = commands.Values.Order(new CommandComparer()).ToList(); + var list = commands.Values.Distinct().Order(new CommandComparer()).ToList(); host.WriteLine(); host.MarkupLine("[bold white]-[/] Type then press [bold olive underline]Enter[/] to chat with the chosen AI agent.");