mirror of
https://github.com/akitaonrails/ai-memory.git
synced 2026-10-02 03:24:46 +08:00
fix(wrapper): preserve stdin across every output mode
This commit is contained in:
+5
-8
@@ -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
@@ -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 += @(
|
||||
|
||||
Reference in New Issue
Block a user