Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions PolyPilot.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ private static async Task<bool> HandleCommandAsync(ParsedCommand command)
HandleStatus();
break;

case CommandType.Model:
HandleModel();
break;

case CommandType.Clear:
HandleClear();
break;
Expand Down Expand Up @@ -342,6 +346,19 @@ private static void HandleStatus()
}
}

private static void HandleModel()
{
var session = _sessionManager.GetActiveSession();

if (session == null)
{
AnsiConsole.MarkupLine("[yellow]No active session. Use /new <name> to create one.[/]");
return;
}

AnsiConsole.MarkupLine($"[bold]Model:[/] [yellow]{session.Model}[/]");
}

private static void HandleClear()
{
var session = _sessionManager.GetActiveSession();
Expand Down Expand Up @@ -415,6 +432,7 @@ private static void PrintCommandHelp()
table.AddRow("/list", "List all active sessions");
table.AddRow("/close <name>", "Close a session");
table.AddRow("/status", "Show current session info");
table.AddRow("/model", "Show current session's model");
table.AddRow("/clear", "Clear current session history");
table.AddRow("/help", "Show this help");
table.AddRow("/quit", "Exit application");
Expand All @@ -438,6 +456,7 @@ private static void PrintHelp()
Console.WriteLine(" /list List all sessions");
Console.WriteLine(" /close <name> Close a session");
Console.WriteLine(" /status Show current session info");
Console.WriteLine(" /model Show current session's model");
Console.WriteLine(" /clear Clear current session history");
Console.WriteLine(" /quit Exit application");
}
Expand Down
2 changes: 2 additions & 0 deletions PolyPilot.Console/Services/CommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum CommandType
ListSessions,
CloseSession,
Status,
Model,
Clear,
Help,
Quit,
Expand Down Expand Up @@ -43,6 +44,7 @@ public static ParsedCommand Parse(string input)
"/list" or "/ls" => new ParsedCommand(CommandType.ListSessions),
"/close" => new ParsedCommand(CommandType.CloseSession, arg1),
"/status" => new ParsedCommand(CommandType.Status),
"/model" => new ParsedCommand(CommandType.Model),
"/clear" => new ParsedCommand(CommandType.Clear),
"/help" or "/?" => new ParsedCommand(CommandType.Help),
"/quit" or "/exit" or "/q" => new ParsedCommand(CommandType.Quit),
Expand Down
64 changes: 64 additions & 0 deletions PolyPilot.Tests/CommandParserTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using PolyPilot.Services;
using Xunit;

namespace PolyPilot.Tests;

public class CommandParserTests
{
[Fact]
public void Model_Command_Returns_ModelType()
{
var result = CommandParser.Parse("/model");
Assert.Equal(CommandType.Model, result.Type);
}

[Fact]
public void Model_Command_CaseInsensitive()
{
var result = CommandParser.Parse("/MODEL");
Assert.Equal(CommandType.Model, result.Type);
}

[Fact]
public void Model_Command_WithWhitespace()
{
var result = CommandParser.Parse(" /model ");
Assert.Equal(CommandType.Model, result.Type);
}

[Fact]
public void Status_Command_Still_Works()
{
var result = CommandParser.Parse("/status");
Assert.Equal(CommandType.Status, result.Type);
}

[Fact]
public void Help_Command_Still_Works()
{
var result = CommandParser.Parse("/help");
Assert.Equal(CommandType.Help, result.Type);
}

[Fact]
public void Plain_Text_Returns_Prompt()
{
var result = CommandParser.Parse("hello world");
Assert.Equal(CommandType.Prompt, result.Type);
Assert.Equal("hello world", result.Argument);
}

[Fact]
public void Unknown_SlashCommand_Returns_Prompt()
{
var result = CommandParser.Parse("/unknown");
Assert.Equal(CommandType.Prompt, result.Type);
}

[Fact]
public void Empty_Input_Returns_Prompt()
{
var result = CommandParser.Parse("");
Assert.Equal(CommandType.Prompt, result.Type);
}
}
1 change: 1 addition & 0 deletions PolyPilot.Tests/PolyPilot.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Compile Include="../PolyPilot/Services/DevTunnelService.cs" Link="Shared/DevTunnelService.cs" />
<Compile Include="../PolyPilot/Services/FiestaService.cs" Link="Shared/FiestaService.cs" />
<Compile Include="../PolyPilot/Models/ReflectionCycle.cs" Link="Shared/ReflectionCycle.cs" />
<Compile Include="../PolyPilot.Console/Services/CommandParser.cs" Link="Shared/CommandParser.cs" />
<Compile Include="../PolyPilot/Models/ModelCapabilities.cs" Link="Shared/ModelCapabilities.cs" />
<Compile Include="../PolyPilot/Models/SquadDiscovery.cs" Link="Shared/SquadDiscovery.cs" />
<Compile Include="../PolyPilot/Models/SquadWriter.cs" Link="Shared/SquadWriter.cs" />
Expand Down