Description

Self improve promote sandbox

Promotes sandbox over live, then restarts this Lilith process with the upgraded build. Only after verification passes.

Included in Version 9

Dynamically extracted tool implementation.
How to register SelfImprovementToolscsharp
registry.Register(new AgentTool(            "self_improve_promote_sandbox",            "Promotes sandbox over live, then restarts this Lilith process with the upgraded build. Only after verification passes.",            _ => InvokePromoteSandbox(),            null,            ToolCategory.Self));
Helper classes for SelfImprovementToolscsharp
    private string InvokePromoteSandbox()    {        var paths = RequirePaths();        if (!Directory.Exists(paths.Sandbox))            return "Error: sandbox does not exist.";        SourceTreeService.CreateBackup(paths);        SourceTreeService.CopyTree(paths.Sandbox, paths.Live, overwriteDestination: true);        string liveProject = Path.Combine(paths.Live, "Interfaces", "ConsoleApp", "LilithConsole", "LilithConsole.csproj");        string buildLog = File.Exists(liveProject)            ? SandboxBuildService.BuildProject(liveProject, paths.Live)            : "Skipped live build (console project missing).";        string promoteNote = Path.Combine(paths.Root, "last-promote.txt");        File.WriteAllText(promoteNote, $"Promoted at {DateTime.UtcNow:O}\n{buildLog}");        string builtExe = Path.Combine(            paths.Live, "Interfaces", "ConsoleApp", "LilithConsole", "bin", "Release", "net8.0", "LilithConsole.exe");        string? exe = File.Exists(builtExe)            ? builtExe            : Process.GetCurrentProcess().MainModule?.FileName;        if (string.IsNullOrWhiteSpace(exe))            return $"Promoted sandbox to live at {paths.Live}. Restart Lilith manually to run the upgraded build.";        string args = string.Join(" ", Environment.GetCommandLineArgs().Skip(1).Select(a => a.Contains(' ') ? $"\"{a}\"" : a));        Process.Start(new ProcessStartInfo(exe, args) { UseShellExecute = true });        Environment.Exit(0);        return "Restarting with upgraded build.";    }