Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(windows): route the ps1 wrapper's native host commands to the Windows client

AkitaOnRailsf37023956ad5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d052ac1..7a7d5377 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,24 @@ version in [`docs/changelog/`](docs/changelog/):
traces to rank-boundary questions that flip between identical runs, not
a deterministic ranking change (#1580).
+- Fixed `ai-memory run` (and `show`, `continue`, `resume`, `workstreams`,
+ `rename-workstream`) failing on Windows Docker installs with "managed
+ claude executable `claude` was not found in the host PATH": the PowerShell
+ wrapper sent every subcommand into the Linux helper container, which has no
+ host CLIs. It now intercepts the same six commands `bin/ai-memory` does and
+ runs them through the native Windows client, resolved from
+ `AI_MEMORY_NATIVE_BIN` or the documented
+ `%LOCALAPPDATA%\Programs\ai-memory` install location, inheriting
+ `AI_MEMORY_SERVER_URL` (an explicit value wins) and exiting with the
+ child's code. A missing client fails with the documented installer command
+ instead of entering the container; the POSIX wrapper's Git Bash refusal
+ points at the same installer; and the missing-harness error's Docker
+ advice is now OS-aware: on Windows it names the native-client installer
+ rather than `ai-memory upgrade`, which in the `.ps1` wrapper only pulls
+ the image. Managed launches keep the hook/MCP wiring rendered through the
+ container (the wrapper sets `AI_MEMORY_RUN_AUTOWIRE=false` for the
+ intercepted commands unless the operator set it). (#1545)
+
## [3.2.0] - 2026-10-21
### Added
diff --git a/bin/ai-memory b/bin/ai-memory
index 811fe250..d85d9292 100755
--- a/bin/ai-memory
+++ b/bin/ai-memory
@@ -498,6 +498,15 @@ native_host_binary() {
case "$(uname -s 2>/dev/null || true)" in
Linux) os="linux" ;;
Darwin) os="macos" ;;
+ MINGW* | MSYS* | CYGWIN*)
+ # Git Bash on native Windows: no Linux/macOS release client exists, and
+ # the helper container cannot run host harnesses anyway. Point at the
+ # two supported paths instead of a bare refusal (#1545).
+ echo "ai-memory: the POSIX container wrapper cannot run host commands on native Windows" >&2
+ echo "use the PowerShell wrapper (bin/ai-memory.ps1) or install the native Windows client:" >&2
+ echo " irm https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1 | iex" >&2
+ return 1
+ ;;
*)
echo "ai-memory: the container wrapper cannot provide native host commands on this OS" >&2
echo "install the native release binary to use managed launches or native lifecycle hooks" >&2
diff --git a/bin/ai-memory.ps1 b/bin/ai-memory.ps1
index 5a22b1d2..adb43e16 100644
--- a/bin/ai-memory.ps1
+++ b/bin/ai-memory.ps1
@@ -6,6 +6,11 @@
#
# The wrapper tells the Linux container to render Windows PowerShell hook
# commands that point at the host's staged .ps1 scripts.
+#
+# Managed launch commands (run, show, continue, resume, workstreams,
+# rename-workstream) never enter the container: they run through the
+# native Windows client instead, mirroring the intercept bin/ai-memory
+# does (see the native-host branch below).
[CmdletBinding()]
param(
[Parameter(ValueFromRemainingArguments = $true)]
@@ -50,6 +55,77 @@ $Image = Get-EnvOrDefault "AI_MEMORY_IMAGE" "akitaonrails/ai-memory:latest"
$Docker = Get-EnvOrDefault "AI_MEMORY_DOCKER" "docker"
$DataVolume = Get-EnvOrDefault "AI_MEMORY_DATA_VOLUME" "ai-memory-data"
+# Managed launch/discovery commands execute on the host: checkouts, harness
+# CLIs and native transcript stores are host resources the Linux helper
+# container cannot see (it has no claude/codex). Mirror the intercept in
+# bin/ai-memory (the same six subcommands, kept in sync by tests) and run
+# them through the native Windows client. These commands never touch the
+# container engine, so this branch sits above the engine check below.
+$NativeHostCommands = @(
+ "run",
+ "show",
+ "continue",
+ "resume",
+ "workstreams",
+ "rename-workstream"
+)
+
+# Resolve the native client: AI_MEMORY_NATIVE_BIN wins when it exists,
+# otherwise the documented install location: install.ps1 (docs/windows.md,
+# Scenario C) unpacks the release zip to %LOCALAPPDATA%\Programs\ai-memory.
+function Get-NativeHostBin {
+ $Explicit = [Environment]::GetEnvironmentVariable("AI_MEMORY_NATIVE_BIN")
+ if (-not [string]::IsNullOrWhiteSpace($Explicit)) {
+ if (-not (Test-Path -LiteralPath $Explicit -PathType Leaf)) {
+ Write-Error "ai-memory: AI_MEMORY_NATIVE_BIN does not point at an existing ai-memory.exe: $Explicit"
+ exit 127
+ }
+ $Resolved = [IO.Path]::GetFullPath($Explicit)
+ # Handing the wrapper itself back as the client would recurse through
+ # this same intercept forever (bin/ai-memory refuses its own path too).
+ foreach ($SelfPath in @($PSCommandPath, (Join-Path $PSScriptRoot "ai-memory.cmd"))) {
+ if ($SelfPath -and (Test-Path -LiteralPath $SelfPath -PathType Leaf) -and
+ ([IO.Path]::GetFullPath($SelfPath) -ieq $Resolved)) {
+ Write-Error "ai-memory: AI_MEMORY_NATIVE_BIN points at the container wrapper itself; point it at the native release ai-memory.exe"
+ exit 127
+ }
+ }
+ return $Resolved
+ }
+ if ($env:LOCALAPPDATA) {
+ $DefaultBin = Join-Path (Join-Path $env:LOCALAPPDATA "Programs") "ai-memory\ai-memory.exe"
+ if (Test-Path -LiteralPath $DefaultBin -PathType Leaf) {
+ return $DefaultBin
+ }
+ $Expected = $DefaultBin
+ } else {
+ $Expected = "%LOCALAPPDATA%\Programs\ai-memory\ai-memory.exe"
+ }
+ Write-Error "ai-memory: the native host client was not found (expected at $Expected). Managed launch commands (run, show, continue, resume, workstreams, rename-workstream) execute host harnesses through the native Windows client, not the Linux helper container. Install it with: irm https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1 | iex (docs/windows.md), or point AI_MEMORY_NATIVE_BIN at an existing ai-memory.exe."
+ exit 127
+}
+
+if ((Get-WrapperSubcommand $CommandArgs) -in $NativeHostCommands) {
+ $NativeBin = Get-NativeHostBin
+ # The intercepted commands run on the host, so AI_MEMORY_SERVER_URL is
+ # inherited untouched: the client's own default (http://127.0.0.1:49374)
+ # already reaches the port Docker Desktop publishes there; an explicit
+ # value wins, the same precedence bin/ai-memory gives its native host
+ # commands. The host.docker.internal alias is only for the helper
+ # container path below.
+ #
+ # Hooks and MCP keep the wiring install-hooks/install-mcp rendered through
+ # the container (windows-platform entries). A native-side autowire would
+ # re-render them around this separately installed client, and could not
+ # read the named volume's auth token from the host either, so run must
+ # not rewire harness config unless the operator opted in (#1545).
+ if ($null -eq [Environment]::GetEnvironmentVariable("AI_MEMORY_RUN_AUTOWIRE")) {
+ $env:AI_MEMORY_RUN_AUTOWIRE = "false"
+ }
+ & $NativeBin @CommandArgs
+ exit $LASTEXITCODE
+}
+
if (-not (Get-Command $Docker -ErrorAction SilentlyContinue)) {
Write-Error "Could not find Docker command '$Docker'. Install Docker Desktop or set AI_MEMORY_DOCKER."
exit 127
@@ -57,7 +133,17 @@ if (-not (Get-Command $Docker -ErrorAction SilentlyContinue)) {
if ($CommandArgs.Count -gt 0 -and $CommandArgs[0] -eq "upgrade") {
& $Docker pull $Image
- exit $LASTEXITCODE
+ if ($LASTEXITCODE -ne 0) {
+ exit $LASTEXITCODE
+ }
+ # Pulling the image refreshes only one of three pieces. The wrapper
+ # scripts are refreshed by re-running the Scenario B install snippet in
+ # docs/windows.md, and the native client used by run/show/... upgrades
+ # itself with its own subcommand (docs/windows.md, Scenario C).
+ Write-Output "Refreshed the container image only."
+ Write-Output " wrapper scripts: re-run the install snippet in docs/windows.md (Scenario B)"
+ Write-Output " native client: ai-memory.exe upgrade (docs/windows.md, Scenario C)"
+ exit 0
}
$HomePath = (Resolve-Path -LiteralPath $HOME).Path
diff --git a/crates/ai-memory-cli/src/commands/run.rs b/crates/ai-memory-cli/src/commands/run.rs
index 7445f72e..608cd6e9 100644
--- a/crates/ai-memory-cli/src/commands/run.rs
+++ b/crates/ai-memory-cli/src/commands/run.rs
@@ -3501,12 +3501,26 @@ fn ensure_executable_available(
return Ok(());
}
Err(anyhow!(
- "managed {} executable `{}` was not found in the host PATH; install it or pass `--executable`. Docker users should run `ai-memory upgrade` to refresh the host wrapper",
+ "managed {} executable `{}` was not found in the host PATH; install it or pass `--executable`. {}",
harness.as_str(),
- program.to_string_lossy()
+ program.to_string_lossy(),
+ docker_host_client_hint(),
))
}
+/// The Docker-wrapper advice appended to a missing-harness error, split by OS
+/// because the two wrappers upgrade differently (#1545): the POSIX wrapper's
+/// `upgrade` re-downloads its checksum-verified native host client, while the
+/// PowerShell wrapper's `upgrade` only pulls the image, so a Windows Docker
+/// user needs the native client's installer instead.
+fn docker_host_client_hint() -> &'static str {
+ if cfg!(windows) {
+ "Docker Desktop users: managed launches run through the native Windows client, not the container; install it with `irm https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1 | iex` (docs/windows.md)"
+ } else {
+ "Docker users should run `ai-memory upgrade` to refresh the host wrapper"
+ }
+}
+
/// Whether this harness's default executable resolves through `PATH`.
///
/// Shared with `show`, so the picker offers exactly the harnesses that
diff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rs
index 13109a2d..af3dab7d 100644
--- a/crates/ai-memory-cli/tests/suite/packaging.rs
+++ b/crates/ai-memory-cli/tests/suite/packaging.rs
@@ -1276,6 +1276,77 @@ fn powershell_wrapper_trims_paths_with_single_character_separators() {
);
}
+// The helper container has no host harnesses, so both Docker wrappers
+// intercept the managed launch/discovery commands and run them through a
+// native client on the host (#1545). The two lists must stay identical, and
+// every surface that refuses or explains a missing client must point at the
+// same documented Windows installer.
+#[test]
+fn docker_wrappers_intercept_the_same_native_host_commands() {
+ let expected = [
+ "run",
+ "show",
+ "continue",
+ "resume",
+ "workstreams",
+ "rename-workstream",
+ ];
+
+ let posix = read_repo("bin/ai-memory");
+ let case_line = posix
+ .lines()
+ .find(|line| {
+ line.starts_with(" run | show | continue | resume | workstreams | rename-workstream)")
+ })
+ .expect("POSIX wrapper native host command case arm");
+ let posix_list: Vec<&str> = case_line
+ .trim()
+ .trim_end_matches(')')
+ .split('|')
+ .map(str::trim)
+ .collect();
+ assert_eq!(posix_list, expected, "POSIX wrapper intercept list drifted");
+
+ let powershell = read_repo("bin/ai-memory.ps1");
+ let (array_body, _) = powershell
+ .split_once("$NativeHostCommands = @(")
+ .expect("PowerShell wrapper native host command array")
+ .1
+ .split_once(')')
+ .expect("PowerShell wrapper native host command array terminator");
+ let ps1_list: Vec<&str> = array_body
+ .lines()
+ .filter_map(|line| {
+ let item = line.trim().trim_end_matches(',').trim();
+ item.strip_prefix('"')?.strip_suffix('"')
+ })
+ .collect();
+ assert_eq!(
+ ps1_list, expected,
+ "PowerShell wrapper must intercept exactly the commands bin/ai-memory does"
+ );
+
+ let installer =
+ "https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1";
+ assert!(
+ powershell.contains(installer),
+ "the PowerShell wrapper's missing-client refusal must name the documented installer"
+ );
+ assert!(
+ posix.contains(installer),
+ "the POSIX wrapper's native-Windows refusal must name the documented installer"
+ );
+ let run_cmd = read_repo("crates/ai-memory-cli/src/commands/run.rs");
+ assert!(
+ run_cmd.contains(installer),
+ "the Windows missing-harness advice must name the documented installer"
+ );
+ assert!(
+ run_cmd.contains("Docker users should run `ai-memory upgrade` to refresh the host wrapper"),
+ "the non-Windows missing-harness advice must stay on `ai-memory upgrade`"
+ );
+}
+
// The PowerShell counterpart of run_wrapper_on_fake_macos: a fake `docker.cmd`
// records the argv the wrapper built. No `uname` shadowing is needed because
// the Windows arm under test is selected by running on Windows at all.
@@ -1326,6 +1397,77 @@ fn run_powershell_wrapper_with_server_url(args: &[&str], server_url: Option<&str
std::fs::read_to_string(docker_args).unwrap()
}
+/// Runs `bin/ai-memory.ps1` with a fake native client (`AI_MEMORY_NATIVE_BIN`)
+/// and a fake container engine, returning the wrapper's exit code plus what
+/// each side saw. Native-host commands must reach only the native client, so
+/// an empty engine log is itself an assertion input; the fake client exits
+/// with a marker code so the wrapper's exit-code pass-through is visible.
+#[cfg(windows)]
+fn run_powershell_wrapper_with_fake_native(
+ args: &[&str],
+ extra_env: &[(&str, &str)],
+) -> (Option<i32>, String, String) {
+ let tmp = tempfile::tempdir().unwrap();
+ let native_args = tmp.path().join("native-args.txt");
+ let docker_args = tmp.path().join("docker-args.txt");
+ let native = tmp.path().join("native.cmd");
+ std::fs::write(
+ &native,
+ concat!(
+ "@echo off\r\n",
+ ">>\"%AI_MEMORY_TEST_NATIVE_ARGS%\" echo argv: %*\r\n",
+ "if defined AI_MEMORY_SERVER_URL ",
+ ">>\"%AI_MEMORY_TEST_NATIVE_ARGS%\" echo server-url: %AI_MEMORY_SERVER_URL%\r\n",
+ "if not defined AI_MEMORY_SERVER_URL ",
+ ">>\"%AI_MEMORY_TEST_NATIVE_ARGS%\" echo server-url: unset\r\n",
+ "if defined AI_MEMORY_RUN_AUTOWIRE ",
+ ">>\"%AI_MEMORY_TEST_NATIVE_ARGS%\" echo autowire: %AI_MEMORY_RUN_AUTOWIRE%\r\n",
+ "if not defined AI_MEMORY_RUN_AUTOWIRE ",
+ ">>\"%AI_MEMORY_TEST_NATIVE_ARGS%\" echo autowire: unset\r\n",
+ "exit /b %AI_MEMORY_TEST_NATIVE_EXIT%\r\n",
+ ),
+ )
+ .unwrap();
+ let docker = tmp.path().join("docker.cmd");
+ std::fs::write(
+ &docker,
+ "@echo off\r\n>>\"%AI_MEMORY_TEST_DOCKER_ARGS%\" echo %*\r\nexit /b 0\r\n",
+ )
+ .unwrap();
+
+ let mut command = Command::new(ai_memory_test_support::powershell_exe());
+ command
+ // Same execution-policy note as run_powershell_wrapper above.
+ .args([
+ "-NoLogo",
+ "-NoProfile",
+ "-NonInteractive",
+ "-ExecutionPolicy",
+ "Bypass",
+ "-File",
+ ])
+ .arg(repo_root().join("bin/ai-memory.ps1"))
+ .args(args)
+ .env("AI_MEMORY_DOCKER", &docker)
+ .env("AI_MEMORY_NATIVE_BIN", &native)
+ .env("AI_MEMORY_TEST_NATIVE_ARGS", &native_args)
+ .env("AI_MEMORY_TEST_NATIVE_EXIT", "7")
+ .env("AI_MEMORY_TEST_DOCKER_ARGS", &docker_args)
+ .env("AI_MEMORY_DATA_VOLUME", "test-ai-memory-data")
+ .env_remove("AI_MEMORY_DATA_DIR")
+ .env_remove("AI_MEMORY_SERVER_URL")
+ .env_remove("AI_MEMORY_RUN_AUTOWIRE");
+ for (name, value) in extra_env {
+ command.env(name, value);
+ }
+ let output = command.output().unwrap();
+ (
+ output.status.code(),
+ std::fs::read_to_string(&native_args).unwrap_or_default(),
+ std::fs::read_to_string(&docker_args).unwrap_or_default(),
+ )
+}
+
#[test]
fn macos_docs_use_valid_install_commands_and_release_body_points_to_them() {
let docs = read_repo("docs/macos.md");
@@ -3403,6 +3545,135 @@ mod slow {
);
}
+ // #1545: the helper container has no host harnesses, so the managed
+ // launch/discovery commands must run through the native Windows client —
+ // never the container engine — with the child's exit code preserved.
+ #[cfg(windows)]
+ #[test]
+ fn windows_wrapper_routes_native_host_commands_through_the_native_client() {
+ let cases: &[&[&str]] = &[
+ &["run", "claude"],
+ &["run", "--new", "docs", "codex"],
+ &["show", "--json"],
+ &["continue", "--yolo"],
+ &["resume"],
+ &["workstreams", "--limit", "5"],
+ &[
+ "rename-workstream",
+ "--from",
+ "typo-nmae",
+ "--to",
+ "refactor-db",
+ ],
+ // Global options precede the subcommand in real invocations too.
+ &["--config", "C:\\tmp\\config.toml", "run", "codex"],
+ ];
+ for args in cases {
+ let (code, native_log, docker_log) = run_powershell_wrapper_with_fake_native(args, &[]);
+ assert_eq!(
+ code,
+ Some(7),
+ "wrapper must exit with the native client's code for {args:?}"
+ );
+ assert!(
+ native_log.contains(&format!("argv: {}", args.join(" "))),
+ "native client must receive the full argv for {args:?}; got {native_log}"
+ );
+ assert!(
+ docker_log.is_empty(),
+ "native host command {args:?} must not reach the container engine; got {docker_log}"
+ );
+ }
+
+ // The child inherits AI_MEMORY_SERVER_URL untouched: unset means the
+ // client's own host-loopback default applies (never the container's
+ // host.docker.internal alias), and an explicit value wins.
+ let (_, native_log, _) = run_powershell_wrapper_with_fake_native(&["run", "claude"], &[]);
+ assert!(
+ native_log.contains("server-url: unset"),
+ "the wrapper must not inject a server URL into native host commands; got {native_log}"
+ );
+ assert!(
+ native_log.contains("autowire: false"),
+ "the wrapper must keep container-rendered wiring authoritative unless the \
+ operator set AI_MEMORY_RUN_AUTOWIRE; got {native_log}"
+ );
+
+ let (_, native_log, _) = run_powershell_wrapper_with_fake_native(
+ &["run", "claude"],
+ &[("AI_MEMORY_SERVER_URL", "http://192.168.1.50:49374")],
+ );
+ assert!(
+ native_log.contains("server-url: http://192.168.1.50:49374"),
+ "an explicit AI_MEMORY_SERVER_URL must reach the native client; got {native_log}"
+ );
+
+ let (_, native_log, _) = run_powershell_wrapper_with_fake_native(
+ &["run", "claude"],
+ &[("AI_MEMORY_RUN_AUTOWIRE", "true")],
+ );
+ assert!(
+ native_log.contains("autowire: true"),
+ "an explicit AI_MEMORY_RUN_AUTOWIRE must win; got {native_log}"
+ );
+ }
+
+ // Without the native client the wrapper must refuse clearly (pointing at
+ // the documented installer) instead of silently falling back to the
+ // helper container, where the command used to die with a misleading
+ // "executable not found in the host PATH" (#1545).
+ #[cfg(windows)]
+ #[test]
+ fn windows_wrapper_refuses_native_host_commands_without_the_native_client() {
+ let tmp = tempfile::tempdir().unwrap();
+ let docker_args = tmp.path().join("docker-args.txt");
+ let docker = tmp.path().join("docker.cmd");
+ std::fs::write(
+ &docker,
+ "@echo off\r\n>>\"%AI_MEMORY_TEST_DOCKER_ARGS%\" echo %*\r\nexit /b 0\r\n",
+ )
+ .unwrap();
+
+ let mut command = Command::new(ai_memory_test_support::powershell_exe());
+ command
+ .args([
+ "-NoLogo",
+ "-NoProfile",
+ "-NonInteractive",
+ "-ExecutionPolicy",
+ "Bypass",
+ "-File",
+ ])
+ .arg(repo_root().join("bin/ai-memory.ps1"))
+ .args(["run", "claude"])
+ .env("AI_MEMORY_DOCKER", &docker)
+ .env("AI_MEMORY_TEST_DOCKER_ARGS", &docker_args)
+ // A temp LOCALAPPDATA holds no installed client, standing in for
+ // "the installer never ran" regardless of the host machine.
+ .env("LOCALAPPDATA", tmp.path())
+ .env_remove("AI_MEMORY_NATIVE_BIN")
+ .env_remove("AI_MEMORY_SERVER_URL");
+ let output = command.output().unwrap();
+ assert!(
+ !output.status.success(),
+ "a missing native client must fail instead of entering the container"
+ );
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ assert!(
+ stderr.contains("install.ps1"),
+ "the refusal must name the documented installer; got {stderr}"
+ );
+ assert!(
+ stderr.contains("AI_MEMORY_NATIVE_BIN"),
+ "the refusal must name the override; got {stderr}"
+ );
+ let docker_log = std::fs::read_to_string(&docker_args).unwrap_or_default();
+ assert!(
+ docker_log.is_empty(),
+ "a missing native client must not fall back to the container; got {docker_log}"
+ );
+ }
+
#[cfg(windows)]
#[test]
fn powershell_wrapper_forwards_subscription_oauth_tokens_without_putting_values_in_argv() {
diff --git a/docs/windows.md b/docs/windows.md
index 8c7ea77b..db3b7800 100644
--- a/docs/windows.md
+++ b/docs/windows.md
@@ -162,6 +162,44 @@ After upgrading the wrapper/image, rerun `install-hooks --agent <agent> --apply`
for each native Windows agent so existing hook entries receive the current
command form.
+### Managed launches (`run`, `continue`, `show`, …) use the native client
+
+`ai-memory run <harness>`, `continue`, `resume`, `show`, `workstreams` and
+`rename-workstream` execute on the host: the helper container cannot see your
+checkouts, your `claude` or `codex` CLIs, or their native session stores. The
+wrapper intercepts those subcommands and runs the native Windows client
+instead of the container (the same interception the Linux/macOS wrapper
+performs), so managed launches work while the server stays in Docker.
+
+The Docker image and the wrapper do not install that client. Install it once
+from the release zip
+([Scenario C](#scenario-c-prebuilt-release-binary-no-toolchain)):
+
+```powershell
+irm https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1 | iex
+```
+
+`install.ps1` unpacks `ai-memory.exe` to `%LOCALAPPDATA%\Programs\ai-memory`
+and puts that directory on your `PATH`; the wrapper finds it there, or
+wherever `AI_MEMORY_NATIVE_BIN` points. Without it the intercepted commands
+stop with a message naming that installer. They never fall back into the
+container, which has no host CLIs.
+
+- The native client inherits `AI_MEMORY_SERVER_URL`. Leave it unset and it
+ talks to `http://127.0.0.1:49374`, the port the container publishes on the
+ host; a remote-server URL wins, as with every other wrapper command.
+- A managed launch does not rewire hooks or MCP: what `install-hooks` and
+ `install-mcp` rendered through the container stays in place (the wrapper
+ sets `AI_MEMORY_RUN_AUTOWIRE=false` for the intercepted commands unless you
+ set the variable yourself). Export `AI_MEMORY_RUN_AUTOWIRE=true` to let
+ `run` rewire a harness around the native client instead.
+- Upgrading in this scenario: `ai-memory upgrade` pulls the image only. It
+ does not refresh the wrapper or install a native client. Refresh the
+ wrapper scripts by re-running the install block at the top of this
+ scenario, and the native client with its own `ai-memory.exe upgrade`
+ ([Scenario C](#scenario-c-prebuilt-release-binary-no-toolchain)). Then
+ rerun `install-hooks --agent <agent> --apply` as noted above.
+
Use the matching `--client` / `--agent` values for other clients, for
example `codex`, `command-code`, `devin`, `kimi-code`, `kiro-cli`, `cursor`, or `gemini-cli`.
diff --git a/scripts/check-native-packaging.sh b/scripts/check-native-packaging.sh
index c1b69543..18c321cf 100755
--- a/scripts/check-native-packaging.sh
+++ b/scripts/check-native-packaging.sh
@@ -182,6 +182,22 @@ main() {
fail "AI_MEMORY_NATIVE_BIN pointing to the wrapper must be refused instead of recursing"
fi
+ log "Checking the PowerShell wrapper intercepts the same native host commands"
+ # bin/ai-memory.ps1 routes run/show/continue/resume/workstreams/rename-
+ # workstream to the native Windows client (#1545). Its list must match the
+ # POSIX wrapper's intercept exactly, and both must point a missing client
+ # at the documented Windows installer. Static only: this script has no pwsh.
+ local posix_list ps1_list
+ posix_list="$(grep -m1 '^ run | show | continue | resume | workstreams | rename-workstream)' bin/ai-memory \
+ | sed 's/^ *//; s/)$//' | tr '|' ' ' | tr -s ' ' '\n' | sort | paste -sd' ' -)"
+ ps1_list="$(sed -n '/^\$NativeHostCommands = @($/,/^)$/p' bin/ai-memory.ps1 \
+ | grep -o '"[a-z-]*"' | tr -d '"' | sort | paste -sd' ' -)"
+ test -n "${posix_list}" || fail "could not extract the native host command list from bin/ai-memory"
+ test "${posix_list}" = "${ps1_list}" \
+ || fail "native host command lists drifted between bin/ai-memory (${posix_list}) and bin/ai-memory.ps1 (${ps1_list})"
+ assert_contains bin/ai-memory.ps1 "https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1"
+ assert_contains bin/ai-memory "https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1"
+
log "Checking the wrapper hands host commands the volume's root bearer"
# New-install default: a server initialized on the named volume keeps its token at
# /data/auth-tokens/default. Host-native commands must receive it as a