Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(install-hooks): invoke the Grok hook command with PowerShell's call operator on Windows
João Carlos Magalhães871d0b6e61bc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 815328ed..32f42a02 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0query before falling back. (#873)### Fixed+- Grok Build CLI hooks capture on Windows again. Grok evaluates+ `~/.grok/hooks/*.json` commands with PowerShell, as Codex does (#515), so+ the double-quoted executable path in command position parsed as a string+ expression and every hook exited 1 with a ParserError: sessions ran with+ the hook installed and nothing was captured. The Windows command now+ carries PowerShell's `&` call operator for Grok too; re-run+ `ai-memory install-hooks --agent grok --apply` to rewrite an existing+ install. (#887)- The Linux/macOS Docker wrapper now keeps its native host client in`${XDG_DATA_HOME:-~/.local/share}/ai-memory/native-runner` instead of`~/.cache/ai-memory/native-runner`. `ai-memory run` auto-wires hooks whosediff --git a/crates/ai-memory-cli/src/commands/render_shared.rs b/crates/ai-memory-cli/src/commands/render_shared.rsindex d6c6374f..6293edcf 100644--- a/crates/ai-memory-cli/src/commands/render_shared.rs+++ b/crates/ai-memory-cli/src/commands/render_shared.rs@@ -1769,7 +1769,15 @@ fn powershell_quote(s: &str) -> String {fn powershell_call_operator(agent: &str) -> &'static str {// Codex evaluates `~/.codex/hooks.json` command strings with PowerShell// on Windows (#515, reproduced against Codex CLI on a native install).- if agent == "codex" { "& " } else { "" }+ // Grok Build CLI does the same for `~/.grok/hooks/*.json` (observed on+ // Grok 1.0.41: every ai-memory hook failed with a ParserError in the+ // session's `hook_execution` updates, and its hooks guide documents the+ // PowerShell `$VAR` rewrite).+ if matches!(agent, "codex" | "grok") {+ "& "+ } else {+ ""+ }}fn win_double_quote(s: &str) -> String {@@ -1795,6 +1803,22 @@ fn codex_windows_command_invokes_rather_than_quotes() {);}+/// Grok runs its Windows hooks through PowerShell like Codex, so every+/// ai-memory hook failed to parse and captured nothing.+#[test]+fn grok_windows_command_invokes_rather_than_quotes() {+ let cmd = hook_command(+ Path::new("stop.sh"),+ "http://127.0.0.1:49374",+ None,+ HookCommandContext::new(HookCommandPlatform::WindowsNative, "grok", None, None),+ );+ assert!(+ cmd.starts_with("& \""),+ "grok must use the call operator: {cmd}"+ );+}+#[test]fn claude_code_windows_command_is_unchanged_by_the_codex_fix() {let cmd = hook_command(