fix(wrapper): preserve stdin across every output mode

This commit is contained in:
AkitaOnRails
2026-07-25 12:56:29 -03:00
parent c180e1d994
commit 0055407e65
4 changed files with 43 additions and 18 deletions
+5 -8
View File
@@ -302,15 +302,12 @@ esac
maybe_warn_outdated || true
# `-t` only makes sense on a real terminal, but `-i` must be passed whenever
# stdin is a pipe/redirect too: subcommands that read stdin (`write-page
# --body -`, `hook`) otherwise see an immediately-closed stdin inside the
# container and silently persist an empty body.
TTY_ARGS=()
# Keep stdin attached in every mode. This covers pipes and redirects, plus the
# easy-to-miss terminal-stdin/redirected-stdout case. `AI_MEMORY_NO_TTY`
# suppresses only the pseudo-terminal allocation.
TTY_ARGS=(-i)
if [ -z "${AI_MEMORY_NO_TTY:-}" ] && [ -t 0 ] && [ -t 1 ]; then
TTY_ARGS=(-it)
elif [ ! -t 0 ]; then
TTY_ARGS=(-i)
TTY_ARGS+=(-t)
fi
# The CLI runs INSIDE the container but renders hook config for the HOST, which
+4 -7
View File
@@ -44,14 +44,11 @@ $HomePath = (Resolve-Path -LiteralPath $HOME).Path
$WorkPath = (Get-Location).Path
$HookHostRoot = ($HomePath -replace '\\', '/') + "/.local/share/ai-memory/hooks"
$DockerArgs = @("run", "--rm")
# `-t` needs a real console, but `-i` must also be passed when stdin is
# redirected: `write-page --body -` (and other stdin readers) would otherwise
# see empty stdin inside the container and silently persist an empty body.
$DockerArgs = @("run", "--rm", "-i")
# Keep stdin attached in every mode. `AI_MEMORY_NO_TTY` suppresses only the
# pseudo-terminal allocation.
if (-not $env:AI_MEMORY_NO_TTY -and -not [Console]::IsInputRedirected -and -not [Console]::IsOutputRedirected) {
$DockerArgs += "-it"
} elseif ([Console]::IsInputRedirected) {
$DockerArgs += "-i"
$DockerArgs += "-t"
}
$DockerArgs += @(