Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(wiki): fall back to the target when an exported wikilink's label is empty
kevin93272b32f51dc795
diff --git a/crates/ai-memory-wiki/src/markdown.rs b/crates/ai-memory-wiki/src/markdown.rsindex e7b3f4cf..3c3fbbd6 100644--- a/crates/ai-memory-wiki/src/markdown.rs+++ b/crates/ai-memory-wiki/src/markdown.rs@@ -677,7 +677,11 @@ fn resolve_local_wikilink(});let mut href = relative_href(&page_dir, &target);href.push_str(suffix);- let display = label.map_or(target_part, str::trim).to_string();+ let display = label+ .map(str::trim)+ .filter(|l| !l.is_empty())+ .unwrap_or(target_part)+ .to_string();Some((href, display))}@@ -1779,6 +1783,22 @@ mod tests {);}+ #[test]+ fn rewrite_local_wikilinks_falls_back_to_target_for_an_empty_label() {+ // An empty or blank `|label` must not export as `[](…)`, a link with+ // no text to click. The web view and `delink_wikilinks` already show+ // the target in that case.+ let path = PagePath::new("concepts/a.md").unwrap();+ assert_eq!(+ rewrite_local_wikilinks("[[decisions/b.md|]]", &path, "proj"),+ "[decisions/b.md](../decisions/b.md)"+ );+ assert_eq!(+ rewrite_local_wikilinks("[[decisions/b| ]]", &path, "proj"),+ "[decisions/b](../decisions/b.md)"+ );+ }+#[test]fn rewrite_local_wikilinks_preserves_anchor_and_query_fragments() {let path = PagePath::new("concepts/a.md").unwrap();