Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
feat(hooks): default native macOS/Linux Claude Code to the binary hook command
Djalma Júnior87300b96b126
diff --git a/bin/ai-memory b/bin/ai-memoryindex 88d4ba1b..6de029f8 100755--- a/bin/ai-memory+++ b/bin/ai-memory@@ -213,6 +213,13 @@ if [ -z "${AI_MEMORY_NO_TTY:-}" ] && [ -t 0 ] && [ -t 1 ]; thenTTY_ARGS=(-it)fi+# The CLI runs INSIDE the container but renders hook config for the HOST, which+# has no local ai-memory binary. Native installs default to `posix-native` (the+# binary hook command); the wrapper must NOT inherit that or it would bake the+# *container's* binary path into the host's hook config. Force the shell-script+# platform (`posix`) unless the operator chose one explicitly.+export AI_MEMORY_HOOK_PLATFORM="${AI_MEMORY_HOOK_PLATFORM:-posix}"+ENV_ARGS=()for var in \AI_MEMORY_SERVER_URL \diff --git a/crates/ai-memory-cli/src/commands/render_shared.rs b/crates/ai-memory-cli/src/commands/render_shared.rsindex 8e624ebc..29274931 100644--- a/crates/ai-memory-cli/src/commands/render_shared.rs+++ b/crates/ai-memory-cli/src/commands/render_shared.rs@@ -342,10 +342,11 @@ pub(crate) enum HookCommandPlatform {WindowsNative,/// POSIX (Linux/macOS), native: invoke the `ai-memory` binary directly/// (`<exe> hook --event …`) instead of the `.sh` script, so the hook gets- /// the local spool + OIDC-token fallback. **Opt-in** via- /// `AI_MEMORY_HOOK_PLATFORM=posix-native` — never the default, because the- /// Docker wrapper renders for the host with no local binary (it keeps the- /// `.sh` path). Use it when ai-memory is installed as a native binary.+ /// the local spool + OIDC-token fallback. The **default** for native+ /// Linux/macOS Claude Code installs (mirrors `WindowsNative`). The Docker+ /// wrapper forces `posix` so its host-rendered config keeps the `.sh` path+ /// (the host has no local binary). Override with+ /// `AI_MEMORY_HOOK_PLATFORM=posix` to get the shell scripts.PosixNative,}@@ -377,7 +378,10 @@ impl HookCommandPlatform {Ok(v) if v.eq_ignore_ascii_case("windows-native") => Self::WindowsNative,Ok(v) if v.eq_ignore_ascii_case("posix-native") => Self::PosixNative,_ if cfg!(windows) => Self::WindowsNative,- _ => Self::Posix,+ // Native macOS / Linux defaults to the binary hook command (spool ++ // OIDC), same as Windows. The Docker wrapper forces `posix` so its+ // host-rendered config keeps using the `.sh` scripts.+ _ => Self::PosixNative,}}}diff --git a/docs/windows.md b/docs/windows.mdindex de51e04e..7e03a1b2 100644--- a/docs/windows.md+++ b/docs/windows.md@@ -212,12 +212,13 @@ native on an i7-6700HQ). Notes:- `windows-native` — direct binary call (default on native Windows).- `windows-bash` — `bash -c` + `.sh` through Git Bash (the previousdefault; set this to opt back in).- - `posix` — POSIX `.sh` (default on macOS / Linux).+ - `posix` — POSIX `.sh`. The Docker-wrapper default (the host has no local+ binary); set it explicitly to opt a native install back into the scripts.- `posix-native` — direct binary call on macOS / Linux (`<exe> hook- --event …`) instead of the `.sh` script, so the hook uses the local- event spool + OIDC-token fallback. **Opt-in** (never the default,- because the Docker wrapper renders for the host with no local binary).- Set it when ai-memory is installed as a native binary (cargo / release).+ --event …`) instead of the `.sh` script, so the hook uses the local event+ spool + OIDC-token fallback. The **default for a native macOS / Linux+ install** (cargo / release binary), mirroring `windows-native`. The Docker+ wrapper forces `posix`, so its host-rendered config keeps the `.sh` scripts.Set the env var before running `install-hooks` so the chosen platformis baked into the rendered hook commands.