Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(workstream): match OpenCode's forward-slash directory in the checkout check
João Carlos Magalhães39b329ef926d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4bfd236d..14cdecf5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0feedback-loop guard stays non-overridable. (#894)### Fixed+- On Windows, `ai-memory run` recognises an OpenCode session as belonging+ to the current checkout again. `native_session_in_checkout` (#880) compared+ the stored `directory` with the backslash `cwd` exactly, while OpenCode+ stores forward slashes (#891), so the check never matched there; it now uses+ the same two spellings as the other OpenCode lookups (#882). (#906)- A manual `memory_consolidate` now reconciles the session's durableconsolidation job row. The MCP handler wrote the page directly through theconsolidator without touching `session_consolidation_jobs`, so a sessiondiff --git a/crates/ai-memory-workstream/src/transcript.rs b/crates/ai-memory-workstream/src/transcript.rsindex 5f8308c0..877bde0d 100644--- a/crates/ai-memory-workstream/src/transcript.rs+++ b/crates/ai-memory-workstream/src/transcript.rs@@ -257,9 +257,10 @@ pub fn native_session_in_checkout(OpenFlags::SQLITE_OPEN_READ_ONLY | OpenFlags::SQLITE_OPEN_NO_MUTEX,)?;let mut statement = connection.prepare(&format!(- "SELECT 1 FROM {table} WHERE id = ?1 AND directory = ?2"+ "SELECT 1 FROM {table} WHERE id = ?1 AND directory IN (?2, ?3)"))?;- Ok(statement.exists(params![native_session_id, cwd.to_string_lossy()])?)+ let (native, forward) = opencode_directories(cwd);+ Ok(statement.exists(params![native_session_id, native, forward])?)}/// Check whether one exact native session still exists in the harness's@@ -4335,7 +4336,8 @@ mod tests {// OpenCode records `C:/Users/me/repo`; the checkout path is// `C:\Users\me\repo`. Both the v1 and v2 stores are found from the native- // spelling, and a sibling directory still is not.+ // spelling, a session is recognised as this checkout's, and a sibling+ // directory still is not.#[cfg(windows)]#[test]fn opencode_stores_match_forward_slash_directories_on_windows() {@@ -4377,6 +4379,16 @@ mod tests {.map(|s| s.native_session_id.as_str()).collect();assert_eq!(ids, ["mine"], "{table}");+ let harness = if table == "session" {+ ManagedHarness::OpenCode+ } else {+ ManagedHarness::OpenCode2+ };+ let in_checkout = |id: &str| {+ native_session_in_checkout(harness, temp.path(), &cwd, Some(&db_root), id).unwrap()+ };+ assert!(in_checkout("mine"), "{table}");+ assert!(!in_checkout("sibling"), "{table}");}}