← All source files

V14 / fad4e1a110e5

Lilith.Commands.Workspace.cs

Lilith/Agent/Lilith.Commands.Workspace.cs

Unchanged from the preceding version
CS
using System.Text.Json;
using Lilith.Core.Commands;

namespace Lilith.Agent;

public partial class Lilith
{
    partial void RegisterWorkspaceCommands(ChatCommandRegistry commands)
    {
        commands.RegisterAsync("workspace", "List proposals; /workspace review <id> inspects one. Access mode is fixed at boot.", async context =>
        {
            string output = context.Arguments switch
            {
                "" => JsonSerializer.Serialize(await Workspace.ExecuteAsync(new("pending"), context.CancellationToken)),
                var args when args.StartsWith("review ", StringComparison.OrdinalIgnoreCase) => JsonSerializer.Serialize(Workspace.Review(args[7..].Trim()), new JsonSerializerOptions { WriteIndented = true }),
                _ => "Workspace mode is fixed at boot. Restart to choose ask or yolo."
            };
            return new(true, output);
        });
        commands.RegisterAsync("approve", "Approve an exact workspace proposal: /approve <id>.", async context => { await ApproveWorkspaceAsync(context.Arguments, context.CancellationToken); return new(true); });
        commands.RegisterAsync("reject", "Reject a workspace proposal: /reject <id>.", async context => { await RejectWorkspaceAsync(context.Arguments, context.CancellationToken); return new(true); });
    }
}