Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(setup): write plain paths into the Windows logon entry
AkitaOnRails805e01b9c186
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5a254dfc..7d428a4b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -50,7 +50,8 @@ version in [`docs/changelog/`](docs/changelog/):The value is written and read through the registry API, not by running`reg.exe`: an unsigned binary running `reg.exe add` on the `Run` key is acommon persistence signal, and Bitdefender's behavioral engine quarantined- `ai-memory.exe` for it (#1280).+ `ai-memory.exe` for it (#1280). Its paths are written plainly, without the+ `\\?\` prefix a canonical path carries.The host runs the server with no console window and restarts it after afailure, giving up after five failures within ten seconds of starting.`ai-memory uninstall --apply` stops the host and removes the value when itdiff --git a/crates/ai-memory-cli/src/commands/user_service.rs b/crates/ai-memory-cli/src/commands/user_service.rsindex a5d88616..207abdd9 100644--- a/crates/ai-memory-cli/src/commands/user_service.rs+++ b/crates/ai-memory-cli/src/commands/user_service.rs@@ -361,9 +361,16 @@ fn windows_arg(what: &str, text: &str) -> Result<String> {/// The logon entry: the binary `setup` ran from, the data dir and config it/// used, and `service-host`, as one command line.fn render_windows(spec: &ServiceSpec) -> Result<ServiceUnit> {- let exe = checked_path("binary", &spec.exe)?;- let data_dir = checked_path("data dir", &spec.data_dir)?;- let config = checked_path("config file", &spec.config_path)?;+ // Write plain paths: the canonical form of an install path carries a+ // `\\?\` verbatim prefix, which is unusual in a Run value and one of the+ // signals behaviour-based antivirus weighs (#1280). Uninstall compares+ // both forms as equal, so an entry written by an older build still+ // matches.+ use super::path_util::strip_windows_verbatim_prefix as plain;+ let exe = plain(checked_path("binary", &spec.exe)?);+ let data_dir = plain(checked_path("data dir", &spec.data_dir)?);+ let config = plain(checked_path("config file", &spec.config_path)?);+ let (exe, data_dir, config) = (exe.as_ref(), data_dir.as_ref(), config.as_ref());let contents = format!("{} --data-dir {} --config {} {SERVICE_HOST}",windows_arg("binary", exe)?,@@ -1759,6 +1766,30 @@ mod windows_entry_tests {}}+ /// A canonical `\\?\` install path is written as a plain path (#1280).+ #[test]+ fn the_rendered_entry_writes_plain_paths() {+ if !cfg!(windows) {+ return;+ }+ let spec = ServiceSpec {+ exe: PathBuf::from(r"\\?\C:\Users\me\ai\ai-memory.exe"),+ data_dir: PathBuf::from(r"\\?\C:\Users\me\AppData\Local\ai-memory"),+ config_path: PathBuf::from(r"\\?\C:\Users\me\AppData\Local\ai-memory\config.toml"),+ home: PathBuf::from(r"C:\Users\me"),+ xdg_config_home: None,+ };+ let unit = render(ServiceManager::WindowsRun, &spec).unwrap();+ assert!(!unit.contents.contains(r"\\?\"), "{}", unit.contents);+ assert!(+ unit.contents.starts_with(+ r#""C:\Users\me\ai\ai-memory.exe" --data-dir "C:\Users\me\AppData\Local\ai-memory""#+ ),+ "{}",+ unit.contents+ );+ }+/// The rendered entry is one setup recognises as its own, names the/// install's data dir and config, and its host command matches it.#[test]