Description

Self improve promote sandbox

Promotes verified sandbox over live, deploys built DLLs to this console, and restarts into the upgraded build. Call only after VERIFICATION PASSED.

Included in Version 8

Dynamically extracted tool implementation.
How to register SelfImprovementToolscsharp
registry.Register(new AgentTool(            "self_improve_promote_sandbox",            "Promotes verified sandbox over live, deploys built DLLs to this console, and restarts into the upgraded build. Call only after VERIFICATION PASSED.",            _ => 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 deployLog = PromoteDeploymentService.DeploySandboxBuildToRunningConsole(paths);        PromoteDeploymentService.SyncLiveSourceToShippedSource(paths);        string promoteNote = Path.Combine(paths.Root, "last-promote.txt");        File.WriteAllText(promoteNote, $"Promoted at {DateTime.UtcNow:O}\n{deployLog}");        bool testMode = Environment.GetEnvironmentVariable("LILITH_TESTER") == "1";        if (testMode)        {            return $"PROMOTED — {deployLog} Test runner will restart Lilith into the upgraded build.";        }        string? runningExe = Environment.ProcessPath            ?? Process.GetCurrentProcess().MainModule?.FileName;        if (string.IsNullOrWhiteSpace(runningExe))            return $"PROMOTED — {deployLog} Restart Lilith manually to run the upgraded build.";        var startInfo = new ProcessStartInfo(runningExe)        {            UseShellExecute = false,            WorkingDirectory = Path.GetDirectoryName(runningExe)!,        };        foreach (System.Collections.DictionaryEntry entry in Environment.GetEnvironmentVariables())        {            if (entry.Key is string key && entry.Value is string value)                startInfo.Environment[key] = value;        }        startInfo.Environment["GENESIS_AFTER_PROMOTE"] = "1";        Process.Start(startInfo);        Environment.Exit(0);        return "PROMOTED — restarting upgraded Lilith.";    }