Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
test(mcp): cover patch headings that end in # without a space
Vinícius DS Andrade3d1b22e95b15
diff --git a/crates/ai-memory-mcp/src/page_patch.rs b/crates/ai-memory-mcp/src/page_patch.rsindex 9bdce439..3f87f0dc 100644--- a/crates/ai-memory-mcp/src/page_patch.rs+++ b/crates/ai-memory-mcp/src/page_patch.rs@@ -500,4 +500,34 @@ mod tests {"# T\n## Log\none\nnext\n## Tail\ntwo\n## Fresh\nnew\n");}++ #[test]+ fn a_trailing_hash_closes_a_heading_only_after_a_space() {+ let body = "# T\n## Notes on C#\nold\n## Tail ##\nend\n";+ let anchors: Vec<_> = section_hashes(body)+ .0+ .into_iter()+ .map(|section| section.anchor)+ .collect();+ assert_eq!(anchors, ["T", "Notes on C#", "Tail"]);+ let patched = apply(+ body,+ &[+ PagePatchEdit::Append {+ target: AppendTarget::Section,+ anchor: Some("Notes on C#".into()),+ content: "more".into(),+ },+ PagePatchEdit::AddSection {+ anchor: "## F#".into(),+ content: "new".into(),+ },+ ],+ )+ .unwrap();+ assert_eq!(+ patched,+ "# T\n## Notes on C#\nold\nmore\n## Tail ##\nend\n## F#\nnew\n"+ );+ }}