Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge PR #723: warn about Cursor hook wrappers that mention ai-memory (#721)
AkitaOnRailseada8e4e4ef3
diff --cc CHANGELOG.mdindex 565f246b,219b4d87..5ba6fce2--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -7,45 -7,12 +7,50 @@@ and this project adheres to [Semantic V## [Unreleased]+### Security+- Updated `rustls` 0.23.40 → 0.23.45 for [RUSTSEC-2026-0285](https://rustsec.org/advisories/RUSTSEC-2026-0285),+ in which a TLS 1.3 handshake message that follows a key-changing message in+ the same record can be accepted at the wrong encryption level. `rustls` is a+ direct dependency — it installs the process-wide crypto provider the MCP+ bridge needs for HTTPS — and is also the TLS implementation every outbound+ HTTPS call resolves to through reqwest, so the advisory failed `cargo audit`+ and `cargo deny check` on every open pull request that inherited `main`'s+ lockfile, including ones that change no Rust at all. `Cargo.toml` already+ allows compatible 0.23 patch releases, so this is a lockfile-only change+ needing no manifest or public-surface edit; the same resolution moves+ `rustls-webpki` 0.103.13 → 0.103.15 and nothing else (#731).+### Fixed+- The native `ai-memory hook` session-id state file+ (`<data_dir>/hook-state/<agent>-session-id`), introduced for Devin in #178,+ now also covers ZCode. ZCode's hook payloads do not reliably carry a session+ id, it fires `Stop` at the end of every turn, and it has no `SessionEnd`+ event — without a persisted id, each turn with an id-less payload opened a+ fresh server-side session that nothing ever closed (observed in production:+ 4 sessions with NULL `ended_at` and 398 observations stuck in episodic).+ ZCode events without a native id now share one stable stored id per agent+ session; events carrying a native id are passed through untouched. The stored+ id is cleared by `finalize-session --agent zcode` (which now also removes the+ state file) or overwritten by the next `session-start`; `Stop` never clears+ it. Other agents are unaffected: payloads that carry a session id short-circuit+ the state file exactly as before.+- `memory_feedback`'s `signal` (FeedbackKind) JSON schema now declares a+ top-level `type: "string"`, so strict function-calling gateways (Moonshot/Kimi+ and other schema validators) accept the `tools/list` surface instead of+ rejecting the enum for a missing type (#735, #741).+- Cursor lifecycle events are no longer stored twice on a host where both+ `install-hooks --agent cursor` and `install-hooks --agent claude-code` are+ applied. Cursor also runs the commands in Claude Code's settings, and since+ 2.1.0 that copy is re-attributed to `cursor` by its `cursor_version`, so it+ landed in the same session as the native event. The `--agent claude-code`+ hook now drops a Cursor-marked payload when `~/.cursor/hooks.json` already+ registers an ai-memory `--agent cursor` hook; without Cursor's own hooks the+ Claude Code path keeps capturing Cursor sessions as before (#721).+ - `install-hooks --agent cursor --apply` now warns about existing+ `~/.cursor/hooks.json` entries that mention ai-memory but are not ai-memory+ hook entries, such as a pre-2.1.0 shim that injected `cwd`. Those entries+ are kept beside the native ones, so every event would otherwise be captured+ twice without any sign (#721).## [2.2.1] - 2026-09-12diff --cc crates/ai-memory-cli/src/commands/install_hooks.rsindex 93f2d2e7,416d490f..55072aa5--- a/crates/ai-memory-cli/src/commands/install_hooks.rs+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs@@@ -9030,50 -9017,37 +9081,81 @@@ model = "gpt-5);}+ #[test]+ fn cursor_native_hooks_detection_requires_an_ai_memory_cursor_entry() {+ let tmp = TempDir::new().unwrap();+ let path = tmp.path().join("hooks.json");+ assert!(!cursor_native_hooks_installed_in(&path), "missing file");++ fs::write(&path, "not json").unwrap();+ assert!(!cursor_native_hooks_installed_in(&path), "malformed file");++ fs::write(+ &path,+ r#"{"version":1,"hooks":{"sessionStart":[+ {"command":"/opt/third-party","args":["--agent","cursor"]},+ {"command":"/usr/bin/ai-memory","args":["hook","--event","session-start","--agent","claude-code","--server-url","http://h"]}+ ]}}"#,+ )+ .unwrap();+ assert!(+ !cursor_native_hooks_installed_in(&path),+ "third-party or non-cursor entries do not count"+ );++ fs::write(+ &path,+ r#"{"version":1,"hooks":{"stop":[+ {"command":"/usr/bin/ai-memory","args":["hook","--event","stop","--agent","cursor","--server-url","http://h"]}+ ]}}"#,+ )+ .unwrap();+ assert!(cursor_native_hooks_installed_in(&path), "exec form");++ fs::write(+ &path,+ r#"{"version":1,"hooks":{"stop":[+ {"command":"/usr/bin/ai-memory hook --event stop --agent cursor --server-url http://h"}+ ]}}"#,+ )+ .unwrap();+ assert!(+ cursor_native_hooks_installed_in(&path),+ "command-string form"+ );+ }++ #[test]+ fn unrecognized_ai_memory_hook_entries_flags_wrappers_only() {+ let root = serde_json::json!({+ "version": 1,+ "hooks": {+ "sessionStart": [+ {"command": "/usr/bin/ai-memory", "args": ["hook", "--event", "session-start", "--agent", "cursor", "--server-url", "http://h"]},+ {"command": "~/bin/ai-memory-cwd-shim.sh session-start"},+ {"command": "/opt/other-tool --flag"}+ ],+ "stop": [+ {"matcher": "", "hooks": [{"command": "/home/u/.local/ai_memory_wrap stop"}]}+ ]+ }+ });+ let found = unrecognized_ai_memory_hook_entries(&root);+ assert_eq!(+ found,+ vec![+ (+ "sessionStart".to_string(),+ "~/bin/ai-memory-cwd-shim.sh session-start".to_string()+ ),+ (+ "stop".to_string(),+ "/home/u/.local/ai_memory_wrap stop".to_string()+ ),+ ]+ );+ }+#[test]fn cursor_apply_is_idempotent() {let hooks_tmp = TempDir::new().unwrap();