Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
feat(core): expose is_dos_device_name for reuse outside PagePath
Talysson de Oliveira Cassiano4e9dbe60249b
diff --git a/crates/ai-memory-core/src/ids.rs b/crates/ai-memory-core/src/ids.rsindex 4c1ae4e8..43719951 100644--- a/crates/ai-memory-core/src/ids.rs+++ b/crates/ai-memory-core/src/ids.rs@@ -811,6 +811,13 @@ const DOS_DEVICE_NAMES: &[&str] = &["com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9",];+/// Whether `stem` (a file name without its extension) is a DOS device name+/// Windows resolves to a device instead of a file, compared case-insensitively.+#[must_use]+pub fn is_dos_device_name(stem: &str) -> bool {+ DOS_DEVICE_NAMES.contains(&stem.to_ascii_lowercase().as_str())+}+/// Characters Windows refuses in a filename. `/` is the separator and is/// handled by the caller; `\\` and a drive prefix are already rejected by/// [`PagePath::new`].@@ -857,7 +864,7 @@ fn ensure_portable_component(component: &str, full: &str) -> Result<(), MemoryEr// Device names match on the stem, so `CON`, `CON.md` and `con.markdown`// are all the console.let stem = component.split('.').next().unwrap_or(component);- if DOS_DEVICE_NAMES.contains(&stem.to_ascii_lowercase().as_str()) {+ if is_dos_device_name(stem) {return invalid(&format!("uses the reserved DOS device name {stem:?}; Windows resolves it to a device, not a file"));diff --git a/crates/ai-memory-core/src/lib.rs b/crates/ai-memory-core/src/lib.rsindex 746f8c56..c42d04b9 100644--- a/crates/ai-memory-core/src/lib.rs+++ b/crates/ai-memory-core/src/lib.rs@@ -61,7 +61,8 @@ pub use handoff::{pub use ids::{AgentKind, ApiCredentialId, AutoImproveProposalId, AutoImproveRunId, EntityId, HandoffId,ManagedRunId, MessageId, ObservationId, PageFeedbackId, PageId, PagePath, ProjectId, SessionId,- UserId, WorkspaceId, WorkstreamId, is_git_reserved_component, portable_page_key,+ UserId, WorkspaceId, WorkstreamId, is_dos_device_name, is_git_reserved_component,+ portable_page_key,};pub use message::{AgentMessage, MessageBox, MessageClaim, MessageOrigin, MessageState, NewAgentMessage,