Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(opencode): add dispose handler to close sessions on shutdown
Luiz Fernandoe6c6032f5010
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rsindex 2ee4fd75..0bbf8721 100644--- a/crates/ai-memory-cli/src/commands/install_hooks.rs+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs@@ -1353,6 +1353,12 @@ async function fetchHandoff(cwd: string): Promise<string | undefined> {{export const AiMemoryHooks: Plugin = async ({{ directory }}) => {{return {{+ dispose: async () => {{+ for (const id of startedSessions) {{+ postHook("session-end", {{ sessionID: id, cwd: cwdFor(id, directory) }});+ }}+ startedSessions.clear();+ }},event: async (input) => {{const event = (input as any).event;const properties = event?.properties ?? {{}};@@ -3248,6 +3254,7 @@ model = "gpt-5"));assert!(plugin.contains("applyMarkerParams(url, cwd);"));assert!(plugin.contains("postPreCompact"));+ assert!(plugin.contains("dispose: async () =>"));assert!(plugin.contains("postHook(\"session-start\""));assert!(plugin.contains(r#""session.deleted")"#));assert!(plugin.contains("postHook(\"session-end\""));