Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge main into PR #1451 after audited fixes
AkitaOnRailsde98a8d9db06
diff --cc CHANGELOG.mdindex 7d743c1e,6452a36a..ceed74c0--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -12,9 -12,41 +12,44 @@@ version in [`docs/changelog/`](docs/cha## [Unreleased]### Fixed+- Skipped H1-like comment lines inside fenced code when the importer derives+ page titles, including AgentMemory vault imports.+ ([#1451](https://github.com/akitaonrails/ai-memory/pull/1451))+ - Recognized importer frontmatter whose closing fence is the final line of a+ file without a trailing newline.+ ([#1450](https://github.com/akitaonrails/ai-memory/pull/1450))+ - Encoded spaces as `%20` instead of `+` in importer URL path segments,+ preserving workspace, project, and page names that contain spaces.+ ([#1449](https://github.com/akitaonrails/ai-memory/pull/1449))+ - Recognized exclamation-mark punctuation in short automatic-handoff+ acknowledgments such as `thanks!` and `perfect!`.+ ([#1448](https://github.com/akitaonrails/ai-memory/pull/1448))+ - Treated a blank `session_id` as omitted when starting an automatic+ improvement review, matching the other session-scoped MCP tools.+ ([#1447](https://github.com/akitaonrails/ai-memory/pull/1447))+ - Returned MCP `invalid_params` for caller-supplied invalid page paths, tiers,+ and scopes instead of misreporting them as internal server errors.+ ([#1445](https://github.com/akitaonrails/ai-memory/pull/1445))+ - Parsed an empty Markdown frontmatter block (`---` followed immediately by+ its closing fence) as frontmatter instead of folding it and later thematic+ breaks into the page body. ([#1444](https://github.com/akitaonrails/ai-memory/pull/1444))+ - Kept hook events whose JSON payload contains half of a UTF-16 surrogate pair+ as a `\u` escape, such as tool output cut in the middle of an emoji. Native,+ shell, PowerShell and direct hook clients now share the bounded server-side+ repair, replacing the unpaired escape with U+FFFD instead of dropping the+ whole event.+ ([#1432](https://github.com/akitaonrails/ai-memory/pull/1432))+ - Model-produced page paths are now cleaned of the remaining shapes `ensure_portable`+ refuses, a component ending in a dot or space and a DOS device name like `aux.md`,+ so one such path no longer aborts every page in a consolidation or bootstrap batch.+ ([#1430](https://github.com/akitaonrails/ai-memory/pull/1430))+ - Preserved FTS5 column filters inside parenthesized groups, so queries such+ as `(title:handoff)` no longer broaden into a search for the literal word+ `title` across every indexed field. ([#1442](https://github.com/akitaonrails/ai-memory/pull/1442))+ - Revalidated session-purge tombstones inside the reindex write transaction,+ preventing a queued watcher update from recreating a deleted summary after+ file cleanup failed. Kept surviving manual replacements at the same path+ editable through the watcher (#1439).- Added exact hover timestamps to `/web` page metadata, made the OKF upgradedialog keyboard accessible, and added a labelled main-navigation landmarkwith current-page state and narrow-screen wrapping.diff --cc companions/ai-memory-importer/src/main.rsindex 29901e05,019da705..26e084ac--- a/companions/ai-memory-importer/src/main.rs+++ b/companions/ai-memory-importer/src/main.rs@@@ -1486,20 -1468,30 +1510,44 @@@ mod testsassert!(parse_markdown("---\ntitle: a\ntitle: b\n---\nbody").is_err());}+ /// A `# ` line inside fenced code is a shell or Python comment, not the+ /// page's H1; the server's `derive_title` skips fences the same way.+ #[test]+ fn title_skips_comment_lines_inside_code_fences() {+ let parsed = parse_markdown("```bash\n# install deps\nnpm i\n```\n# Real Title\n").unwrap();+ assert_eq!(parsed.title.as_deref(), Some("Real Title"));+ let tilde = parse_markdown("~~~~\n# not it\n~~~\n# still code\n~~~~\n# Title\n").unwrap();+ assert_eq!(tilde.title.as_deref(), Some("Title"));+ let none = parse_markdown("```sh\n# just a comment\n```\nbody\n").unwrap();+ assert_eq!(none.title, None);+ let inline = parse_markdown("```code``` text\n# After\n").unwrap();+ assert_eq!(inline.title.as_deref(), Some("After"));+ }++ /// A frontmatter-only page whose closing fence ends the file with no+ /// final newline, which the server's parser has accepted since #1402.+ #[test]+ fn parses_omc_frontmatter_closed_at_end_of_file() {+ let parsed = parse_markdown("---\ntitle: T\ntier: procedural\npinned: true\n---").unwrap();+ assert_eq!(parsed.title.as_deref(), Some("T"));+ assert_eq!(parsed.tier.as_deref(), Some("procedural"));+ assert!(parsed.pinned);+ assert_eq!(parsed.body, "");++ let crlf = parse_markdown("\u{feff}---\r\ntitle: T\r\n---").unwrap();+ assert_eq!(crlf.title.as_deref(), Some("T"));+ assert_eq!(crlf.body, "");++ let not_a_fence = parse_markdown("---\ntitle: T\n----").unwrap();+ assert_eq!(not_a_fence.title, None);++ let empty = parse_markdown("---\n---").unwrap();+ assert_eq!(empty.body, "");+ let empty_with_body = parse_markdown("---\n---\n# Body\n").unwrap();+ assert_eq!(empty_with_body.title.as_deref(), Some("Body"));+ assert_eq!(empty_with_body.body, "# Body\n");+ }+/// A wiki checked out on Windows with `core.autocrlf=true`, or saved/// there by an editor, has CRLF line endings; one saved as "UTF-8 with/// BOM" opens with U+FEFF. Either used to miss the fence, so kind, tier,