Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(windows): stop the PS wrapper crashing outside a git repo (#591)
AkitaOnRails1ec5cf165dcc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0c58caab..1d12d6fc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Fixed+- The Windows PowerShell wrapper (`ai-memory.ps1`) no longer crashes with+ `git.exe : fatal: not a git repository … NativeCommandError` when run+ outside a git repository — which broke `ai-memory status` and every+ non-repo invocation (#591). The wrapper's script-global+ `$ErrorActionPreference = 'Stop'` turned the repo-root probe's+ *redirected* native stderr into a terminating error under Windows+ PowerShell 5.1; the probe now runs under a localized+ `SilentlyContinue`, gates on `$LASTEXITCODE`, and restores the+ preference, falling back to the working directory as before. The+ unredirected Docker invocations were never affected.+## [2.0.1] - 2026-09-02### Fixeddiff --git a/bin/ai-memory.ps1 b/bin/ai-memory.ps1index 0c860a1d..abd25adc 100644--- a/bin/ai-memory.ps1+++ b/bin/ai-memory.ps1@@ -79,9 +79,23 @@ if ($InsideHome) {} else {$ScopeRoot = $WorkPathif (Get-Command git -ErrorAction SilentlyContinue) {- $DetectedScopeRoot = (& git -C $WorkPath rev-parse --show-toplevel 2>$null)- if (-not [string]::IsNullOrWhiteSpace($DetectedScopeRoot)) {- $ScopeRoot = [IO.Path]::GetFullPath($DetectedScopeRoot.Trim())+ # Probe for the repo root, but never let git's "not a git+ # repository" message abort the wrapper. Under this script's+ # $ErrorActionPreference = 'Stop', Windows PowerShell 5.1 turns a+ # REDIRECTED native stderr (the 2>$null below) into a *terminating*+ # error, so running `status` outside a repo crashed the wrapper+ # (#591). Suppress locally, gate on the exit code, and restore. The+ # unredirected `& $Docker` calls are unaffected, which is why only+ # this probe tripped it.+ $PrevErrorAction = $ErrorActionPreference+ $ErrorActionPreference = 'SilentlyContinue'+ try {+ $DetectedScopeRoot = (& git -C $WorkPath rev-parse --show-toplevel 2>$null)+ if ($LASTEXITCODE -eq 0 -and -not [string]::IsNullOrWhiteSpace($DetectedScopeRoot)) {+ $ScopeRoot = [IO.Path]::GetFullPath($DetectedScopeRoot.Trim())+ }+ } finally {+ $ErrorActionPreference = $PrevErrorAction}}$ScopeRoot = $ScopeRoot.TrimEnd([char[]]@('/', '\'))