kaeru 0.1.4

Reopens your terminal tabs, and the coding agent sessions in them, after the terminal closes or the computer restarts.

# Codex runs its sessions in a shared background server unless it starts with
# --no-daemon, and then its hooks can't tell which tab a session is in. In a
# tab that kaeru tracks, this starts Codex's interactive screen with
# --no-daemon, so that the session runs in the tab. Other Codex commands run
# as they are. kaeru adds this when its codex-no-daemon option is on.
if ($global:__kaeru_cwd_file) {
    function global:codex {
        $codex = Get-Command -Name codex -CommandType ExternalScript, Application -ErrorAction SilentlyContinue |
            Select-Object -First 1
        if ($null -eq $codex) {
            throw 'codex is not installed.'
        }
        $oneOff = @(KAERU_ONE_OFF_COMMANDS)
        $asItIs = $args | Where-Object {
            $_ -is [string] -and ($_ -ceq '--no-daemon' -or $_ -clike '--remote*' -or $oneOff -ccontains $_)
        }
        # @() keeps a single argument a list, which splatting needs.
        $arguments = @(if ($asItIs) { $args } else { @('--no-daemon') + $args })
        if ($MyInvocation.ExpectingInput) {
            $input | & $codex @arguments
        } else {
            & $codex @arguments
        }
    }
}