Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(cli): print the random tail of the page id in write-page and restore-page
Jay Hemnani07f06669109f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 77cfb862..51f0a3d8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,14 @@ version in [`docs/changelog/`](docs/changelog/):## [Unreleased]+### Fixed++- `ai-memory write-page` and `restore-page` now print the last eight+ characters of the page id instead of the first eight. Page ids are UUIDv7,+ so the first eight are a timestamp prefix that every page written within+ about a minute shares, and the printed `page_id` was the same for all of+ them. The web UI already shortens ids this way.+## [3.2.3] - 2026-10-24### Changeddiff --git a/crates/ai-memory-cli/src/commands/restore_page.rs b/crates/ai-memory-cli/src/commands/restore_page.rsindex 83b1684a..ff00162c 100644--- a/crates/ai-memory-cli/src/commands/restore_page.rs+++ b/crates/ai-memory-cli/src/commands/restore_page.rs@@ -59,7 +59,7 @@ pub async fn run(config: &Config, args: RestorePageArgs) -> Result<()> {workspace,project,resp.restored_from,- &resp.page_id[..resp.page_id.len().min(8)]+ super::write_page::short_page_id(&resp.page_id));if let Some(pre) = resp.pre_checkpoint {println!("pre-restore checkpoint: {pre}");diff --git a/crates/ai-memory-cli/src/commands/write_page.rs b/crates/ai-memory-cli/src/commands/write_page.rsindex 9300f2ef..7fcd164b 100644--- a/crates/ai-memory-cli/src/commands/write_page.rs+++ b/crates/ai-memory-cli/src/commands/write_page.rs@@ -86,10 +86,38 @@ pub async fn run(config: &Config, args: WritePageArgs) -> Result<()> {if let Some(warning) = resp.manifest_warning.as_deref() {eprintln!("ai-memory: warning: {warning}");}- let short_id = &resp.page_id[..resp.page_id.len().min(8)];println!("✓ wrote {} (page_id={}) under {}/{}",- resp.path, short_id, workspace, project+ resp.path,+ short_page_id(&resp.page_id),+ workspace,+ project);Ok(())}++/// The last eight characters of a page id, for display. Page ids are UUIDv7,+/// whose leading characters are a timestamp that pages written close together+/// share.+pub(crate) fn short_page_id(id: &str) -> &str {+ let start = id.char_indices().rev().nth(7).map_or(0, |(i, _)| i);+ &id[start..]+}++#[cfg(test)]+mod tests {+ use super::short_page_id;++ #[test]+ fn short_page_id_keeps_the_random_tail() {+ assert_eq!(+ short_page_id("01a16f89-8ca9-7f40-8847-eb44e095e3ea"),+ "e095e3ea"+ );+ assert_eq!(+ short_page_id("01a16f89-eb81-70a2-8ba4-c84c5783b7fb"),+ "5783b7fb"+ );+ assert_eq!(short_page_id("abc"), "abc");+ }+}